这边根据您的需求,请用下面的代码重写ctrl+c
- var command = {
- canUndo: false,
- execute: function (context, options, isUndo) {
- var Commands = GC.Spread.Sheets.Commands;
- if (isUndo) {
- Commands.undoTransaction(context, options);
- return true;
- } else {
- Commands.startTransaction(context, options);
- let spread = context;
- let sheetName = options.sheetName;
- let command = {};
- command.cmd = "copy";
- command.sheetName = sheetName;
- command.ignoreClipboard = true;
- command.callback = function () {
- options.callback(command.copyData.copyText, command.copyData.copyHtml);
- };
- spread.commandManager().execute(command);
-
- Commands.endTransaction(context, options);
- return true;
- }
- }
- };
- spread.commandManager().register("myCopy", command);
- spread.commandManager().setShortcutKey("myCopy", GC.Spread.Commands.Key.c, true, false, false, false);
复制代码
用下面的代码重写ctrl+v
- var commandV = {
- canUndo: false,
- execute: function (context, options, isUndo) {
- var Commands = GC.Spread.Sheets.Commands;
- if (isUndo) {
- Commands.undoTransaction(context, options);
- return true;
- } else {
- Commands.startTransaction(context, options);
- let spread = context;
- let sheetName = options.sheetName;
- let command = {};
- command.cmd = "paste";
- command.sheetName = sheetName;
-
- spread.commandManager().execute(command);
-
- Commands.endTransaction(context, options);
- return true;
- }
- }
- };
- spread.commandManager().register("myPaste", commandV);
- spread.commandManager().setShortcutKey("myPaste", GC.Spread.Commands.Key.v, true, false, false, false);
复制代码 用以上代码能实现表单内的复制,表单内容无法向外部复制,外部内容可以粘贴在表单。
|