Created XLSX compression #220
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#220
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?
Hello!
I might be missing some functionality here, but I can't enable the compression on the files...
I'm using the node version of this library (https://www.npmjs.com/package/xlsx) to convert some server side data to XLSX, and serve it as downloadable file (without saving the file itself on the server side). The code I'm using:
(the callback function is a HAPI reply function)
This code works fine, the xlsx is available for download, and the data is correct.
The problem is that the file size is too big...
F.E a downloaded file is 1,3 MB.
I open that file in Excel, modify a small detail (f.e. modify a number), and the file size becomes 153 KB.
I have reproduced this with LibreOffice, and with the writeFile function as well.
What am I missing?
Thx in advance
I could guess it's concerned with Shared String Table (ISO/IEC 29500-1 specification, p.18.4). In than case devs just should implement that mechanism in js-xlsx.
Tried it with and without SST (bookSST true/false), no change
(also with xlsx, xlsb and xlsm mode - neither was good)
@SzaboAdamImre @Siri0n the zip library is not compressing (it is storing the files as plaintext rather than using the DEFLATE algorithm). That option needs to be made available to the write functions
@SheetJSDev
So it is not available in the current version?
@SzaboAdamImre Did you ever figure out how to compress your file? I am running into the same exact problem. Thanks.
@SzaboAdamImre @Siri0n @SheetJSDev
I created a pull request which will give us the ability to add a compression option.
Example usage:
XLSX.writeFile(wb, 'out.xlsx', {compression: 'DEFLATE'});
If you don't want to wait for the next version commit then just edit your xlsx.js file and replace the write_zip_type function with the updated one:
@bchr02 So many thanks, this is great!
Hi All,
I am facing the same issue. The final file size is enormous. But on opening and saving the file again without any changes reduces it to normal size.
Please let me know whether this issue is fixed?
@gtskaushik it's not enabled by default, you have to pass the
compression:true
option to the write function:@reviewher Thanks for the immediate reply. I'm already using this library with compression option. But still the size is 30 MB. But when I open the file in Microsoft Excel and save it again , it becomes 6 MB
@gtskaushik can you share the code that generated the file?
var wb = new Workbook()
var ws = {};
var range = {s: {c:0, r:0}, e: {c:0, r:0 }};
for(var R = 0; R !== data.length; ++R) {
for(var C = 0; C !== data[R].length; ++C) {
if(range.s.r > R) range.s.r = R;
if(range.s.c > C) range.s.c = C;
if(range.e.r < R) range.e.r = R;
if(range.e.c < C) range.e.c = C;
var cell = {v: data[R][C], s: {} };
if(cell.v === null) continue;
var cell_ref = XLSX.utils.encode_cell({c:C,r:R});
@gtskaushik hello, got the same problem, did you fix this issue? many thanks:)
Same Problem Here.File Size is large on download but on resaving, the size of the file reduces.Please share the solution for this if anyone has come up with one