|
不废话,直接代码
- private Stack<Action> actionStack = new Stack<Action>();
- private void SetCellValues()
- {
- var worksheet = Globals.ThisAddIn.Application.ActiveSheet as Excel.Worksheet;
- var range = worksheet.Range["A1"];
- var previousValue = range.Value2;
- // 保存当前状态以便恢复
- actionStack.Push(() =>
- {
- range.Value2 = previousValue;
- });
- }
- private void UndoLastOperation()
- {
- if (actionStack.Count > 0)
- {
- var undoAction = actionStack.Pop();
- undoAction();
- }
- }
复制代码 来源:https://www.cnblogs.com/xt_hjl/p/18210702
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作! |
|