How to programmatically copy content from Spreadsheet JSON

Posted by: vinayakbagi on 16 June 2020, 11:43 pm EST

  • Posted 16 June 2020, 11:43 pm EST

    Hi Team,

    I am currently trying to programmatically copy content for Spreadsheet JSON. But the problem is it is copying data but is not retrieving cell related info like merge cell data, height, width of cell etc.

    Below is my sample code.

    editJsonData(){

    //testfiledata2 contains SSJSON

    let newWorkbookObj = testfiledata2;

    this.spreadsheet.fromJSON(newWorkbookObj)

    // Inserted 6 rows

    this.spreadsheet.getActiveSheet().addRows(14, 6)

    // trying to paste data available in row (8-12) to row (13-17)

    for (let index = 8; index < 13; index++) {

    newWorkbookObj.sheets[‘page02’].data.dataTable[index + 7] = newWorkbookObj.sheets[‘page02’].data.dataTable[index]

    }

    this.spreadsheet.fromJSON(newWorkbookObj)

    }

  • Posted 18 June 2020, 12:19 am EST

    Hi,

    It is not recommended to not manipulate the JSON data directly. Looking at your code, it looks like you want to perform copy-paste from one range to another. For this, you may use the copyTo method. Please refer to the following code snippet. if it doesn’t fulfill your requirement, please provide information about the use case that you are trying to implement and why you are manipulating the JSON data directly so that we can help you accordingly:

    sheet.copyTo(fromRow, fromCol, toRow, toCol, rowCount, colCount, GC.Spread.Sheets.CopyToOptions.all);
    

    For more information please refer to the following References:

    copyTo method: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Worksheet~copyTo.html

    Regards

Need extra support?

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

Learn More

Forum Channels