Save Workbook / Sheet into database

Posted by: nautilux on 28 June 2020, 7:23 pm EST

  • Posted 28 June 2020, 7:23 pm EST

    Hi

    I try to save Workbook / Sheet into database with

    
    Save :
    	var spread = new GC.Spread.Sheets.Workbook($("#ss")[0]);
            var sheet = spread.getActiveSheet();
    var data = JSON.stringify(sheet.toJSON())
    
    Load: 
    	sheet.fromJSON(JSON.parse(data))
    
    

    But I always return error

    Uncaught SyntaxError: Unexpected token u in JSON at position 0

    at JSON.parse ()

    at :1:21

    How can I achieve this?

    Thanks

  • Posted 29 June 2020, 6:48 pm EST

    Hi,

    The code snippet shared by you is correct and should not throw any error. We created a sample based on the code snippet and everything is working fine. Please refer to the same:

    https://codesandbox.io/s/spread-js-starter-k9iwy?file=/src/index.js

    Based on the error, it seems like the value of data is not in correct JSON format. Please make sure that the data variable contains the correct JSON string when using the JSON parse, if the issue persists, please share a small sample replicating the issue or the JSON data you are facing issues with.

    Regards

Need extra support?

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

Learn More

Forum Channels