Handling new SJS format on code level

Posted by: uraatz on 22 December 2022, 1:52 am EST

    • Post Options:
    • Link

    Posted 22 December 2022, 1:52 am EST

    SpreadJS version 16 introduce the new file format .SJS

    How is this on code level handled?

    Are there new load and export functions?

    Because currently there are “only”

    var jsonStr = null;
    //export
    jsonStr = JSON.stringify(activeSheet.toJSON());
    //import
    activeSheet.fromJSON(JSON.parse(jsonStr));

    See

    https://help.grapecity.com/spread/SpreadSheets10/JavascriptLibrary~GC.Spread.Sheets.Worksheet~fromJSON.html

    Is there something like

    var sjs = null;
    //export
    sjs = activeSheet.toSJS();
    and
    //import
    activeSheet.fromSJSON(sjs));

  • Posted 22 December 2022, 11:44 pm EST

    Hi,

    SJS format is zipped folder. SpreadJS will provide blob of which you need to saves as .sjs. Please refer to the following demo that explains the same.

       spread.save(function(blob) { saveAs(blob, fileName); }, function() {}, options);

    demo: https://www.grapecity.com/spreadjs/demos/features/spreadjs-file-format/overview/purejs

    Regards,

    Avinash

  • Posted 23 December 2022, 2:05 am EST - Updated 23 December 2022, 2:48 am EST

    Thank you very much for your really fast answer!

    OK I took a look into it.

    Nice – but unfortunately not exactly what I hoped to find and need - or i´ve overseen it. :wink:

    Your demo shows how to load and save files.

    But I (we developer) need also two functions like the shown above.

    Means a export function that returns the spreadsheet as “sjs” (assuming its binary data).

    Like

    const sjsBinaryData: *typedArray* = this.activeSheet.getSjs();

    ( Where typedArray is meant as a Javascript “typed array”;

    please see

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays )

    And a import function that consumes SJS (binary) data.

    Like

    this.activeSheet.fromSJS(sjsBinaryData);

    These export and import functions are needed to store the value of the here used variable “sjsBinaryData” in a database and to read it from the database and assign it to the spreadsheet.

    Any plans for that?

  • Posted 23 December 2022, 8:19 am EST

    Hi,

    These methods are available with just a name of save and open. save method will return the blob of .sjs and open will act as from JSON and accept the file blob or instance of File class.

    Please refer to the following code snippet and let me know if you face any issues.

     spread.open(FileOrBlob, function() {}, function() {}, options);

    regards,

    Avinash

  • Posted 27 December 2022, 3:21 am EST

    Thanks for your fast reply.

    You are right!

    Got it!

    “issue” / “requirement” solved!

    Thanks!

  • Posted 26 January 2023, 1:19 pm EST

    Hi!

    Is there any documentation about this sjs file format?

  • Posted 26 January 2023, 1:19 pm EST

    Hi!

    Is there any documentation about this sjs file format?

  • Posted 26 January 2023, 10:42 pm EST

    Hi Marcio,

    You could refer to the following docs on the SpreadJS File Format: https://www.grapecity.com/spreadjs/docs/features/spreadjs-file-format

    The demo is also available at: https://www.grapecity.com/spreadjs/demos/features/spreadjs-file-format/overview/purejs

    Please refer to the provided links and let us know if you face any problems. We would be delighted to help you.

    Regards,

    Ankit

  • Posted 27 January 2023, 9:20 am EST

    Thank you for the informations

    But is there any way to parse SJS file in backend?

  • Posted 27 January 2023, 9:31 am EST

    @marico.shimoda

    Do not get me wrong

    but your questions are not belonging (anymore) to the topic of this/my post.

    So please create a new to handle your question separately.

    And:

    “parse SJS file in backend”?

    What do you mean?

    Answer:

    Send the sjs object via an POST api call to the server

    fetch and consume / parse it there. :wink:

  • Posted 27 January 2023, 9:45 am EST

  • Posted 6 February 2023, 11:27 pm EST

    Hi Marcio and Uwe,

    Thanks for the suggestions. If you need further assistance or have any other questions, please feel free to ask. I’m here to help.

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels