0.17.5 to 0.18.2 invalid array length issue during writeFile #2539
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#2539
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
just had the time to test 0.18.2 and in runs into a "Range Error: Invalid array length" issue when doing a "XLSX.writeFile(wb, args.fileName)" on a workbook which perfectly works fine with 0.17.5 (we're talking about one sheet with 25000 rows * 186 columns). Replacing xlsx.full.min.js with the 0.17.5 version and it is running and saving fine. 0.18.2 creates the problem.
Only had a quick look at the minimized code (sorry): The error is happening in xlsx.full.min.js at pos 9:22755 (corresponds to function z(e){var r=new Array(e.length);for(var t=0;t<e.length;++t)r[t]=String.fromCharCode(e[t]);return r.join("")} This is most likely the "a2s" function
....so maybe another unicode issue? Would be great if you can check it. In the meantime I try to do more tests on my side checking which data is actually used there.
Small update: Use xlsx.js and it is indeed the a2s(o) function (line 2124). The o.length is in my crashing case 181579121 but when reaching already i=11184812 and setting out[i] to whatever leads to the invalid array length error. Call stack comes from write, write_zip_denouement, write_zip_type....
Using Win11 with Edge 98.0.1108.62 by the way
The function that actually performs the download mantras is expecting a binary string. That doesn't make sense now that the zip writer builds a
Uint8Array
by default (thewriteFile
path and thearray
/buffer
output types now convert fromUint8Array
to binary string and back). This also applies to Deno, sinceDeno.writeFileSync
only operates onUint8Array
The following patch should work, feel free to submit a PR:
Actually generating the final zip is about twice as fast now in the realm of 25K rows x 200 columns. In local tests we were able to push ~80K rows x 200 columns of numbers and small text strings before hitting the invalid string length issue in the XML generation.