您好,建议将comand中做的操作的js代码封装成一个命令,在反序列化前的spread实例中首先需要同步注册这个命令,之后再反序列化之后就可以执行点击按钮后的代码了。
封装命令相关可以参考下面代码:
- let style = new GC.Spread.Sheets.Style();
- style.cellButtons= [
- {
- caption: "MyButton",
- useButtonStyle: true,
- command: "click"
- }
- ];
-
- var command = {
- canUndo: true,
- execute: function (context, options, isUndo) {
- var Commands = GC.Spread.Sheets.Commands;
- if (isUndo) {
- Commands.undoTransaction(context, options);
- return true;
- } else {
- console.log("click");
- return true;
- }
- }
- };
- var commandManager = spread.commandManager();
- commandManager.register("click", command);
-
- sheet.setStyle(0, 0, style);
-
复制代码 |