Wijmo 5 FlexSheet - Export to JSON format

Posted by: guy.g on 5 August 2018, 11:31 pm EST

    • Post Options:
    • Link

    Posted 5 August 2018, 11:31 pm EST

    Hi, is it possible to export a workbook to a JSON format including cell position (row, column), data and styling?

  • Posted 6 August 2018, 8:22 pm EST

    Hi,

    You may use FlexSheet.save() method, it returns an instance of Workbook type in JSON format.

    You can use save() method without passing any parameter(FileName) which will skip exporting the FlexSheet to excel format and you will get WorkBook in JSON Format.

    You may also refer to the following sample:-

    https://stackblitz.com/edit/js-ebr88e?file=index.js

    Please let us know if you have any further query or different requirement.

    ~Manish

  • Posted 20 August 2018, 9:42 pm EST

    Thank you for your answer.

    I still have a couple more questions:

    1. Do this method of saving persists styling and formatting of the workbook?
    2. Can I use flexSheet.load() method to load from that WorkBook in JSON Format if I save that json to the DB and after I want to load it back to FlexSheet?
  • Posted 21 August 2018, 8:53 pm EST

    Hi,

    1). Yes, workbook persists formatting and styling(applied only using applyCellsStyle() method).

    2). You can load flexsheet by passing an instance of WorkBook but for storing and retrieving the Workbook in DB would require it to stringify/parse the JSON which would make it unusable.

    To save to DB you can use workBook.save() method which will return a base-64 string representation of the WorkBook. Save this string to DB then create and load new workbook using base-64 string and finally load the workbook back to flexsheet.

    Please refer to the following sample which implements the same:-

    https://stackblitz.com/edit/js-rchuym?file=index.js

    ~Sharad

  • Posted 22 August 2018, 3:19 am EST

    Thank you, We were checking out the different methods of saving to DB and indeed it seems like saving in base64 format will be the optimal way of doing so.

Need extra support?

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

Learn More

Forum Channels