SpreadJS toJson calculate entire woorkbook

Posted by: asaf.shechter on 23 April 2023, 3:15 am EST

  • Posted 23 April 2023, 3:15 am EST

    Hello,

    is it possible to call the toJson method in spreadJs without triggering calculation of the entire workbook?

    I tried to suspend calc service and then resume by calling the following methods:

    suspendCalcService(false);

    workbook.toJson();

    resumeCalcService(false)

    but after resuming the calc service the workbook is calculated,

    how can I avoid it?

    Thanks.

  • Posted 24 April 2023, 4:12 pm EST

    Hello,

    Please note that when spread.toJSON() method is used, then the spread is calculated so that the changes could be reflected/updated in the json of the spread. To stop the spread from recalculating after spread.toJSON() method is used, you may dispose the calc service using spread.getCalcService().dispose() method.

    Please refer to the code snippet and attached sample.

        spread.suspendCalcService();
        console.log(spread.toJSON());
        spread.getCalcService().dispose();
        spread.resumeCalcService();

    Sample: https://jscodemine.grapecity.com/share/lK1o_Kk_pUmH9-d8wTY_9g/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Findex.html"}

    If you still face any issues, please let us know. Also, please explain your use case and provide us the excel file in which you want to prevent the recalculation so that we could provide solution more accurately.

    Regards,

    Ankit

  • Posted 26 April 2023, 7:41 pm EST

    Hello Ankit ,

    it doesn’t seem to work for us ,

    looks like the dispose method makes the spread unresponsive,

    we found another solution that did what we want : workbook.getCalcService().resumeWithoutCalc() ,

    if you think this method might cause some issues please let me know,

    Thanks.

  • Posted 27 April 2023, 8:46 pm EST

    Hi,

    Apologies, we have tested the spread.getCalcService().dispose() function and did not experience any problems. Could you provide a sample where this function is causing an issue? This will enable us to investigate the matter more thoroughly.

    Also, thank you for sharing your solution with us. We have tested the function on our end and encountered no issues. You may use this function to meet your needs. If you come across any problems while using the function, please inform us with an example, so that we may assist you accordingly.

    Please feel free to inform us if you encounter any difficulties.

    Regards,

    Ankit

  • Posted 29 April 2023, 9:07 pm EST

    Hi,

    we found it while debugging ,

    it’s not documented anywhere else ,

    not in documentation and not in the types,

    we just want to make sure this method won’t change

    in future builds as it seems undocumented and not exposed in

    your official api,

    Thanks.

  • Posted 30 April 2023, 11:26 pm EST

    Hello,

    We have escalated this issue to the concerned team. The internal tracking id for this issue is: SJS-18104. Please be rest assured that we will keep you updated as there is any progress on this issue.

    Please let us know if you still face any issues or have any doubts.

    Regards,

    Ankit

  • Posted 8 May 2023, 7:51 pm EST

    Hello,

    The devs have replied for the issue with internal id SJS-18104. They have mentioned that there is no relation between suspending the calc service and using spread.toJSON() method. The spread is calculated when calc service is resumed. Also, the spread.getCalcService().resumeWithoutCalc() is not a public API and it is unlikely to become public.

    Could you please provide us a working sample which replicates the issue you are facing? Also, please explain your use case and requirements. This will enable us to provide you an appropriate solution that does not rely on APIs which are not public. It would we hard to comment on the nature of issue without a sample replicating the issue.

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels