@office-open/xlsx 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -71,36 +71,36 @@ Check the [demo folder](./demo) for working examples covering every feature.
71
71
 
72
72
  Performance comparison against [hucre](https://github.com/nicolo-ribaudo/hucre) (higher ops/s is better, Windows 11 / Node 24).
73
73
 
74
- **Default** = XML DEFLATE level 1 (SuperFast, matching MS Office) + media STORE. **All STORE** = no compression (`{ compression: { xml: 0 } }`). **hucre** (async only) uses `CompressionStream("deflate-raw")` when available, falls back to STORE per-entry when compression doesn't reduce size.
74
+ **Default** = XML DEFLATE level 1 (SuperFast); media is split by type, matching MS Office Excel — already-compressed formats (PNG/JPEG/GIF) are STOREd, the rest (EMF/WMF/BMP/TIFF/…) use DEFLATE level 1 (verified on a real MS Office file). **All STORE** = no compression (`{ compression: { xml: 0, media: 0 } }`). **hucre** (async only) uses `CompressionStream("deflate-raw")` when available, falls back to STORE per-entry when compression doesn't reduce size.
75
75
 
76
76
  ```typescript
77
77
  // Default (matches MS Office)
78
78
  await generateWorkbook(options);
79
79
  // All STORE (no compression)
80
- await generateWorkbook(options, { compression: { xml: 0 } });
80
+ await generateWorkbook(options, { compression: { xml: 0, media: 0 } });
81
81
  ```
82
82
 
83
83
  **Create + toBuffer (end-to-end)**
84
84
 
85
85
  | Scenario | Default sync | Default async | All STORE sync | All STORE async | hucre |
86
86
  | ---------------- | -----------: | ------------: | -------------: | --------------: | ----------: |
87
- | Simple (3 rows) | 2,385 ops/s | 1,142 ops/s | 14,583 ops/s | 15,943 ops/s | 951 ops/s |
88
- | Styled rows (20) | 2,355 ops/s | 1,195 ops/s | 16,765 ops/s | 12,852 ops/s | 1,083 ops/s |
89
- | Table (10x5) | 2,357 ops/s | 1,177 ops/s | 16,480 ops/s | 13,716 ops/s | 1,049 ops/s |
87
+ | Simple (3 rows) | 2,416 ops/s | 1,160 ops/s | 14,593 ops/s | 17,853 ops/s | 1,062 ops/s |
88
+ | Styled rows (20) | 2,446 ops/s | 1,128 ops/s | 15,780 ops/s | 15,544 ops/s | 1,075 ops/s |
89
+ | Table (10x5) | 2,361 ops/s | 1,195 ops/s | 16,784 ops/s | 16,723 ops/s | 907 ops/s |
90
90
 
91
91
  **Large Files — Create + toBuffer**
92
92
 
93
93
  | Scenario | Default sync | Default async | All STORE sync | All STORE async | hucre |
94
94
  | ----------------------------- | -----------: | ------------: | -------------: | --------------: | --------: |
95
- | 2000 rows + 10 images | 79 ops/s | 75 ops/s | 89 ops/s | 93 ops/s | 44 ops/s |
96
- | 200x10 table | 847 ops/s | 610 ops/s | 1,118 ops/s | 1,011 ops/s | 261 ops/s |
97
- | 20 sheets × 100 rows + 20 img | 49 ops/s | 39 ops/s | 60 ops/s | 62 ops/s | 26 ops/s |
95
+ | 2000 rows + 10 images | 110 ops/s | 92 ops/s | 86 ops/s | 91 ops/s | 44 ops/s |
96
+ | 200x10 table | 853 ops/s | 614 ops/s | 1,142 ops/s | 1,122 ops/s | 258 ops/s |
97
+ | 20 sheets × 100 rows + 20 img | 72 ops/s | 50 ops/s | 63 ops/s | 62 ops/s | 25 ops/s |
98
98
 
99
99
  **Large Data — 100,000 rows × 20 columns (2M cells)**
100
100
 
101
101
  | Scenario | Default sync | Default async | All STORE sync | All STORE async | hucre |
102
102
  | --------- | -----------: | ------------: | -------------: | --------------: | ---------: |
103
- | 100k × 20 | 0.84 ops/s | 0.83 ops/s | 0.90 ops/s | 0.94 ops/s | 0.39 ops/s |
103
+ | 100k × 20 | 0.87 ops/s | 0.81 ops/s | 1.02 ops/s | 0.96 ops/s | 0.39 ops/s |
104
104
 
105
105
  ## License
106
106
 
@@ -642,10 +642,10 @@ const stylesDesc = {
642
642
  const fillId = attrNum(xf, "fillId");
643
643
  const borderId = attrNum(xf, "borderId");
644
644
  const numFmtId = attrNum(xf, "numFmtId");
645
- if (fontId !== void 0) style.fontIdx = fontId;
646
- if (fillId !== void 0) style.fillIdx = fillId;
647
- if (borderId !== void 0) style.borderIdx = borderId;
648
- if (numFmtId !== void 0) style.numFmtIdx = numFmtId;
645
+ if (fontId !== void 0) style.fontId = fontId;
646
+ if (fillId !== void 0) style.fillId = fillId;
647
+ if (borderId !== void 0) style.borderId = borderId;
648
+ if (numFmtId !== void 0) style.numFmtId = numFmtId;
649
649
  xfs.push(style);
650
650
  }
651
651
  result.cellStyleXfs = xfs;
@@ -664,10 +664,10 @@ const stylesDesc = {
664
664
  const protectionEl = findChild(xf, "protection");
665
665
  const protection = protectionEl ? parseProtection(protectionEl) : void 0;
666
666
  const style = {};
667
- if (fontId > 0) style.fontIdx = fontId;
668
- if (fillId > 0) style.fillIdx = fillId;
669
- if (borderId > 0) style.borderIdx = borderId;
670
- if (numFmtId > 0) style.numFmtIdx = numFmtId;
667
+ if (fontId > 0) style.fontId = fontId;
668
+ if (fillId > 0) style.fillId = fillId;
669
+ if (borderId > 0) style.borderId = borderId;
670
+ if (numFmtId > 0) style.numFmtId = numFmtId;
671
671
  if (alignment) style.alignment = alignment;
672
672
  if (protection) style.protection = protection;
673
673
  if (attr(xf, "quotePrefix") === "1") style.quotePrefix = true;
@@ -5081,23 +5081,19 @@ var XlsxReadContext = class {
5081
5081
  resolveStyle(styleIndex) {
5082
5082
  const ps = this.parsedStyles;
5083
5083
  if (!ps) return void 0;
5084
- const cellXfs = ps.cellXfs;
5084
+ const { cellXfs, fonts, fills, borders, customNumFmts } = ps;
5085
5085
  if (!cellXfs || styleIndex >= cellXfs.length) return void 0;
5086
5086
  const xf = cellXfs[styleIndex];
5087
5087
  const result = {};
5088
- const fonts = ps.fonts;
5089
- const fills = ps.fills;
5090
- const borders = ps.borders;
5091
- const customNumFmts = ps.customNumFmts;
5092
- const fontIdx = xf.fontIdx;
5093
- if (fontIdx !== void 0 && fonts && fontIdx < fonts.length) result.font = fonts[fontIdx];
5094
- const fillIdx = xf.fillIdx;
5095
- if (fillIdx !== void 0 && fills && fillIdx < fills.length) result.fill = fills[fillIdx];
5096
- const borderIdx = xf.borderIdx;
5097
- if (borderIdx !== void 0 && borders && borderIdx < borders.length) result.border = borders[borderIdx];
5098
- const numFmtIdx = xf.numFmtIdx;
5099
- if (numFmtIdx !== void 0 && customNumFmts) {
5100
- for (const [code, id] of Object.entries(customNumFmts)) if (id === numFmtIdx) {
5088
+ const fontId = xf.fontId;
5089
+ if (fontId !== void 0 && fonts && fontId < fonts.length) result.font = fonts[fontId];
5090
+ const fillId = xf.fillId;
5091
+ if (fillId !== void 0 && fills && fillId < fills.length) result.fill = fills[fillId];
5092
+ const borderId = xf.borderId;
5093
+ if (borderId !== void 0 && borders && borderId < borders.length) result.border = borders[borderId];
5094
+ const numFmtId = xf.numFmtId;
5095
+ if (numFmtId !== void 0 && customNumFmts) {
5096
+ for (const [code, id] of Object.entries(customNumFmts)) if (id === numFmtId) {
5101
5097
  result.numFmt = code;
5102
5098
  break;
5103
5099
  }
@@ -5127,4 +5123,4 @@ function resolveWsTarget(wsPath, target) {
5127
5123
  //#endregion
5128
5124
  export { Styles as C, sharedStringsDesc as E, worksheetDesc as S, SharedStrings as T, commentsDesc as _, workbookDesc as a, calcChainDesc as b, tableDesc as c, pivotTableDesc as d, PivotFilterType as f, drawingDesc as g, externalLinkDesc as h, buildTablePartsXml as i, pivotCacheDefDesc as l, collectUniqueValues as m, XlsxWriteContext as n, TableType as o, aggregate as p, buildExternalReferencesXml as r, TotalsRowFunction as s, XlsxReadContext as t, pivotCacheRecordsDesc as u, vmlNotesDesc as v, stylesDesc as w, stringifyWorksheet as x, chartsheetDesc as y };
5129
5125
 
5130
- //# sourceMappingURL=context-D-5KiTi9.mjs.map
5126
+ //# sourceMappingURL=context-D6f14vKV.mjs.map