Thanks for bringing this up.
The fact that the undo stack gets cleared when you execute the APIs is -- for Excel -- unfortunately unavoidable. You get the same behavior in VBA or VSTO, and it has to do with the way that Excel is fundamentally designed. Perhaps we could be a tad better at remembering undos for trivial operations, but even the UI itself or Excel Online will clear away the undo stack for things like deleting a sheet.
That being said, I do appreciate both suggestions, and have already passed them along to the team. Namely:
- Avoid clearing the undo stack on read-only operations; only clear it on 'write'.
- Think about some sort of copying/serialization method for worksheets, so that there's a state to revert to.
We'll see what we can do.