Creating spread instance from blob instead of file

Posted by: datta on 22 December 2022, 4:55 am EST

  • Posted 22 December 2022, 4:55 am EST - Updated 22 December 2022, 5:07 am EST

    Hi we store excel files as bytes in our mongodb. I have a working code to construct workbook instance from this byte array using excelIO.open() api. Now with SpreadJS 16 I want to do the same with gc.spread.sheets.io.16.0.0.min.js library. Can you please give me some examples which I can refer. All the examples I found was about creating spread instance from file. I need example which generates spread instance from blob. Below is the current code which uses excelIO and fromJson methood of spread instance

    [code] excelIO.open(blob, function (json) {

            		 spread.fromJSON(json);})[/code]
    
  • Posted 23 December 2022, 7:37 am EST

    Hi,

    Please refer to the following sample which implements the scenario.

    sample: https://codesandbox.io/s/solution-forked-xvwfpu?file=/src/index.js

    regards,

    Avinash

  • Posted 26 December 2022, 11:01 am EST

    Hi Thanks code is working. But styles in the files are not coming up after importing. Below is my code. Please let me know what I am missing here

    spread.import(blob,

    (args)=>{

            		 },()=>{
            			
            		 },{
            			 calcOnDemand: false,
            			 dynamicReferences: true,
            			 frozenColumnsAsRowHeaders:false,
            			 frozenRowsAsColumnHeaders:false,
            			 fullRecalc: false,
            			 includeFormulas: true,
            			 includeStyles: true,
            			 includeUnusedStyles: true
            			 }
            		 
            		 );
    
  • Posted 27 December 2022, 2:55 am EST - Updated 27 December 2022, 3:01 am EST

    Hi,

    I tested at my end and the styles seems to be working fine at my end. Please refer to the following sample that I have used for testing, that makes use of the import options available.

    Sample: https://codesandbox.io/s/solution-forked-sz7u1z?file=/src/index.js

    If the issue still persists for you, we request you to kindly modify the sample and share with us. Also, please mention the steps to follow.

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels