sheetjs icon indicating copy to clipboard operation
sheetjs copied to clipboard

Getting Bad uncompressed size on XLSX.read

Open alonir opened this issue 3 years ago • 1 comments

Hi,

i am getting the below errors when doing the read on arraybuffer. it is able to read the data i didn't get what it failed to read
What does this error mean? how can i avoid it?

sheetjs.js:3 Bad uncompressed size: 586 != 0 Bad uncompressed size: 183 != 0 .....

Thanks Nir

alonir avatar Jul 17 '22 08:07 alonir

XLSX, XLSB, ODS and NUMBERS files are ultimately ZIP containers. You are seeing a ZIP file error.

The version of APPNOTE.TXT that is aligned with XLSX is 6.2.0: https://pkware.cachefly.net/webdocs/APPNOTE/APPNOTE_6.2.0.txt

Those messages (errors if you set WTF: true) are likely stemming from incorrect local file flags:

For each file in the ZIP, the file entry header has a 4-byte space for uncompressed size. To support streaming writers, one of the bits in the header bit flags signals that the uncompressed size is stored after the file data and that the uncompressed size in the header should be ignored.

Without seeing the actual file, we'd speculate that the file is marked with zero size in the header and did not set the appropriate flags. The library sees that the flag was not set and trusts the header size of 0.

We'd probably accept a PR to suppress the message if the file reports a zero size. The check is in https://github.com/SheetJS/sheetjs/blob/master/bits/18_cfb.js#L1457 .

SheetJSDev avatar Jul 17 '22 17:07 SheetJSDev

If you can share a file (some writer is generating bad files) we can revisit this idea.

SheetJSDev avatar Aug 30 '22 17:08 SheetJSDev