sheetName写成字符串数组即可,示例代码如下:
- var command1 = {
- canUndo: true,
- execute: function (spread, options, isUndo) {
- var Commands = GC.Spread.Sheets.Commands;
- if (isUndo) {
- console.log(options);
- Commands.undoTransaction(spread, options);
- return true;
- } else {
- Commands.startTransaction(spread, options);
- spread.suspendPaint();
- var sheet1 = spread.getActiveSheet();
- sheet1.setValue(0,0,"sheet1");
- var sheet2 = spread.getSheet(1);
- sheet2.setValue(0,0,"sheet2");
- spread.resumePaint();
- Commands.endTransaction(spread, options);
- return true;
- }
- }
- };
- var commandManager = spread.commandManager();
- commandManager.register('sheetCmd', command1);
- document.getElementById('test').onclick = function () {
- commandManager.execute({
- cmd: 'sheetCmd',
- sheetName: ["Sheet1", "Sheet2"]
- });
- }
复制代码
|