本帖最后由 artman5545 于 2018-10-9 08:57 编辑
下列代码实现效果模拟excel中"CTRL+;"填充当前时间快捷键,但是操作没办法撤销
- spread.commandManager().register("fillNow",
- {
- canUndo: true,
- execute: function (context, options, isUndo) {
- var Commands = GC.Spread.Sheets.Commands;
- if (isUndo) {
- Commands.undoTransaction(context, options);
- return true;
- } else {
- Commands.startTransaction(context, options);
- var ranges = sheet.getSelections();
- if (ranges.length > 0) {
- var range = ranges[0];
- var cell = sheet.getCell(range.row, range.col);
- if (!cell.locked()) {
- sheet.setValue(range.row, range.col, new Date());
- }
- }
- Commands.endTransaction(context, options);
- return true;
- }
- }
- }, 186, true, false, false, false);
复制代码 |