@office-kit/xlsx 0.14.0 → 0.16.0
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 +43 -7
- package/dist/{cell-style-BFmJOmcx.mjs → cell-style-CNsET6WU.mjs} +2 -2
- package/dist/{cell-style-BFmJOmcx.mjs.map → cell-style-CNsET6WU.mjs.map} +1 -1
- package/dist/{differential-H9SjEeIU.mjs → differential-BPKa7wXi.mjs} +2 -2
- package/dist/{differential-H9SjEeIU.mjs.map → differential-BPKa7wXi.mjs.map} +1 -1
- package/dist/io.mjs +2 -2
- package/dist/{iterparse-zWV-5vc6.mjs → iterparse-DZE0zy2M.mjs} +39 -16
- package/dist/{iterparse-zWV-5vc6.mjs.map → iterparse-DZE0zy2M.mjs.map} +1 -1
- package/dist/{load-B16H5A3S.mjs → load-B1sK-LjT.mjs} +4 -4
- package/dist/{load-B16H5A3S.mjs.map → load-B1sK-LjT.mjs.map} +1 -1
- package/dist/node.mjs +1 -1
- package/dist/{save-I6GjvO1k.mjs → save-DmdWwxmw.mjs} +3 -3
- package/dist/{save-I6GjvO1k.mjs.map → save-DmdWwxmw.mjs.map} +1 -1
- package/dist/streaming/string-table.d.ts +7 -0
- package/dist/streaming.mjs +92 -21
- package/dist/streaming.mjs.map +1 -1
- package/dist/styles.mjs +3 -3
- package/dist/{stylesheet-writer-BCS6PzWU.mjs → stylesheet-writer-oXSuGnJy.mjs} +23 -11
- package/dist/stylesheet-writer-oXSuGnJy.mjs.map +1 -0
- package/dist/{table-Ccro4rrz.mjs → table-BrP0RwUd.mjs} +2 -2
- package/dist/{table-Ccro4rrz.mjs.map → table-BrP0RwUd.mjs.map} +1 -1
- package/dist/workbook/shared-strings.d.ts +2 -0
- package/dist/{workbook-B15-T4cs.mjs → workbook-DOTFzCpz.mjs} +9 -8
- package/dist/workbook-DOTFzCpz.mjs.map +1 -0
- package/dist/workbook.mjs +1 -1
- package/dist/worksheet/index.d.ts +1 -1
- package/dist/worksheet/ref-batch.d.ts +15 -0
- package/dist/worksheet/worksheet.d.ts +33 -0
- package/dist/worksheet/writer.d.ts +9 -5
- package/dist/{worksheet-4xW-i8j9.mjs → worksheet-B2NOQ6dM.mjs} +100 -2
- package/dist/worksheet-B2NOQ6dM.mjs.map +1 -0
- package/dist/worksheet.mjs +3 -3
- package/dist/xml.mjs +1 -1
- package/package.json +1 -1
- package/dist/stylesheet-writer-BCS6PzWU.mjs.map +0 -1
- package/dist/workbook-B15-T4cs.mjs.map +0 -1
- package/dist/worksheet-4xW-i8j9.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ paywall.
|
|
|
36
36
|
|------------------------|----------------------------------------------------------------------------------|-----------------------------------------------------------------------|
|
|
37
37
|
| TypeScript types | hand-written `.d.ts` retrofitted (SheetJS) or community typings (xlsx-populate, excel4node) | first-party, written in TS under `exactOptionalPropertyTypes` + `noUncheckedIndexedAccess` |
|
|
38
38
|
| Bundle size | ExcelJS unpacks to 21.8 MB; xlsx ~7.5 MB | full lib ≤120 KB min+brotli (currently ~85 KB); streaming entry ~49 KB |
|
|
39
|
-
| Streaming | SheetJS docs explicitly note the zip central-directory layout prevents true streaming; ExcelJS supports both directions but the lib is heavy | both read iter and write append, with
|
|
39
|
+
| Streaming | SheetJS docs explicitly note the zip central-directory layout prevents true streaming; ExcelJS supports both directions but the lib is heavy | both read iter and write append, with bounded row buffering and string retention |
|
|
40
40
|
| Charts (write) | none in ExcelJS, xlsx-js-style, SheetJS CE; gated behind SheetJS Pro | 16 legacy `c:` + 8 modern `cx:` chart kinds (Sunburst, Treemap, Waterfall, Histogram, Pareto, Funnel, BoxWhisker, RegionMap) |
|
|
41
41
|
| Pivots / VBA / OLE | ExcelJS drops pivot tables on read ([#261][exceljs-pivot]); others vary | byte-identical passthrough so Excel 365 still renders parts we don't model |
|
|
42
42
|
| Maintenance | ExcelJS stalled since 2023; excel4node archived 2022; xlsx-js-style frozen 2022; SheetJS npm artifact frozen 2022 (still distributed via private CDN) | active |
|
|
@@ -201,7 +201,33 @@ const response = await fetch('/sheet.xlsx');
|
|
|
201
201
|
const wb = await loadWorkbook(fromResponse(response));
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
-
###
|
|
204
|
+
### Add hyperlinks and comments in bulk
|
|
205
|
+
|
|
206
|
+
Use `setHyperlinks` and `setComments` when many cells need links or notes. Each
|
|
207
|
+
batch runs in linear time over the existing entries and additions.
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
import { createWorkbook, addWorksheet } from '@office-kit/xlsx/workbook';
|
|
211
|
+
import { setHyperlinks, setComments } from '@office-kit/xlsx/worksheet';
|
|
212
|
+
|
|
213
|
+
const wb = createWorkbook();
|
|
214
|
+
const ws = addWorksheet(wb, 'Report');
|
|
215
|
+
setHyperlinks(ws, [
|
|
216
|
+
{ ref: 'A2', target: 'https://example.com/items/1' },
|
|
217
|
+
{ ref: 'A3', target: 'https://example.com/items/2' },
|
|
218
|
+
]);
|
|
219
|
+
setComments(ws, [
|
|
220
|
+
{ ref: 'A2', author: 'Reviewer', text: 'Verified' },
|
|
221
|
+
{ ref: 'A3', author: 'Reviewer', text: 'Check the source' },
|
|
222
|
+
]);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Entries are applied in order: replacing a hyperlink moves it to the end;
|
|
226
|
+
replacing a comment keeps its position. Hyperlink entries must supply `target`
|
|
227
|
+
or `location`; the entire batch is validated before the sheet is changed.
|
|
228
|
+
Both APIs preserve the public arrays and allow direct edits between calls.
|
|
229
|
+
|
|
230
|
+
### Streaming write — bounded row buffering and string retention
|
|
205
231
|
|
|
206
232
|
```ts
|
|
207
233
|
import { createWriteOnlyWorkbook } from '@office-kit/xlsx/streaming';
|
|
@@ -211,7 +237,7 @@ const sink = toFile('big.xlsx');
|
|
|
211
237
|
const wb = await createWriteOnlyWorkbook(sink);
|
|
212
238
|
const ws = await wb.addWorksheet('Data');
|
|
213
239
|
ws.setColumnWidth(1, 24); // must precede the first appendRow
|
|
214
|
-
for (let r = 0; r <
|
|
240
|
+
for (let r = 0; r < 1_000_000; r++) {
|
|
215
241
|
await ws.appendRow([r, `row-${r}`, r * Math.PI]);
|
|
216
242
|
}
|
|
217
243
|
await ws.close();
|
|
@@ -220,10 +246,20 @@ await wb.finalize();
|
|
|
220
246
|
|
|
221
247
|
The streaming writer pushes each row through deflate as it arrives, and
|
|
222
248
|
`toFile` forwards each deflated chunk to disk (honouring write-stream
|
|
223
|
-
backpressure)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
249
|
+
backpressure). Row buffering stays at approximately 64 KiB plus the current
|
|
250
|
+
row and deflate scratch. Plain and rich-text strings share a workbook-wide
|
|
251
|
+
table capped at 100,000 entries and an 8 MiB accounting budget for retained
|
|
252
|
+
keys and serialized XML (two bytes per UTF-16 code unit). This is a payload
|
|
253
|
+
budget, not a total JavaScript heap limit. Once a new value cannot fit, all
|
|
254
|
+
subsequent new values are written as inline strings; previously registered
|
|
255
|
+
values still reuse their shared-string IDs, including on later sheets.
|
|
256
|
+
|
|
257
|
+
Styles and sheet metadata remain resident, so keep their counts bounded when
|
|
258
|
+
exporting large datasets. `toWritable` also streams output; buffered sinks
|
|
259
|
+
(`toBuffer` / `toBlob` / `toArrayBuffer`) keep the full archive resident for
|
|
260
|
+
`result()`. Excel allows at most 1,048,576 rows per sheet; split larger datasets
|
|
261
|
+
across sheets. See [write-only string storage](docs/write-only-strings.md) for
|
|
262
|
+
the storage policy and compatibility details.
|
|
227
263
|
|
|
228
264
|
### Streaming read — iterate row-by-row without materialising the sheet
|
|
229
265
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as OpenXmlSchemaError } from "./exceptions-D-CFwxgm.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Dn as makeColor, bn as colorToHex, un as parseRange, y as ensureCell } from "./worksheet-B2NOQ6dM.mjs";
|
|
3
3
|
//#region src/utils/stable-stringify.ts
|
|
4
4
|
const sortKeysReplacer = (_key, value) => {
|
|
5
5
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
|
|
@@ -1615,4 +1615,4 @@ function setRangeBorderBox(wb, ws, range, opts = { style: "thin" }) {
|
|
|
1615
1615
|
//#endregion
|
|
1616
1616
|
export { BUILTIN_NAMED_STYLES as $, makeAlignment as $t, setCellBorder as A, isBuiltinFormat as At, setItalic as B, PATTERN_TYPES as Bt, setBold as C, FORMAT_NUMBER_00 as Ct, setCellAsNumber as D, builtinFormatCode as Dt, setCellAsDate as E, FORMAT_TEXT as Et, setCellProtection as F, FONT_SCHEMES as Ft, setRangeNumberFormat as G, makePatternFill as Gt, setRangeBackgroundColor as H, makeFill as Ht, setCellStyle as I, UNDERLINE_STYLES as It, setRangeWrapText as J, makeBorder as Jt, setRangeProtection as K, SIDE_STYLES as Kt, setFontColor as L, VERT_ALIGNS as Lt, setCellFill as M, isTimedeltaFormat as Mt, setCellFont as N, makeNumberFormat as Nt, setCellAsPercent as O, builtinFormatId as Ot, setCellNumberFormat as P, DEFAULT_FONT as Pt, makeProtection as Q, alignmentToCss as Qt, setFontName as R, fontToCss as Rt, rotateCellText as S, FORMAT_NUMBER as St, setCellAsCurrency as T, FORMAT_PERCENTAGE_00 as Tt, setRangeBorderBox as U, makeGradientFill as Ut, setRangeAlignment as V, fillToCss as Vt, setRangeFont as W, makeGradientStop as Wt, setUnderline as X, HORIZONTAL_ALIGNMENTS as Xt, setStrikethrough as Y, makeSide as Yt, wrapCellText as Z, VERTICAL_ALIGNMENTS as Zt, getCellNumberFormat as _, BUILTIN_FORMATS_MAX_SIZE as _t, cellStyleToCss as a, addFill as at, patchCellFont as b, FORMAT_DATE_YYYYMMDD2 as bt, clearCellStyle as c, buildXfPatch as ct, copyCellStyle as d, listCellStyleXfs as dt, stableStringify as en, addNamedStyle as et, formatAsHeader as f, listCellXfs as ft, getCellFont as g, BUILTIN_FORMATS as gt, getCellFill as h, makeStylesheet as ht, applyNamedStyle as i, addCellXf as it, setCellBorderAll as j, isDateFormat as jt, setCellBackgroundColor as k, classifyDateFormat as kt, clearRangeStyle as l, defaultCellXf as lt, getCellBorder as m, listFonts as mt, alignCellVertical as n, addBorder as nt, centerCell as o, addFont as ot, getCellAlignment as p, listFills as pt, setRangeStyle as q, borderToCss as qt, applyBuiltinStyle as r, addCellStyleXf as rt, clearCellBackground as s, addNumFmt as st, alignCellHorizontal as t, ensureBuiltinStyle as tt, cloneCellStyle as u, listBorders as ut, getCellProtection as v, FORMAT_DATE_DATETIME as vt, setCellAlignment as w, FORMAT_PERCENTAGE as wt, registerCellStyle as x, FORMAT_GENERAL as xt, indentCell as y, FORMAT_DATE_TIMEDELTA as yt, setFontSize as z, makeFont as zt };
|
|
1617
1617
|
|
|
1618
|
-
//# sourceMappingURL=cell-style-
|
|
1618
|
+
//# sourceMappingURL=cell-style-CNsET6WU.mjs.map
|