Export SpreadJs into Excel Document without saving it on file system

Posted by: mirfan on 7 May 2022, 10:25 pm EST

  • Posted 7 May 2022, 10:25 pm EST

    Hi, We are using SpreadJs 13.0.4 and we can export it to Excel and save it using Spread-ExcelIo and "file-saver’. However we need to export SpreadJs and then open an Excel document directly from it. ExcelJs support to open document using “Excel.createWorkbook(https://docs.microsoft.com/en-us/office/dev/add-ins/excel/excel-add-ins-workbooks#create-a-workbook)” which accepts base64 string. So I need help to convert SpreadJs exported blob/json to appropriate string for this operation.

  • Posted 9 May 2022, 3:20 pm EST

    Hi,

    For this, you need to use the excel URI scheme and pass the URI to the template, based on the HTTP or HTTPS scheme. for this, you may need to implement a server that returns the file. Please refer to the following code snippet and attached official doc of URI which explains the same.

    
    //here you ned to to implement the backend http server which return the excel file
    window.open("ms-excel:ofv|u|https://contoso.com/Q4/budget.xls")
    
    

    office URI Scheme: https://docs.microsoft.com/en-us/office/client-developer/office-uri-schemes

    Regards,

    Avinash

  • Posted 9 May 2022, 7:53 pm EST

    Hi Avinash,

    So do you mean, first we need to send exported SpreadJs instance JSON blob to Server and then save it to Server File System folder as Excel and then send that Excel file from Server and open it using this URI Schema?

    Really this is the only solution?

  • Posted 10 May 2022, 7:00 pm EST

    Hi,

    The only solution is to use the excel URI scheme since the web apps do not have access to the native application. We tried directly passing the blob/base64 to the URI scheme but excel only supports the URI to the document, based on the HTTP or HTTPS scheme. So that is why you need to return the excel file from the backed.

    I hope it clarifies the issue.

    Regards,

    Avinash

Need extra support?

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

Learn More

Forum Channels