Move/Copy sheet feature

Posted by: davide.vago on 2 November 2020, 1:40 am EST

  • Posted 2 November 2020, 1:40 am EST

    Hi there,

    I'm reaching out to you over the sheet copy feature.

    The way this works is you right click on worksheet, select ‘Move or Copy’, then select copy, and an exact replica of the current worksheet opens up next to the original sheet.

    Manual copy/paste via clipboard cannot handle huge data amounts as per browser/os limitations, therefore we are unable to manually select all and copy the content via keyboard shortcut (cmd/ctrl+C) and then paste into a new sheet.

    Looking forward to find a solution
  • Replied 3 November 2020, 10:27 pm EST

    Hi Davide,

    SpreadJS support JSON import/export feature by which we could implement this feature. Please refer to the following code snippet and the attached sample that demonstrates the same.

    document.getElementById("copy").addEventListener("click", () => {
    sheetJson = spread.getActiveSheet().toJSON({
    includeDataSource: true
    document.getElementById("paste").addEventListener("click", () => {
    let sheet = spread2.getActiveSheet();
    if (sheetJson) sheet.fromJSON(sheetJson);



    JSON Serialization:

  • Replied 12 November 2020, 1:50 am EST

    Thank you Avinash,

    I was hoping to have something available natively, this solution requires an extra interface outside the context menus of the workbook.

    However, the main goal of the copy function was to create a new sheet within the same workbook with the copied data and it seems not be covered.

    In fact, the given example is instead showcasing the possibility to copy (using the fromJSON/toJSON methods) from a workbook instance to a different workbook instance.

    It will probably quite complex to handle the copy to new sheet using toJSON as it will require to get the activeSheet, get the relative name, extract the JSON, search within the sheets key the matching name to then slice it and fire an addSheet call.

    If the above is the case it's definitely too over engineered for the scope.
  • Replied 13 November 2020, 12:10 am EST

    Hi Davide,

    This feature is currently not supported by SJS but we have made an enhancement request on your behalf. we will update on the development of this case. The internal ID for this issue will be SJS-6435.
    Further, You may also paste the sheet in the current workbook using the fromJSON method. Please refer to the following code snippet and attached an updated sample and let us know if you face any issues.

    document.getElementById("internalPaste").addEventListener("click", () => {
    var sheet = new GC.Spread.Sheets.Worksheet("NewSheet");

    spread.addSheet(spread.getSheetCount(), sheet);
    spread.setActiveSheetIndex(spread.getSheetCount() - 1);



Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels