javascript-excel 2.0.0-alpha.2 → 2.0.0-alpha.3
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 +151 -21
- package/dist/address-DUn7-5OS.js +75 -0
- package/dist/address-DZBHchLv.cjs +122 -0
- package/dist/{auto-width-2oBzjeNG.d.cts → auto-width-DRHsPKNk.d.cts} +1 -1
- package/dist/cells-CPXU722t.cjs +33 -0
- package/dist/cells-CrMF8h_t.js +28 -0
- package/dist/colors-B8Nf_xTx.js +114 -0
- package/dist/colors-oBpjx97l.cjs +119 -0
- package/dist/csv.d.cts +4 -1
- package/dist/csv.d.ts +4 -1
- package/dist/dataset-KeMzHCGl.js +664 -0
- package/dist/dataset-UUZCzsi3.cjs +687 -0
- package/dist/dates-BXcSWf9_.js +64 -0
- package/dist/dates-CA1dCizp.cjs +75 -0
- package/dist/dom.cjs +5 -2
- package/dist/dom.d.cts +5 -2
- package/dist/dom.d.ts +4 -1
- package/dist/dom.js +4 -1
- package/dist/{numfmt-Dv6AjopS.cjs → dos-time-FZ7-1tot.cjs} +0 -199
- package/dist/{numfmt-BBgB7iQA.js → dos-time-dD0z1YWU.js} +2 -177
- package/dist/format.cjs +1264 -0
- package/dist/format.d.cts +59 -0
- package/dist/format.d.ts +59 -0
- package/dist/format.js +1262 -0
- package/dist/import.cjs +10 -0
- package/dist/import.d.cts +10 -0
- package/dist/import.d.ts +10 -0
- package/dist/import.js +1 -0
- package/dist/index.cjs +24 -607
- package/dist/index.d.cts +32 -6
- package/dist/index.d.ts +31 -5
- package/dist/index.js +10 -594
- package/dist/{warnings-C_12PT4t.d.cts → model-0JikLfuM.d.cts} +1 -41
- package/dist/{warnings-DXJKe1lx.d.ts → model-0JikLfuM.d.ts} +1 -41
- package/dist/numfmt-BmEbm78Y.cjs +125 -0
- package/dist/numfmt-DCDrX9P1.js +114 -0
- package/dist/pipeline-BAJtzBdW.js +1085 -0
- package/dist/pipeline-Bnf7EU3X.cjs +1132 -0
- package/dist/pipeline-CctEa86r.d.cts +186 -0
- package/dist/pipeline-I8SLmV9S.d.ts +186 -0
- package/dist/{read-Ym1voUct.cjs → read-CZEWV4rK.cjs} +181 -17
- package/dist/{read-DDN5ZsPe.js → read-LWti17lz.js} +169 -5
- package/dist/read.cjs +1 -1
- package/dist/read.d.cts +78 -4
- package/dist/read.d.ts +78 -4
- package/dist/read.js +1 -1
- package/dist/render.cjs +751 -0
- package/dist/render.d.cts +215 -0
- package/dist/render.d.ts +215 -0
- package/dist/render.js +732 -0
- package/dist/{sheet-names-uT2EH5Ui.js → sheet-names-7p-joVsG.js} +2 -101
- package/dist/{sheet-names-qpXsvMpM.cjs → sheet-names-B8U5RAW0.cjs} +14 -167
- package/dist/warnings-B1v58nCZ.d.cts +41 -0
- package/dist/warnings-B1v58nCZ.d.ts +41 -0
- package/dist/worker.cjs +10 -2
- package/dist/worker.d.cts +10 -4
- package/dist/worker.d.ts +10 -4
- package/dist/worker.js +10 -2
- package/dist/{write-CYpLGuzl.d.ts → write-DM6ieuQY.d.ts} +2 -1
- package/dist/{write-DubvcG-x.js → write-DjgWy1PK.js} +5 -2
- package/dist/{write-C5JgeIar.d.cts → write-DtjfdIFm.d.cts} +2 -1
- package/dist/{write-BOh9jfu1.cjs → write-f9kcYf5K.cjs} +31 -28
- package/package.json +32 -1
- package/dist/read-C6L7Nyy3.d.cts +0 -78
- package/dist/read-Ddkks7qC.d.ts +0 -78
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { n as parseIsoDate, r as toBytes } from "./infer-BR-J9BZa.js";
|
|
2
2
|
import { a as LimitError, i as FormatError } from "./errors-CvGlfw0E.js";
|
|
3
|
-
import { a as
|
|
3
|
+
import { a as decodeUtf8Strict, i as nativeCodec, l as concatBytes, r as crc32, s as throttleProgress, t as fromDosDateTime, u as throwIfAborted$1 } from "./dos-time-dD0z1YWU.js";
|
|
4
|
+
import { n as isDateFormat } from "./numfmt-DCDrX9P1.js";
|
|
5
|
+
import { n as serialToDate } from "./dates-BXcSWf9_.js";
|
|
4
6
|
// src/internal/read/limits.ts
|
|
5
7
|
/** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
|
|
6
8
|
const DEFAULT_LIMITS = Object.freeze({
|
|
@@ -378,12 +380,24 @@ var XmlTokenizer = class {
|
|
|
378
380
|
maxDepth;
|
|
379
381
|
buf = "";
|
|
380
382
|
stack = [];
|
|
383
|
+
/** While skipping: the end tag being searched for ("</qname"), and the depth to keep. */
|
|
384
|
+
skipTag;
|
|
385
|
+
skipDepth = 0;
|
|
381
386
|
rootSeen = false;
|
|
382
387
|
rootClosed = false;
|
|
383
388
|
pendingCR = false;
|
|
384
389
|
constructor(handler, maxDepth) {
|
|
385
390
|
this.handler = handler;
|
|
386
391
|
this.maxDepth = maxDepth;
|
|
392
|
+
handler.attach?.(this);
|
|
393
|
+
}
|
|
394
|
+
depth() {
|
|
395
|
+
return this.stack.length;
|
|
396
|
+
}
|
|
397
|
+
skipToEndOf(depth) {
|
|
398
|
+
if (depth < 1 || depth > this.stack.length) throw new RangeError(`skipToEndOf: no open element at depth ${depth}`);
|
|
399
|
+
this.skipTag = `</${this.stack[depth - 1]}`;
|
|
400
|
+
this.skipDepth = depth;
|
|
387
401
|
}
|
|
388
402
|
feed(chunk) {
|
|
389
403
|
this.buf = this.buf.length === 0 ? chunk : this.buf + chunk;
|
|
@@ -400,6 +414,20 @@ var XmlTokenizer = class {
|
|
|
400
414
|
const len = buf.length;
|
|
401
415
|
let i = 0;
|
|
402
416
|
while (i < len) {
|
|
417
|
+
if (this.skipTag !== void 0) {
|
|
418
|
+
const tag = this.skipTag;
|
|
419
|
+
let at = buf.indexOf(tag, i);
|
|
420
|
+
while (at !== -1 && at + tag.length < len && !isNameEnd(buf.charCodeAt(at + tag.length))) at = buf.indexOf(tag, at + 1);
|
|
421
|
+
if (at === -1 || at + tag.length >= len) {
|
|
422
|
+
if (final) throw malformed(`Element <${tag.slice(2)}> is not closed.`);
|
|
423
|
+
i = Math.max(i, len - tag.length);
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
this.stack.length = this.skipDepth;
|
|
427
|
+
this.skipTag = void 0;
|
|
428
|
+
i = at;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
403
431
|
if (buf.charCodeAt(i) !== 60) {
|
|
404
432
|
let j = buf.indexOf("<", i);
|
|
405
433
|
if (j === -1) {
|
|
@@ -534,6 +562,9 @@ var XmlTokenizer = class {
|
|
|
534
562
|
this.handler.open(localName(qname), attrs, selfClosing);
|
|
535
563
|
}
|
|
536
564
|
};
|
|
565
|
+
function isNameEnd(c) {
|
|
566
|
+
return c === 62 || isSpace(c);
|
|
567
|
+
}
|
|
537
568
|
function isSpace(c) {
|
|
538
569
|
return c === 32 || c === 9 || c === 10 || c === 13;
|
|
539
570
|
}
|
|
@@ -1592,14 +1623,37 @@ var StringItem = class {
|
|
|
1592
1623
|
var SharedStringsParser = class {
|
|
1593
1624
|
mode;
|
|
1594
1625
|
max;
|
|
1626
|
+
stopAfter;
|
|
1595
1627
|
strings = [];
|
|
1596
1628
|
item;
|
|
1597
1629
|
depth = 0;
|
|
1598
|
-
|
|
1630
|
+
control;
|
|
1631
|
+
/**
|
|
1632
|
+
* `stopAfter`: decode only the first `stopAfter` items, then jump to the
|
|
1633
|
+
* end of the part without tokenizing the rest (previews, ReadOptions.maxRows).
|
|
1634
|
+
*/
|
|
1635
|
+
constructor(mode, max, stopAfter = 1e400) {
|
|
1599
1636
|
this.mode = mode;
|
|
1600
1637
|
this.max = max;
|
|
1638
|
+
this.stopAfter = stopAfter;
|
|
1639
|
+
}
|
|
1640
|
+
attach(control) {
|
|
1641
|
+
this.control = control;
|
|
1642
|
+
if (this.stopAfter <= 0) this.stopped = true;
|
|
1643
|
+
}
|
|
1644
|
+
/** True once stopAfter items were decoded and the rest of the part is skipped. */
|
|
1645
|
+
stopped = false;
|
|
1646
|
+
pushed() {
|
|
1647
|
+
if (this.strings.length >= this.stopAfter && !this.stopped && this.control) {
|
|
1648
|
+
this.stopped = true;
|
|
1649
|
+
this.control.skipToEndOf(1);
|
|
1650
|
+
}
|
|
1601
1651
|
}
|
|
1602
1652
|
open(name, a, empty) {
|
|
1653
|
+
if (this.stopped && !this.item && name === "si") {
|
|
1654
|
+
if (!empty) this.control?.skipToEndOf(1);
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1603
1657
|
if (this.item) {
|
|
1604
1658
|
if (!empty) this.depth++;
|
|
1605
1659
|
this.item.open(name, a);
|
|
@@ -1612,8 +1666,10 @@ var SharedStringsParser = class {
|
|
|
1612
1666
|
value: this.strings.length + 1,
|
|
1613
1667
|
max: this.max
|
|
1614
1668
|
} });
|
|
1615
|
-
if (empty)
|
|
1616
|
-
|
|
1669
|
+
if (empty) {
|
|
1670
|
+
this.strings.push("");
|
|
1671
|
+
this.pushed();
|
|
1672
|
+
} else {
|
|
1617
1673
|
this.item = new StringItem();
|
|
1618
1674
|
this.depth = 0;
|
|
1619
1675
|
}
|
|
@@ -1624,6 +1680,7 @@ var SharedStringsParser = class {
|
|
|
1624
1680
|
if (this.depth === 0 && name === "si") {
|
|
1625
1681
|
this.strings.push(this.item.value(this.mode));
|
|
1626
1682
|
this.item = void 0;
|
|
1683
|
+
this.pushed();
|
|
1627
1684
|
return;
|
|
1628
1685
|
}
|
|
1629
1686
|
this.depth--;
|
|
@@ -1655,6 +1712,39 @@ const ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
1655
1712
|
"#PYTHON!",
|
|
1656
1713
|
"#EXTERNAL!"
|
|
1657
1714
|
]);
|
|
1715
|
+
/**
|
|
1716
|
+
* Shared-string cells whose text is filled in after the sheets are parsed
|
|
1717
|
+
* (ReadOptions.maxRows): the reader then decodes only the shared strings
|
|
1718
|
+
* up to the highest index the read rows use. Parallel arrays, one entry per
|
|
1719
|
+
* cell, kept small because a capped read can still hold many cells.
|
|
1720
|
+
*/
|
|
1721
|
+
var DeferredStrings = class {
|
|
1722
|
+
cells = [];
|
|
1723
|
+
indexes = [];
|
|
1724
|
+
rows = [];
|
|
1725
|
+
cols = [];
|
|
1726
|
+
refs = [];
|
|
1727
|
+
sheets = [];
|
|
1728
|
+
parts = [];
|
|
1729
|
+
maxIndex = -1;
|
|
1730
|
+
/** Fills each cell from `sst`; a missing entry is reported and the cell dropped unless it has a formula or style, as on the full path. */
|
|
1731
|
+
resolve(sst, warn) {
|
|
1732
|
+
for (let i = 0; i < this.cells.length; i++) {
|
|
1733
|
+
const cell = this.cells[i];
|
|
1734
|
+
const str = sst[this.indexes[i]];
|
|
1735
|
+
if (str === void 0) {
|
|
1736
|
+
warn(this.refs[i], this.sheets[i], this.parts[i], this.indexes[i]);
|
|
1737
|
+
delete cell.value;
|
|
1738
|
+
cell.type = "empty";
|
|
1739
|
+
const row = this.rows[i];
|
|
1740
|
+
if (cell.formula === void 0 && cell.style === void 0 && row[this.cols[i]] === cell) row[this.cols[i]] = void 0;
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
cell.value = str;
|
|
1744
|
+
cell.type = typeof str === "string" ? "string" : "richText";
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1658
1748
|
/** Maximum digit width of Calibri 11 in pixels; the writer uses the same value (internal/write/sheet-features.ts). */
|
|
1659
1749
|
const MAX_DIGIT_WIDTH = 7;
|
|
1660
1750
|
/**
|
|
@@ -1748,6 +1838,8 @@ var SheetParser = class {
|
|
|
1748
1838
|
minCol = 1e400;
|
|
1749
1839
|
maxRow = -1;
|
|
1750
1840
|
maxCol = -1;
|
|
1841
|
+
truncated = false;
|
|
1842
|
+
control;
|
|
1751
1843
|
constructor(name, state, ctx, styles, opts, part) {
|
|
1752
1844
|
this.ctx = ctx;
|
|
1753
1845
|
this.styles = styles;
|
|
@@ -1759,6 +1851,9 @@ var SheetParser = class {
|
|
|
1759
1851
|
};
|
|
1760
1852
|
if (state && state !== "visible") this.sheet.state = state;
|
|
1761
1853
|
}
|
|
1854
|
+
attach(control) {
|
|
1855
|
+
this.control = control;
|
|
1856
|
+
}
|
|
1762
1857
|
open(name, a, empty) {
|
|
1763
1858
|
if (this.inline) {
|
|
1764
1859
|
if (!empty) this.inlineDepth++;
|
|
@@ -1933,6 +2028,10 @@ var SheetParser = class {
|
|
|
1933
2028
|
} else this.curRow++;
|
|
1934
2029
|
this.nextCol = 0;
|
|
1935
2030
|
if (this.curRow >= 1048576) return;
|
|
2031
|
+
if (this.curRow >= this.opts.maxRows) {
|
|
2032
|
+
this.truncate();
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
1936
2035
|
const p = {};
|
|
1937
2036
|
const ht = num(a.get("ht"));
|
|
1938
2037
|
if (ht !== void 0 && bool(a.get("customHeight"), false)) p.height = ht;
|
|
@@ -1985,6 +2084,11 @@ var SheetParser = class {
|
|
|
1985
2084
|
}
|
|
1986
2085
|
if (row < 0) row = 0;
|
|
1987
2086
|
this.nextCol = col + 1;
|
|
2087
|
+
if (row >= this.opts.maxRows && row < 1048576) {
|
|
2088
|
+
this.truncate();
|
|
2089
|
+
if (!this.control) this.skipCell(empty);
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
1988
2092
|
if (row >= 1048576 || col >= 16384) {
|
|
1989
2093
|
this.ctx.warn("CELL_OUT_OF_BOUNDS", `Cell ${r ?? `${colLetters(col + 1)}${row + 1}`} is beyond the format limits; it was skipped.`, {
|
|
1990
2094
|
part: this.part,
|
|
@@ -2008,6 +2112,23 @@ var SheetParser = class {
|
|
|
2008
2112
|
};
|
|
2009
2113
|
if (empty) this.finishCell();
|
|
2010
2114
|
}
|
|
2115
|
+
/** maxRows reached: the rest of sheetData is tokenized but no cells are built; later elements (merges, views, …) are still read. */
|
|
2116
|
+
truncate() {
|
|
2117
|
+
if (this.truncated) return;
|
|
2118
|
+
this.truncated = true;
|
|
2119
|
+
this.ctx.warn("ROWS_TRUNCATED", `Sheet "${this.sheet.name}" has rows beyond maxRows (${this.opts.maxRows}); they were not read.`, {
|
|
2120
|
+
part: this.part,
|
|
2121
|
+
sheet: this.sheet.name
|
|
2122
|
+
});
|
|
2123
|
+
const depth = this.path.lastIndexOf("sheetData") + 1;
|
|
2124
|
+
if (this.control && depth > 0) {
|
|
2125
|
+
this.cell = void 0;
|
|
2126
|
+
this.inline = void 0;
|
|
2127
|
+
this.textTarget = void 0;
|
|
2128
|
+
this.path.length = depth;
|
|
2129
|
+
this.control.skipToEndOf(depth);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2011
2132
|
skipCell(empty) {
|
|
2012
2133
|
this.cell = void 0;
|
|
2013
2134
|
if (!empty) this.cell = {
|
|
@@ -2039,6 +2160,18 @@ var SheetParser = class {
|
|
|
2039
2160
|
ref: p.ref
|
|
2040
2161
|
});
|
|
2041
2162
|
row[p.col] = cell;
|
|
2163
|
+
if (this.pendingIndex >= 0) {
|
|
2164
|
+
const d = this.deferred;
|
|
2165
|
+
d.cells.push(cell);
|
|
2166
|
+
d.indexes.push(this.pendingIndex);
|
|
2167
|
+
d.rows.push(row);
|
|
2168
|
+
d.cols.push(p.col);
|
|
2169
|
+
d.refs.push(p.ref);
|
|
2170
|
+
d.sheets.push(this.sheet.name);
|
|
2171
|
+
d.parts.push(this.part);
|
|
2172
|
+
if (this.pendingIndex > d.maxIndex) d.maxIndex = this.pendingIndex;
|
|
2173
|
+
this.pendingIndex = -1;
|
|
2174
|
+
}
|
|
2042
2175
|
if (p.row < this.minRow) this.minRow = p.row;
|
|
2043
2176
|
if (p.row > this.maxRow) this.maxRow = p.row;
|
|
2044
2177
|
if (p.col < this.minCol) this.minCol = p.col;
|
|
@@ -2048,11 +2181,18 @@ var SheetParser = class {
|
|
|
2048
2181
|
const style = this.styles.style(p.s);
|
|
2049
2182
|
let value;
|
|
2050
2183
|
let type = "empty";
|
|
2184
|
+
let deferredIndex = -1;
|
|
2051
2185
|
const v = p.v;
|
|
2052
2186
|
switch (p.t) {
|
|
2053
2187
|
case "s": {
|
|
2054
2188
|
if (v === void 0) break;
|
|
2055
2189
|
const idx = Number(v);
|
|
2190
|
+
if (this.deferred && Number.isInteger(idx) && idx >= 0) {
|
|
2191
|
+
value = "";
|
|
2192
|
+
type = "string";
|
|
2193
|
+
deferredIndex = idx;
|
|
2194
|
+
break;
|
|
2195
|
+
}
|
|
2056
2196
|
const sst = this.sharedStrings;
|
|
2057
2197
|
const str = Number.isInteger(idx) && idx >= 0 ? sst[idx] : void 0;
|
|
2058
2198
|
if (str === void 0) {
|
|
@@ -2144,8 +2284,11 @@ var SheetParser = class {
|
|
|
2144
2284
|
if (formula.arrayRef) cell.arrayRef = formula.arrayRef;
|
|
2145
2285
|
}
|
|
2146
2286
|
if (style) cell.style = style;
|
|
2287
|
+
if (deferredIndex >= 0) this.pendingIndex = deferredIndex;
|
|
2147
2288
|
return cell;
|
|
2148
2289
|
}
|
|
2290
|
+
/** Set by convert() for a deferred shared-string cell; consumed by finishCell(). */
|
|
2291
|
+
pendingIndex = -1;
|
|
2149
2292
|
formula(p) {
|
|
2150
2293
|
if (p.f === void 0 || !this.opts.formulas) return void 0;
|
|
2151
2294
|
if (p.fType === "shared" && p.fSi !== void 0) {
|
|
@@ -2179,6 +2322,8 @@ var SheetParser = class {
|
|
|
2179
2322
|
}
|
|
2180
2323
|
/** Set before parsing; the shared strings table. */
|
|
2181
2324
|
sharedStrings = [];
|
|
2325
|
+
/** When set, shared-string cells are collected here and filled in later (ReadOptions.maxRows). */
|
|
2326
|
+
deferred;
|
|
2182
2327
|
openView(a) {
|
|
2183
2328
|
this.viewCount++;
|
|
2184
2329
|
if (this.viewCount !== 1) return;
|
|
@@ -2663,6 +2808,7 @@ async function readImpl(input, options, internal) {
|
|
|
2663
2808
|
checkEnum("dates", o.dates, ["date", "serial"]);
|
|
2664
2809
|
checkEnum("dateZone", o.dateZone, ["local", "utc"]);
|
|
2665
2810
|
checkEnum("richText", o.richText, ["runs", "plain"]);
|
|
2811
|
+
if (o.maxRows !== void 0 && (!Number.isInteger(o.maxRows) || o.maxRows < 0)) throw new TypeError(`maxRows must be a non-negative integer, got ${String(o.maxRows)}`);
|
|
2666
2812
|
throwIfAborted(o.signal);
|
|
2667
2813
|
const bytes = await toBytes(input, "read");
|
|
2668
2814
|
throwIfAborted(o.signal);
|
|
@@ -2719,10 +2865,13 @@ async function readImpl(input, options, internal) {
|
|
|
2719
2865
|
}
|
|
2720
2866
|
}
|
|
2721
2867
|
let sst = [];
|
|
2868
|
+
const deferred = o.maxRows !== void 0 ? new DeferredStrings() : void 0;
|
|
2869
|
+
let sstEntry;
|
|
2722
2870
|
const sstRel = relOf("sharedStrings");
|
|
2723
2871
|
if (sstRel) {
|
|
2724
2872
|
const entry = pkg.part(sstRel.target);
|
|
2725
2873
|
if (!entry) ctx.warn("MISSING_PART", `The shared strings part ${sstRel.target} is missing; cells that use it are empty.`, { part: sstRel.target });
|
|
2874
|
+
else if (deferred) sstEntry = entry;
|
|
2726
2875
|
else {
|
|
2727
2876
|
const sp = new SharedStringsParser(o.richText ?? "runs", limits.maxSharedStrings);
|
|
2728
2877
|
await ctx.parse(entry, sp);
|
|
@@ -2746,9 +2895,11 @@ async function readImpl(input, options, internal) {
|
|
|
2746
2895
|
dates: o.dates ?? "date",
|
|
2747
2896
|
dateZone: o.dateZone ?? "local",
|
|
2748
2897
|
richText: o.richText ?? "runs",
|
|
2749
|
-
date1904: wbp.date1904
|
|
2898
|
+
date1904: wbp.date1904,
|
|
2899
|
+
maxRows: o.maxRows ?? 1048576
|
|
2750
2900
|
}, rel?.target ?? workbookPart);
|
|
2751
2901
|
parser.sharedStrings = sst;
|
|
2902
|
+
parser.deferred = deferred;
|
|
2752
2903
|
const part = rel ? pkg.part(rel.target) : void 0;
|
|
2753
2904
|
if (!part) {
|
|
2754
2905
|
ctx.warn("MISSING_PART", `The part for sheet "${entry.name}" is missing; the sheet is empty.`, { sheet: entry.name });
|
|
@@ -2779,6 +2930,19 @@ async function readImpl(input, options, internal) {
|
|
|
2779
2930
|
doneBytes += part.size;
|
|
2780
2931
|
sheets.push(parser.finish(sheetRels));
|
|
2781
2932
|
}
|
|
2933
|
+
if (sstEntry && deferred && deferred.cells.length === 0) ctx.consumed.add(sstEntry.name);
|
|
2934
|
+
if (deferred && deferred.cells.length > 0) {
|
|
2935
|
+
if (sstEntry) {
|
|
2936
|
+
const sp = new SharedStringsParser(o.richText ?? "runs", limits.maxSharedStrings, deferred.maxIndex + 1);
|
|
2937
|
+
await ctx.parse(sstEntry, sp);
|
|
2938
|
+
sst = sp.strings;
|
|
2939
|
+
}
|
|
2940
|
+
deferred.resolve(sst, (ref, sheet, part, index) => ctx.warn("INVALID_SHARED_STRING", `Cell ${ref} refers to shared string ${index}, which does not exist; the cell was left empty.`, {
|
|
2941
|
+
part,
|
|
2942
|
+
sheet,
|
|
2943
|
+
ref
|
|
2944
|
+
}));
|
|
2945
|
+
}
|
|
2782
2946
|
const bookToSheet = /* @__PURE__ */ new Map();
|
|
2783
2947
|
listed.forEach((s, i) => bookToSheet.set(s.bookIndex, i));
|
|
2784
2948
|
const definedNames = [];
|
package/dist/read.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_read = require("./read-
|
|
2
|
+
const require_read = require("./read-CZEWV4rK.cjs");
|
|
3
3
|
exports.DEFAULT_READ_LIMITS = require_read.DEFAULT_READ_LIMITS;
|
|
4
4
|
exports.detectFormat = require_read.detectFormat;
|
|
5
5
|
exports.read = require_read.read;
|
package/dist/read.d.cts
CHANGED
|
@@ -7,9 +7,83 @@
|
|
|
7
7
|
* because the tokenizer ignores namespace prefixes and relationship types
|
|
8
8
|
* are matched by their last path segment, which both variants share.
|
|
9
9
|
* .xlsm, .xltx and .xltm read like .xlsx; macros are never read or run.
|
|
10
|
+
*
|
|
11
|
+
* @module javascript-excel/read
|
|
10
12
|
*/
|
|
11
|
-
import {
|
|
13
|
+
import { a as BlobType, i as BlobLike, n as ExcelWarningCode, r as BinaryInput, t as ExcelWarning } from "./warnings-B1v58nCZ.cjs";
|
|
14
|
+
import { A as Theme, C as PrintSetup, D as Sheet, E as RowProps, O as SheetView, S as PatternType, T as RichTextRun, _ as Font, a as Cell, b as NumFmt, c as CellType, d as ColumnProps, f as ColumnWidth, g as Fill, h as ErrorCode, i as BorderStyle, j as Workbook, k as Style, l as CellValue, m as DocProperties, n as Border, o as CellErrorValue, p as DefinedName, r as BorderSide, s as CellInput, t as Alignment, u as Color, v as GradientFill, w as RichText, x as PatternFill, y as Hyperlink } from "./model-0JikLfuM.cjs";
|
|
12
15
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.cjs";
|
|
13
|
-
import { t as Progress } from "./write-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
+
import { t as Progress } from "./write-DtjfdIFm.cjs";
|
|
17
|
+
/** Result of `read`. */
|
|
18
|
+
export interface ReadResult {
|
|
19
|
+
workbook: Workbook<Cell>;
|
|
20
|
+
warnings: ExcelWarning[];
|
|
21
|
+
}
|
|
22
|
+
/** Options for `read`. */
|
|
23
|
+
export interface ReadOptions {
|
|
24
|
+
/** Only parse these sheets (by name or index); the others are listed with empty rows. Default: all. */
|
|
25
|
+
sheets?: Array<string | number> | undefined;
|
|
26
|
+
/** Parse styles (default true). false is faster: no `cell.style`, but date detection still uses the number format. */
|
|
27
|
+
styles?: boolean | undefined;
|
|
28
|
+
/** Return formula text (default true). false: cached values only. */
|
|
29
|
+
formulas?: boolean | undefined;
|
|
30
|
+
/** `'date'` (default): date-formatted numbers become `Date`. `'serial'`: leave them as numbers. */
|
|
31
|
+
dates?: "date" | "serial" | undefined;
|
|
32
|
+
/** Default `'local'`. */
|
|
33
|
+
dateZone?: "local" | "utc" | undefined;
|
|
34
|
+
/** Rich text as runs (default) or flattened to a plain string. */
|
|
35
|
+
richText?: "runs" | "plain" | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Read only the first `maxRows` rows of each parsed sheet (zero-based rows
|
|
38
|
+
* 0..maxRows-1). Later rows are skipped without building cells, with one
|
|
39
|
+
* `ROWS_TRUNCATED` warning per sheet; merges, views and the other sheet
|
|
40
|
+
* features after the cell data are still read. Default: all rows.
|
|
41
|
+
*/
|
|
42
|
+
maxRows?: number | undefined;
|
|
43
|
+
limits?: Partial<ReadLimits> | undefined;
|
|
44
|
+
/** Rejects with `signal.reason` when aborted. */
|
|
45
|
+
signal?: AbortSignalLike | undefined;
|
|
46
|
+
onProgress?: ((p: Progress) => void) | undefined;
|
|
47
|
+
/** Called as warnings occur, in addition to `ReadResult.warnings`. */
|
|
48
|
+
onWarning?: ((w: ExcelWarning) => void) | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it). */
|
|
51
|
+
export interface ReadLimits {
|
|
52
|
+
maxInputBytes: number;
|
|
53
|
+
maxEntries: number;
|
|
54
|
+
/** Decompressed bytes of one part. */
|
|
55
|
+
maxEntryBytes: number;
|
|
56
|
+
/** Decompressed bytes of all parts read. */
|
|
57
|
+
maxTotalBytes: number;
|
|
58
|
+
/** Decompressed / compressed, per entry, checked once an entry has produced more than 1 MiB. */
|
|
59
|
+
maxRatio: number;
|
|
60
|
+
maxXmlDepth: number;
|
|
61
|
+
/** All sheets together. */
|
|
62
|
+
maxCells: number;
|
|
63
|
+
maxSharedStrings: number;
|
|
64
|
+
/** Then a single `WARNINGS_TRUNCATED`. */
|
|
65
|
+
maxWarnings: number;
|
|
66
|
+
}
|
|
67
|
+
/** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
|
|
68
|
+
export declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
|
|
69
|
+
/** A sheet as listed by `readSheetNames`. */
|
|
70
|
+
export interface SheetInfo {
|
|
71
|
+
name: string;
|
|
72
|
+
index: number;
|
|
73
|
+
state: "visible" | "hidden" | "veryHidden";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* What `detectFormat` recognises. `'cfb'` is a legacy `.xls` or an encrypted OOXML file.
|
|
77
|
+
* `read` reads xlsx, xlsm, xltx and xltm; the others are rejected with UNSUPPORTED_FORMAT.
|
|
78
|
+
*/
|
|
79
|
+
export type DetectedFormat = "xlsx" | "xlsm" | "xltx" | "xltm" | "xlsb" | "ods" | "cfb" | "zip" | "unknown";
|
|
80
|
+
/** Detects the file format from the bytes. Never throws for unreadable input; returns `'unknown'` or `'zip'` instead. */
|
|
81
|
+
export declare function detectFormat(input: BinaryInput): Promise<DetectedFormat>;
|
|
82
|
+
/** Lists the worksheets (name, index, visibility) without parsing any sheet. */
|
|
83
|
+
export declare function readSheetNames(input: BinaryInput, options?: {
|
|
84
|
+
limits?: Partial<ReadLimits> | undefined;
|
|
85
|
+
signal?: AbortSignalLike | undefined;
|
|
86
|
+
}): Promise<SheetInfo[]>;
|
|
87
|
+
/** Reads an .xlsx, .xlsm, .xltx or .xltm file into the model. */
|
|
88
|
+
export declare function read(input: BinaryInput, options?: ReadOptions): Promise<ReadResult>;
|
|
89
|
+
export type { AbortSignalLike, Alignment, BinaryInput, BlobLike, BlobType, Border, BorderSide, BorderStyle, Cell, CellErrorValue, CellInput, CellType, CellValue, Color, ColumnProps, ColumnWidth, DefinedName, DocProperties, ErrorCode, ExcelWarning, ExcelWarningCode, Fill, Font, GradientFill, Hyperlink, NumFmt, PatternFill, PatternType, PrintSetup, Progress, RichText, RichTextRun, RowProps, Sheet, SheetView, Style, Theme, Workbook };
|
package/dist/read.d.ts
CHANGED
|
@@ -7,9 +7,83 @@
|
|
|
7
7
|
* because the tokenizer ignores namespace prefixes and relationship types
|
|
8
8
|
* are matched by their last path segment, which both variants share.
|
|
9
9
|
* .xlsm, .xltx and .xltm read like .xlsx; macros are never read or run.
|
|
10
|
+
*
|
|
11
|
+
* @module javascript-excel/read
|
|
10
12
|
*/
|
|
11
|
-
import {
|
|
13
|
+
import { a as BlobType, i as BlobLike, n as ExcelWarningCode, r as BinaryInput, t as ExcelWarning } from "./warnings-B1v58nCZ.js";
|
|
14
|
+
import { A as Theme, C as PrintSetup, D as Sheet, E as RowProps, O as SheetView, S as PatternType, T as RichTextRun, _ as Font, a as Cell, b as NumFmt, c as CellType, d as ColumnProps, f as ColumnWidth, g as Fill, h as ErrorCode, i as BorderStyle, j as Workbook, k as Style, l as CellValue, m as DocProperties, n as Border, o as CellErrorValue, p as DefinedName, r as BorderSide, s as CellInput, t as Alignment, u as Color, v as GradientFill, w as RichText, x as PatternFill, y as Hyperlink } from "./model-0JikLfuM.js";
|
|
12
15
|
import { t as AbortSignalLike } from "./signal-Dz0ZYe6d.js";
|
|
13
|
-
import { t as Progress } from "./write-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
+
import { t as Progress } from "./write-DM6ieuQY.js";
|
|
17
|
+
/** Result of `read`. */
|
|
18
|
+
export interface ReadResult {
|
|
19
|
+
workbook: Workbook<Cell>;
|
|
20
|
+
warnings: ExcelWarning[];
|
|
21
|
+
}
|
|
22
|
+
/** Options for `read`. */
|
|
23
|
+
export interface ReadOptions {
|
|
24
|
+
/** Only parse these sheets (by name or index); the others are listed with empty rows. Default: all. */
|
|
25
|
+
sheets?: Array<string | number> | undefined;
|
|
26
|
+
/** Parse styles (default true). false is faster: no `cell.style`, but date detection still uses the number format. */
|
|
27
|
+
styles?: boolean | undefined;
|
|
28
|
+
/** Return formula text (default true). false: cached values only. */
|
|
29
|
+
formulas?: boolean | undefined;
|
|
30
|
+
/** `'date'` (default): date-formatted numbers become `Date`. `'serial'`: leave them as numbers. */
|
|
31
|
+
dates?: "date" | "serial" | undefined;
|
|
32
|
+
/** Default `'local'`. */
|
|
33
|
+
dateZone?: "local" | "utc" | undefined;
|
|
34
|
+
/** Rich text as runs (default) or flattened to a plain string. */
|
|
35
|
+
richText?: "runs" | "plain" | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Read only the first `maxRows` rows of each parsed sheet (zero-based rows
|
|
38
|
+
* 0..maxRows-1). Later rows are skipped without building cells, with one
|
|
39
|
+
* `ROWS_TRUNCATED` warning per sheet; merges, views and the other sheet
|
|
40
|
+
* features after the cell data are still read. Default: all rows.
|
|
41
|
+
*/
|
|
42
|
+
maxRows?: number | undefined;
|
|
43
|
+
limits?: Partial<ReadLimits> | undefined;
|
|
44
|
+
/** Rejects with `signal.reason` when aborted. */
|
|
45
|
+
signal?: AbortSignalLike | undefined;
|
|
46
|
+
onProgress?: ((p: Progress) => void) | undefined;
|
|
47
|
+
/** Called as warnings occur, in addition to `ReadResult.warnings`. */
|
|
48
|
+
onWarning?: ((w: ExcelWarning) => void) | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** Limits for untrusted input. Exceeding one throws `LimitError` (`LIMIT_EXCEEDED`, `details.limit` names it). */
|
|
51
|
+
export interface ReadLimits {
|
|
52
|
+
maxInputBytes: number;
|
|
53
|
+
maxEntries: number;
|
|
54
|
+
/** Decompressed bytes of one part. */
|
|
55
|
+
maxEntryBytes: number;
|
|
56
|
+
/** Decompressed bytes of all parts read. */
|
|
57
|
+
maxTotalBytes: number;
|
|
58
|
+
/** Decompressed / compressed, per entry, checked once an entry has produced more than 1 MiB. */
|
|
59
|
+
maxRatio: number;
|
|
60
|
+
maxXmlDepth: number;
|
|
61
|
+
/** All sheets together. */
|
|
62
|
+
maxCells: number;
|
|
63
|
+
maxSharedStrings: number;
|
|
64
|
+
/** Then a single `WARNINGS_TRUNCATED`. */
|
|
65
|
+
maxWarnings: number;
|
|
66
|
+
}
|
|
67
|
+
/** Default limits (docs/api.md §5.2; the measurements behind each value are listed there). */
|
|
68
|
+
export declare const DEFAULT_READ_LIMITS: Readonly<ReadLimits>;
|
|
69
|
+
/** A sheet as listed by `readSheetNames`. */
|
|
70
|
+
export interface SheetInfo {
|
|
71
|
+
name: string;
|
|
72
|
+
index: number;
|
|
73
|
+
state: "visible" | "hidden" | "veryHidden";
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* What `detectFormat` recognises. `'cfb'` is a legacy `.xls` or an encrypted OOXML file.
|
|
77
|
+
* `read` reads xlsx, xlsm, xltx and xltm; the others are rejected with UNSUPPORTED_FORMAT.
|
|
78
|
+
*/
|
|
79
|
+
export type DetectedFormat = "xlsx" | "xlsm" | "xltx" | "xltm" | "xlsb" | "ods" | "cfb" | "zip" | "unknown";
|
|
80
|
+
/** Detects the file format from the bytes. Never throws for unreadable input; returns `'unknown'` or `'zip'` instead. */
|
|
81
|
+
export declare function detectFormat(input: BinaryInput): Promise<DetectedFormat>;
|
|
82
|
+
/** Lists the worksheets (name, index, visibility) without parsing any sheet. */
|
|
83
|
+
export declare function readSheetNames(input: BinaryInput, options?: {
|
|
84
|
+
limits?: Partial<ReadLimits> | undefined;
|
|
85
|
+
signal?: AbortSignalLike | undefined;
|
|
86
|
+
}): Promise<SheetInfo[]>;
|
|
87
|
+
/** Reads an .xlsx, .xlsm, .xltx or .xltm file into the model. */
|
|
88
|
+
export declare function read(input: BinaryInput, options?: ReadOptions): Promise<ReadResult>;
|
|
89
|
+
export type { AbortSignalLike, Alignment, BinaryInput, BlobLike, BlobType, Border, BorderSide, BorderStyle, Cell, CellErrorValue, CellInput, CellType, CellValue, Color, ColumnProps, ColumnWidth, DefinedName, DocProperties, ErrorCode, ExcelWarning, ExcelWarningCode, Fill, Font, GradientFill, Hyperlink, NumFmt, PatternFill, PatternType, PrintSetup, Progress, RichText, RichTextRun, RowProps, Sheet, SheetView, Style, Theme, Workbook };
|
package/dist/read.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as DEFAULT_READ_LIMITS, n as detectFormat, r as read, i as readSheetNames } from "./read-
|
|
1
|
+
export { t as DEFAULT_READ_LIMITS, n as detectFormat, r as read, i as readSheetNames } from "./read-LWti17lz.js";
|