Skip to content

Opening an XLSX with a part over 512 MB says how to get the data in - #1248

Merged
aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/too-large-open-hint
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
marcoarnulfo:fix/too-large-open-hint

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

Fixes #1242.

Thanks @dev-exe for suggesting the error should tell people how to get unblocked. Opening an XLSX where one part unpacks to more than the reader's 512 MB per-part cap (MAX_PART in crates/xlsx/src/package.rs) used to say:

We can't open 'book.xlsx': the file is too large: xl/worksheets/sheet1.xml expands to 540278731 bytes

It now says:

We can't open 'book.xlsx': its part xl/worksheets/sheet1.xml unpacks to 515 MB, over GridCraft's limit of 512 MB for one part (a guard against damaged or malicious files). To open it, split the data across several sheets, since the limit applies to each part, or save the sheet as CSV, which keeps only its values.

The limit itself is unchanged: raising it, or streaming very large sheets, is your call.

I only suggest what the code actually lets through:

  • Splitting across sheets works because the cap is per part (the 1 GB package total still applies).
  • CSV import has no per-part or size cap beyond the 2 GB read_file limit.
  • .xlsb is left out, which corrects my earlier comment: the XLSB import stops at 1 million cells and 64 MiB of text (crates/xlsx/src/xlsb.rs), far less than a 515 MB sheet holds.
  • When the oversized part is not a worksheet (for example xl/sharedStrings.xml, which every sheet shares), splitting sheets doesn't help, so the message only suggests CSV.

gridcraft_xlsx::oversized_part finds the part from the zip directory's declared sizes, and the engine uses it only when read_xlsx returns TooLarge. A part that lies about its size and is caught while inflating keeps the old message.

Validation:

  • io::tests::a_part_over_the_size_limit_says_how_to_get_the_data_in patches the declared size in the central directory, so it needs no 512 MB fixture. It fails on main with the message above and passes here. It also covers the shared-strings case, a size just over the limit (shown as "more than 512 MB", never "512 MB"), and a package broken for another reason, which keeps its own error.
  • cargo test -p gridcraft-engine --lib io::tests, cargo test -p gridcraft-xlsx --lib tests::malformed, cargo clippy -p gridcraft-xlsx -p gridcraft-engine --all-targets -- -D warnings, cargo fmt --all -- --check, cargo check -p gridcraft-engine --target wasm32-unknown-unknown
  • (macOS, Apple silicon)

@iampato2

Copy link
Copy Markdown

Watching this
Screenshot 2026-10-15 at 16 34 57

@aiongg
aiongg merged commit 4ec2de2 into storytold:main Oct 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cant Open Over 50MB

3 participants