您好,实现这个操作需要重写dragDrop这个command,请参考以下代码:
- window.onload = function () {
- let designerConfig = JSON.parse(
- JSON.stringify(GC.Spread.Sheets.Designer.DefaultConfig)
- );
- let designer = new GC.Spread.Sheets.Designer.Designer(
- "gc-designer-container",
- designerConfig
- );
- let spread = designer.getWorkbook();
- let sheet = spread.getActiveSheet();
- sheet.getCell(0, 0).value("Hello World");
- let command = {
- canUndo: true,
- execute: function (context, options, isUndo) {
- let Commands = GC.Spread.Sheets.Commands;
- options.cmd = "dragDrop";
- if (isUndo) {
- Commands.undoTransaction(context, options);
- return true;
- } else {
- Commands.startTransaction(context, options);
- console.log("dragDrop");
- Commands.endTransaction(context, options);
- return true;
- }
- },
- };
- let commandManager = spread.commandManager();
- commandManager.register("dragDrop", command);
- };
复制代码 |