Can't "open" a file with ExcelIO when using Designer

Posted by: tyler on 15 August 2024, 3:21 pm EST

  • Posted 15 August 2024, 3:21 pm EST

    I am using ExcelIO.open to load a remote excel file (created from a blob from a fetch request). This works fine with the Spreadsheets, and Worksheet components from @mescius/spread-sheets-react, but the same code fails when I use it with Designer from @mescius/spread-sheets-designer-react

    I keep getting “Incorrect File Format” as the error message back, but the file type is the same in both instances: “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”

  • Posted 16 August 2024, 2:38 am EST - Updated 16 August 2024, 2:43 am EST

    Hi,

    The recommended method for importing .xlsx files is to use the new IO module.

    The IO module, which includes “workbook.import()”, “workbook.export()”, “workbook.save()”, and “workbook.open()” APIs, was introduced in SpreadJS V16 and differs from the older ExcelIO module. The IO module improves performance by allowing Excel files to be imported directly without converting them to JSON before loading them into SpreadJS, as the ExcelIO module does. Additionally, the IO module supports the SJS file format, a SpreadJS-specific format that is essentially a zipped folder, reducing file size and improving loading performance.

    Please refer to the following sample that demonstrates how to load an Excel file from a server. This sample is based on the blog post: https://developer.mescius.com/blogs/how-to-read-excel-xlsx-files-from-a-url-using-javascript

    To run the attached sample, ensure that the following Chrome extension is enabled to avoid “CORS” errors: https://chromewebstore.google.com/detail/moesif-origincors-changer/digfbfaphojjndkpccljibejjbppifbc?hl=en-US

    I have tested both the IO and ExcelIO modules and did not encounter any issues. Refer to the attached gif “Steps.gif” and sample “Sample.zip”. If you are using an older version, I suggest updating to the latest version and trying the IO module’s import method.

    Gif:

    Sample: Sample.zip

    If you still experience issues, please share a sample along with the steps to replicate the behavior, or modify the existing sample to demonstrate the problem. This will help me investigate the issue more thoroughly. Additionally, it would be helpful if you could provide a GIF or video illustrating the issue.

    Regards,

    Priyam

Need extra support?

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

Learn More

Forum Channels