Error when importing XLSX file

Posted by: achort on 7 April 2025, 2:34 pm EST

    • Post Options:
    • Link

    Posted 7 April 2025, 2:34 pm EST

    Hello,

    I have a problem importing a particular XLSX file (every other XLSX file I have tested is working fine with my setup)

    The problem file is just like any other file, just a long table with data. It doesn’t look to have any particular difference with other files that work.

    The file is valid and I can open and work with it in MS Excel but SpreadJS fails to import it.

    This is how I load the XLSX into the SpreadJS instance:

    spread.import(blob, resolve, reject, { fileType: GC.Spread.Sheets.FileType.xlsx });

    The reject function is called with this:

    {errorCode: 1, errorMessage: 'Incorrect file format.'}

    I have tested with SpreadJS versions 16.1.3 and 18.0.6 and it always fails with this particular file.

    Is there any way to get more information about why it failed? Like the actual error thrown inside the SpreadJS import method?

    Thank you.

  • Posted 8 April 2025, 1:37 am EST - Updated 8 April 2025, 1:43 am EST

    Hi,

    We are unable to replicate the issue you mentioned on our end. However, the issue seems to be specific to the Excel file you are loading into the SpreadJS.

    Additionally, could you please check if changing the file type from GC.Spread.Sheets.FileType.xlsx to GC.Spread.Sheets.FileType.excel in the import statement resolves the issue? The FileType enumeration supports the values csv, excel, and ssjson only.

    In case the issue does not resolve on your end by modifying the file type, please share the Excel file with us for further investigation of the issue.

    You can also try to load the file in the attached sample that loads the input XLSX file without any issues.

    Sample: https://jscodemine.mescius.io/share/NoOsF2jSp0OlWQdh8zxTDQ/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fapp.js"]%2C"ActiveFile"%3A"%2Fapp.js"}

    input.zip

    Regards,

    Ankit

  • Posted 8 April 2025, 3:30 pm EST

    Hello,

    I tried changing this GC.Spread.Sheets.FileType.xlsx to GC.Spread.Sheets.FileType.excel but it did not fix the issue. It fails using your sample app too.

    Also, it appears file size is a factor. It fails with a 500 000 rows (~60MB) but if I make it 400 000 rows it works fine.

    If I pause on exceptions it seems to be failing around this line of code in SpreadJS:

    return t.entry.getData(t.textWriter).then(function(e) {
                            return e || 0 === t.entry.uncompressedSize ? e : Promise.reject()
                        })


    Seems to be executing the latter part of that ternary expression - Promise.reject()

    Sadly, since it is a big file I’m not really able to share it here because of file size limitations in the forum.

    Any hints on why it would fail in that line of code?

    Thank you.

  • Posted 9 April 2025, 4:30 am EST

    Hi,

    The issue you mentioned seems not a limitation of SpreadJS, but rather the limitation of the browser. When attempting to load such a large file in SpreadJS, it fails to load and throws an Incorrect file format error, rejecting the loading of the file in SpreadJS.

    While SpreadJS itself does not impose file size limitations for importing files, its performance depends on browser memory availability. Even a 5MB file might consume significantly more memory once loaded into SpreadJS, as the workbook’s memory usage depends on factors like the number of formulas, data volume, formatting, etc. As a result, crashes or failures can occur based on content rather than file size alone.

    Additionally, we would recommend you load the file with incremental or lazy mode. In “Incremental” mode, the user can perform UI operations while the file is being loaded in the SpreadJS. The file is only loaded when a user does not perform any UI operations. On the other hand, when the file is loaded with “Lazy” mode, only the minimal and necessary data is loaded at first, and other data is loaded in the background and when needed. This makes it faster to load big Excel files.

    We have updated the shared sample to load the Excel file incrementally. Please refer to the sample - https://jscodemine.mescius.io/share/NoOsF2jSp0OlWQdh8zxTDQ/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fapp.js"]%2C"ActiveFile"%3A"%2Fapp.js"}.

    You can also try to open the file in lazy open mode. Please refer to the OpenMode enumeration (https://developer.mescius.com/spreadjs/api/enums/GC.Spread.Sheets.OpenMode#enumeration-openmode) to learn about all the open modes supported in SpreadJS.

    You can share the file by uploading the file to the cloud (eg, Google Drive) and sharing the accessible link with us. In case the file contains confidential data, you can create a new support ticket on our private portal - https://developer.mescius.com/my-account/my-support and upload the file there.

    Please feel free to reach out if you encounter any further issues or require additional guidance.

    Best Regards,

    Ankit

  • Posted 9 April 2025, 1:31 pm EST

    Hello,

    I tried the sample app with incremental and lazy modes and it always fail with the same “Incorrect file format.” error.

    Here is the problematic file, it’s just dummy data so no issue posting it here.

    https://docs.google.com/spreadsheets/d/1FVa82MwjyPyzWWIAowuFzVYqNjc4-iUA/edit?usp=sharing&ouid=100032125769399024809&rtpof=true&sd=true

    Thank you

  • Posted 10 April 2025, 8:02 am EST - Updated 10 April 2025, 8:07 am EST

    Hi,

    Thanks for sharing the Excel file with us.

    The Excel file seems to be too big to be handled by the browser, due to which the browser is unable to load the file. The issue is specific to the browser file size limitation and not because of the SpreadJS File Import feature.

    We have tried to load the file Google Sheets, however it fails on that platform too. Please refer to the following screenshot:

    You can also refer to the similar file size limitation issues in SpreadJS:

    To restrict the issue, we recommend you limit the size of the file blob to be loaded into the SpreadJS. We have updated the sample to limit the file loading exceeding a particular size - ImportXLSX: https://jscodemine.mescius.io/share/NoOsF2jSp0OlWQdh8zxTDQ/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fapp.js"]%2C"ActiveFile"%3A"%2Fapp.js"}.

    Please feel free to reach out if you encounter any further issues or require additional guidance.

    Best Regards,

  • Posted 7 May 2025, 1:30 pm EST

    Hi,

    I don’t think this is a size issue. The number of columns in the file is also a factor.

    Would you mind trying to load the file into SpreadJS yourselves and seeing why it fails?

    I’ve uploaded a zipped version of the file here so you can download it and test it.

    https://drive.google.com/file/d/1G24q3LauK2pNuPFj1_g6HiQ4D8Ks48fh/view?usp=sharing

    Thank you.

  • Posted 8 May 2025, 8:29 am EST - Updated 8 May 2025, 8:34 am EST

    Hi,

    I attempted to load the attached file in both Online Excel and Google Sheets but was unsuccessful due to the file’s large size.

    When trying to load and read the blob’s text using native APIs, nothing is returned for large files. As shown in the attached GIF : , SpreadJS assumes the file is either in an incorrect format or is corrupted when the blob text cannot be read. SpreadJS does not impose a file size limit for importing files, which is why no “File is too big” error is thrown.

    However, while SpreadJS itself doesn’t restrict file size, its performance heavily depends on the browser’s memory availability. A file as small as 5MB could consume much more memory once loaded into SpreadJS, depending on factors such as the number of formulas, data volume, and applied formatting. This means crashes or loading failures can occur due to content complexity rather than just file size.

    It’s also important to note that predicting whether a file will load successfully cannot rely solely on row and column counts. Monitoring memory usage on the current page could help, but native APIs for this purpose are not consistently supported across all browsers and come with strict limitations.

    Please refer to this related forum discussion on pivot table size limitations:

    https://developer.mescius.com/forums/spreadjs/pivot-table-limitation-of-the-pivot-table-size

    References:

    Regards,

    Priyam

Need extra support?

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

Learn More

Forum Channels