undo() {
let undoManager = this.spread.undoManager();
undoManager.undo();
},
xin() {
let that = this;
let transactionName = 'tran_' + this.generateUniqueId();
// 撤回增加事务
let command = {
canUndo: true,
execute: function (spread, options, isUndo) {
let Commands = GC.Spread.Sheets.Commands;
options.cmd = transactionName;
if (isUndo) {
Commands.undoTransaction(spread, options);
return true;
} else {
Commands.startTransaction(spread, options);
spread.suspendPaint();
// 执行excel具体操作
let source = [
{ "a": "a", "a": '', },
]
let spreadNS = GC.Spread.Sheets;
let sheet = that.spread.getActiveSheet();
let tableName = 'table_' + that.generateUniqueId();
let table = sheet.tables.addFromDataSource(tableName, 1, 1, source, spreadNS.Tables.TableThemes.medium15);
spread.resumePaint();
Commands.endTransaction(spread, options);
return true;
}
}
};
let commandManager = that.spread.commandManager();
let sheetName = that.spread.getSheet(0).name();
if (sheetName == "Evaluation Version") {
sheetName = that.spread.getSheet(1).name();
}
commandManager.register(transactionName, command);
commandManager.execute({
cmd: transactionName,
sheetName: sheetName, // 事务必填sheetName
});
let redoStack = this.spread.undoManager().getRedoStack();
let undoStack = this.spread.undoManager().getUndoStack();
console.log(redoStack, "保留栈")
console.log(undoStack, "撤销栈")
},
版本@grapecity-software/spread-sheets-vue": "17.1.0", 确实撤回不了 |