Compression: true is not working #3134

Open
opened 2024-06-11 21:29:32 +00:00 by virginiam1203 · 0 comments

Hello,

My team has noticed that files exported using XLSX.writeFile with compression: true are twice the size as when we save the same file in Excel with no changes. The exported file in my tests is 7,499 KB and when saved in Excel it goes down to 3,270 KB. I have tested using compression: true and compression: false as well as dense: true and dense: false in the json_to_sheet call. None of these settings appear to make any difference in the exported file size of 7,499 KB.

The test file has 5 columns and about 100,000 rows. I cannot upload it because it contains confidential data.

I have tried both version 19.3 and 20.2 with no success. Version 19.3 did not let me pass dense:true into the json_to_sheet call, though, so I only tested compression: true and compression: false on that version.

I referenced #2974 but it does not list what version shows those results. I cannot reproduce any level of compression.

Are there any known bugs with this functionality? What could be causing compression: true to have no effect? Could it be some other dependency that needs to be updated?

Here is the code we use:

exportExcel = async (): Promise<void> => {
    if (this.selectionCount > 0) {
      // we only need this 1.5MB package if the user clicks the button.
      const XLSX = await import("xlsx");
      const wscols = [
        { width: 17.29 }, // Product Name
        { width: 17.29 }, // Serial Number
        { width: 17.29 }, // Description
        { width: 17.29 }, // Expires
        { width: 17.29 }, // Entitlement
      ];
      this.selectedSystems = this.lcdGrid.agGrid.api.getSelectedRows();
      const ws = XLSX.utils.json_to_sheet(this.formatSystemSelectedData(this.selectedSystems));
      const wb = XLSX.utils.book_new();
      XLSX.utils.book_append_sheet(wb, ws, "Systems");
      ws["!cols"] = wscols;
      XLSX.writeFile(wb, "systems.xlsx", { compression: true });
      this.formatedSpreadsheet = [];
    }
  }
Hello, My team has noticed that files exported using XLSX.writeFile with compression: true are twice the size as when we save the same file in Excel with no changes. The exported file in my tests is 7,499 KB and when saved in Excel it goes down to 3,270 KB. I have tested using compression: true and compression: false as well as dense: true and dense: false in the json_to_sheet call. None of these settings appear to make any difference in the exported file size of 7,499 KB. The test file has 5 columns and about 100,000 rows. I cannot upload it because it contains confidential data. I have tried both version 19.3 and 20.2 with no success. Version 19.3 did not let me pass dense:true into the json_to_sheet call, though, so I only tested compression: true and compression: false on that version. I referenced https://git.sheetjs.com/sheetjs/sheetjs/issues/2974 but it does not list what version shows those results. I cannot reproduce any level of compression. Are there any known bugs with this functionality? What could be causing compression: true to have no effect? Could it be some other dependency that needs to be updated? Here is the code we use: ``` exportExcel = async (): Promise<void> => { if (this.selectionCount > 0) { // we only need this 1.5MB package if the user clicks the button. const XLSX = await import("xlsx"); const wscols = [ { width: 17.29 }, // Product Name { width: 17.29 }, // Serial Number { width: 17.29 }, // Description { width: 17.29 }, // Expires { width: 17.29 }, // Entitlement ]; this.selectedSystems = this.lcdGrid.agGrid.api.getSelectedRows(); const ws = XLSX.utils.json_to_sheet(this.formatSystemSelectedData(this.selectedSystems)); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, "Systems"); ws["!cols"] = wscols; XLSX.writeFile(wb, "systems.xlsx", { compression: true }); this.formatedSpreadsheet = []; } } ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#3134
No description provided.