Copy and paste with SpreadJS

Question!

I have two spreads in my interface: SpreadA and SpreadB.

Both of them have a sheet called MySheet and I am trying to copy the contents of MySheet in SpreadA and paste them into MySheet in SpreadB.

I have used ClipboardPasteUndoAction but it's not working for me. If I try to paste the contents in the same spread (SpreadA to SpreadA), it works, however what I need is to paste into a different spread (SpreadA to SpreadB).

var sheetFrom = SpreadA.getSheetFromName("MySheet");
var sheetTo   = SpreadB.getSheetFromName("MySheet");

var fromRange = new $.wijmo.wijspread.Range(0, 0, 10, 10);
var toRanges = [new $.wijmo.wijspread.Range(0, 0, 10, 10)];

var clipboardCopyPasteAction = new $.wijmo.wijspread.UndoRedo.ClipboardPasteUndoAction(sheetFrom, sheetFrom, sheetTo, {fromRange: fromRange, pastedRanges: toRanges, isCutting: false, clipboardText: "" }, $.wijmo.wijspread.ClipboardPasteOptions.Values);
clipboardCopyPasteAction.execute(sheetFrom);

Any Idea of how to do it?



Answers

I used a method to export the contents of a specific spreadsheet

sheetFrom.toJSON();

Then, I imported all the contents of the spreadsheet into the other spreadsheet

sheetTo.fromJSON(sheetFrom.toJSON());


This video can help you solving your question :)
By: admin