Posted 14 June 2022, 6:11 pm EST
Hi,
We are sorry but on further investigation, we found that the writing internal clipboard in spreadJS is not supported. For this, you need to implement your own paste command and replace it with internaClipboardPaste. Please refer to the following code snippet and attached sample that explains the same.
var pasteCommand = {
canUndo: true,
execute: function (spread, options, isUndo) {
var Commands = GC.Spread.Sheets.Commands;
if (isUndo) {
Commands.undoTransaction(spread, options);
return true;
} else {
Commands.startTransaction(spread, options);
spread.suspendPaint();
let sheet = spread.getActiveSheet();
let clipboardtext = "Text\nText2\tText3";
var toRanges = [
new GC.Spread.Sheets.Range(
sheet.getActiveRowIndex(),
sheet.getActiveColumnIndex(),
clipboardtext.split("\n").length,
clipboardtext.split("\t").length
)
];
spread.commandManager().execute({
cmd: "clipboardPaste",
sheetName: "Sheet1",
fromSheet: spread.getActiveSheet(),
pastedRanges: toRanges,
isCutting: false,
clipboardText: clipboardtext,
pasteOption: GC.Spread.Sheets.ClipboardPasteOptions.all
});
spread.resumePaint();
Commands.endTransaction(spread, options);
return true;
}
}
};
spread.commandManager().register("myPaste", pasteCommand, 86, true);
sample: https://codesandbox.io/s/spread-js-starter-forked-mgq5nr?file=/src/index.js:535-1738
regards,
Avinash