OS version: Win 10 x64
App version: 8.2.2.22 (x64 exe)
Downloaded from: ONLYOFFICE website
Just wanted to put a note in this forum for other coders that might get tripped up by using range.Cut() or range.Copy() to place a range in the clipboard for later, and then think you would be able to use range.Paste(‘clipboard’) or other param to paste back into your sheet.
While you could use range.Cut(toRange), or range.Paste(fromRange) to automate a Move, range.Paste() simply did not have user access to a clipboard, and regardless of param would log “Invalid range” without indicating which.
To paste your cut or copied range from the clipboard back into your sheet, you had to switch from the ApiRange over to the ApiWorksheet and use something like oWorksheet.Paste(toRange).
/**
* Range.Cut() empty parens moves content to clipboard
* do stuff
* Worksheet.Paste(toRange) to restore contents to range
*/
(function()
{
// Selection to clipboard
const oSelectedRange = Api.GetSelection();
const originalSelectionAddr = oSelectedRange.GetAddress();
oSelectedRange.Cut(); // also worked with (null)
if(typeof oCutCopyTo == 'undefined' || oCutCopyTo === null) {
console.log("Cut/Copied to ? navigator.clipboard ?");
} else {
console.log(`Moved to ${oCutCopyTo.GetAddress()}`);
}
// Do stuff here
// Paste From Clipboard
const oPasteTo = Api.GetRange(originalSelectionAddr);
//const oPasteTo = Api.GetRange("C13");
console.log(`verify oPasteTo ${oPasteTo.GetAddress()}`);
const aSheet = Api.GetActiveSheet();
aSheet.Paste(oPasteTo);
})();