您好,我这边根据您的Demo,找到了一个更简便的实现方法:
let designerConfig = JSON.parse(
JSON.stringify(GC.Spread.Sheets.Designer.DefaultConfig)
);
let newCommand = GC.Spread.Sheets.Commands.renameSheet;
if (newCommand) {
let oldExecute = newCommand.execute;
newCommand.execute = function (context, options, isUndo) {
let Commands = GC.Spread.Sheets.Commands;
if (isUndo) {
Commands.undoTransaction(context, options);
return true;
} else {
Commands.startTransaction(context, options);
sheet.setValue(0, 0, "aaa");
oldExecute.call(this, context, options, isUndo);
Commands.endTransaction(context, options);
return true;
}
};
}
designerConfig.commandMap = {};
designerConfig.commandMap[GC.Spread.Sheets.Commands.renameSheet] = newCommand;
let designer = new GC.Spread.Sheets.Designer.Designer(
"gc-designer-container",
designerConfig
);
效果如下:
|