@cj-tech-master/excelts 4.2.3 → 5.0.0-canary.20260123012457.1fdf506
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/dist/browser/modules/csv/csv-core.d.ts +0 -9
- package/dist/browser/modules/csv/csv.browser.js +3 -3
- package/dist/browser/modules/excel/column.d.ts +5 -0
- package/dist/browser/modules/excel/column.js +10 -2
- package/dist/browser/modules/excel/row.d.ts +2 -0
- package/dist/browser/modules/excel/row.js +3 -1
- package/dist/browser/modules/excel/utils/parse-sax.d.ts +0 -3
- package/dist/browser/modules/excel/utils/parse-sax.js +13 -32
- package/dist/browser/modules/excel/utils/passthrough-manager.d.ts +77 -0
- package/dist/browser/modules/excel/utils/passthrough-manager.js +129 -0
- package/dist/browser/modules/excel/workbook.d.ts +12 -0
- package/dist/browser/modules/excel/workbook.js +12 -1
- package/dist/browser/modules/excel/worksheet.d.ts +4 -0
- package/dist/browser/modules/excel/worksheet.js +4 -1
- package/dist/browser/modules/excel/xlsx/xform/base-xform.js +68 -1
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +35 -11
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +271 -94
- package/dist/browser/modules/excel/xlsx/xform/sheet/row-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/row-xform.js +7 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +9 -4
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +4 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +40 -12
- package/dist/browser/modules/excel/xlsx/xform/style/style-xform.d.ts +7 -0
- package/dist/browser/modules/excel/xlsx/xform/style/style-xform.js +26 -6
- package/dist/browser/modules/excel/xlsx/xform/style/styles-xform.d.ts +6 -0
- package/dist/browser/modules/excel/xlsx/xform/style/styles-xform.js +52 -4
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +220 -131
- package/dist/browser/modules/stream/streams.browser.js +0 -3
- package/dist/cjs/modules/csv/csv.browser.js +3 -3
- package/dist/cjs/modules/excel/column.js +10 -2
- package/dist/cjs/modules/excel/row.js +3 -1
- package/dist/cjs/modules/excel/utils/parse-sax.js +13 -32
- package/dist/cjs/modules/excel/utils/passthrough-manager.js +133 -0
- package/dist/cjs/modules/excel/workbook.js +12 -1
- package/dist/cjs/modules/excel/worksheet.js +4 -1
- package/dist/cjs/modules/excel/xlsx/xform/base-xform.js +68 -1
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +271 -94
- package/dist/cjs/modules/excel/xlsx/xform/sheet/row-xform.js +7 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +9 -4
- package/dist/cjs/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +4 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +40 -12
- package/dist/cjs/modules/excel/xlsx/xform/style/style-xform.js +26 -6
- package/dist/cjs/modules/excel/xlsx/xform/style/styles-xform.js +52 -4
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +220 -131
- package/dist/cjs/modules/stream/streams.browser.js +0 -3
- package/dist/esm/modules/csv/csv.browser.js +3 -3
- package/dist/esm/modules/excel/column.js +10 -2
- package/dist/esm/modules/excel/row.js +3 -1
- package/dist/esm/modules/excel/utils/parse-sax.js +13 -32
- package/dist/esm/modules/excel/utils/passthrough-manager.js +129 -0
- package/dist/esm/modules/excel/workbook.js +12 -1
- package/dist/esm/modules/excel/worksheet.js +4 -1
- package/dist/esm/modules/excel/xlsx/xform/base-xform.js +68 -1
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +271 -94
- package/dist/esm/modules/excel/xlsx/xform/sheet/row-xform.js +7 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +9 -4
- package/dist/esm/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +4 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +40 -12
- package/dist/esm/modules/excel/xlsx/xform/style/style-xform.js +26 -6
- package/dist/esm/modules/excel/xlsx/xform/style/styles-xform.js +52 -4
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +220 -131
- package/dist/esm/modules/stream/streams.browser.js +0 -3
- package/dist/iife/excelts.iife.js +1009 -650
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +25 -52
- package/dist/types/modules/csv/csv-core.d.ts +0 -9
- package/dist/types/modules/excel/column.d.ts +5 -0
- package/dist/types/modules/excel/row.d.ts +2 -0
- package/dist/types/modules/excel/utils/parse-sax.d.ts +0 -3
- package/dist/types/modules/excel/utils/passthrough-manager.d.ts +77 -0
- package/dist/types/modules/excel/workbook.d.ts +12 -0
- package/dist/types/modules/excel/worksheet.d.ts +4 -0
- package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +35 -11
- package/dist/types/modules/excel/xlsx/xform/sheet/row-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/style/style-xform.d.ts +7 -0
- package/dist/types/modules/excel/xlsx/xform/style/styles-xform.d.ts +6 -0
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/package.json +15 -15
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts
|
|
2
|
+
* @cj-tech-master/excelts v5.0.0-canary.20260123012457.1fdf506
|
|
3
3
|
* TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
|
|
4
4
|
* (c) 2026 cjnoname
|
|
5
5
|
* Released under the MIT License
|
|
@@ -228,8 +228,8 @@ var ExcelTS = (function(exports) {
|
|
|
228
228
|
default: throw new Error("Can only encode with 2 or 4 arguments");
|
|
229
229
|
}
|
|
230
230
|
},
|
|
231
|
-
inRange(range
|
|
232
|
-
const [left, top, , right, bottom] = range
|
|
231
|
+
inRange(range, address) {
|
|
232
|
+
const [left, top, , right, bottom] = range;
|
|
233
233
|
const [col, row] = address;
|
|
234
234
|
return col >= left && col <= right && row >= top && row <= bottom;
|
|
235
235
|
}
|
|
@@ -435,47 +435,47 @@ var ExcelTS = (function(exports) {
|
|
|
435
435
|
|
|
436
436
|
//#endregion
|
|
437
437
|
//#region src/modules/excel/enums.ts
|
|
438
|
-
let ValueType = /* @__PURE__ */ function(ValueType
|
|
439
|
-
ValueType
|
|
440
|
-
ValueType
|
|
441
|
-
ValueType
|
|
442
|
-
ValueType
|
|
443
|
-
ValueType
|
|
444
|
-
ValueType
|
|
445
|
-
ValueType
|
|
446
|
-
ValueType
|
|
447
|
-
ValueType
|
|
448
|
-
ValueType
|
|
449
|
-
ValueType
|
|
450
|
-
ValueType
|
|
451
|
-
ValueType
|
|
452
|
-
return ValueType
|
|
438
|
+
let ValueType = /* @__PURE__ */ function(ValueType) {
|
|
439
|
+
ValueType[ValueType["Null"] = 0] = "Null";
|
|
440
|
+
ValueType[ValueType["Merge"] = 1] = "Merge";
|
|
441
|
+
ValueType[ValueType["Number"] = 2] = "Number";
|
|
442
|
+
ValueType[ValueType["String"] = 3] = "String";
|
|
443
|
+
ValueType[ValueType["Date"] = 4] = "Date";
|
|
444
|
+
ValueType[ValueType["Hyperlink"] = 5] = "Hyperlink";
|
|
445
|
+
ValueType[ValueType["Formula"] = 6] = "Formula";
|
|
446
|
+
ValueType[ValueType["SharedString"] = 7] = "SharedString";
|
|
447
|
+
ValueType[ValueType["RichText"] = 8] = "RichText";
|
|
448
|
+
ValueType[ValueType["Boolean"] = 9] = "Boolean";
|
|
449
|
+
ValueType[ValueType["Error"] = 10] = "Error";
|
|
450
|
+
ValueType[ValueType["JSON"] = 11] = "JSON";
|
|
451
|
+
ValueType[ValueType["Checkbox"] = 12] = "Checkbox";
|
|
452
|
+
return ValueType;
|
|
453
453
|
}({});
|
|
454
|
-
let FormulaType = /* @__PURE__ */ function(FormulaType
|
|
455
|
-
FormulaType
|
|
456
|
-
FormulaType
|
|
457
|
-
FormulaType
|
|
458
|
-
return FormulaType
|
|
454
|
+
let FormulaType = /* @__PURE__ */ function(FormulaType) {
|
|
455
|
+
FormulaType[FormulaType["None"] = 0] = "None";
|
|
456
|
+
FormulaType[FormulaType["Master"] = 1] = "Master";
|
|
457
|
+
FormulaType[FormulaType["Shared"] = 2] = "Shared";
|
|
458
|
+
return FormulaType;
|
|
459
459
|
}({});
|
|
460
|
-
let RelationshipType = /* @__PURE__ */ function(RelationshipType
|
|
461
|
-
RelationshipType
|
|
462
|
-
RelationshipType
|
|
463
|
-
RelationshipType
|
|
464
|
-
RelationshipType
|
|
465
|
-
RelationshipType
|
|
466
|
-
RelationshipType
|
|
467
|
-
RelationshipType
|
|
468
|
-
RelationshipType
|
|
469
|
-
return RelationshipType
|
|
460
|
+
let RelationshipType = /* @__PURE__ */ function(RelationshipType) {
|
|
461
|
+
RelationshipType[RelationshipType["None"] = 0] = "None";
|
|
462
|
+
RelationshipType[RelationshipType["OfficeDocument"] = 1] = "OfficeDocument";
|
|
463
|
+
RelationshipType[RelationshipType["Worksheet"] = 2] = "Worksheet";
|
|
464
|
+
RelationshipType[RelationshipType["CalcChain"] = 3] = "CalcChain";
|
|
465
|
+
RelationshipType[RelationshipType["SharedStrings"] = 4] = "SharedStrings";
|
|
466
|
+
RelationshipType[RelationshipType["Styles"] = 5] = "Styles";
|
|
467
|
+
RelationshipType[RelationshipType["Theme"] = 6] = "Theme";
|
|
468
|
+
RelationshipType[RelationshipType["Hyperlink"] = 7] = "Hyperlink";
|
|
469
|
+
return RelationshipType;
|
|
470
470
|
}({});
|
|
471
|
-
let DocumentType = /* @__PURE__ */ function(DocumentType
|
|
472
|
-
DocumentType
|
|
473
|
-
return DocumentType
|
|
471
|
+
let DocumentType = /* @__PURE__ */ function(DocumentType) {
|
|
472
|
+
DocumentType[DocumentType["Xlsx"] = 1] = "Xlsx";
|
|
473
|
+
return DocumentType;
|
|
474
474
|
}({});
|
|
475
|
-
let ReadingOrder = /* @__PURE__ */ function(ReadingOrder
|
|
476
|
-
ReadingOrder
|
|
477
|
-
ReadingOrder
|
|
478
|
-
return ReadingOrder
|
|
475
|
+
let ReadingOrder = /* @__PURE__ */ function(ReadingOrder) {
|
|
476
|
+
ReadingOrder[ReadingOrder["LeftToRight"] = 1] = "LeftToRight";
|
|
477
|
+
ReadingOrder[ReadingOrder["RightToLeft"] = 2] = "RightToLeft";
|
|
478
|
+
return ReadingOrder;
|
|
479
479
|
}({});
|
|
480
480
|
const ErrorValue = {
|
|
481
481
|
NotApplicable: "#N/A",
|
|
@@ -1830,7 +1830,8 @@ var ExcelTS = (function(exports) {
|
|
|
1830
1830
|
style: this.style,
|
|
1831
1831
|
hidden: this.hidden,
|
|
1832
1832
|
outlineLevel: this.outlineLevel,
|
|
1833
|
-
collapsed: this.collapsed
|
|
1833
|
+
collapsed: this.collapsed,
|
|
1834
|
+
dyDescent: this.dyDescent
|
|
1834
1835
|
} : null;
|
|
1835
1836
|
}
|
|
1836
1837
|
set model(value) {
|
|
@@ -1864,6 +1865,7 @@ var ExcelTS = (function(exports) {
|
|
|
1864
1865
|
else delete this.height;
|
|
1865
1866
|
this.hidden = value.hidden;
|
|
1866
1867
|
this.outlineLevel = value.outlineLevel || 0;
|
|
1868
|
+
this.dyDescent = value.dyDescent;
|
|
1867
1869
|
this.style = value.style && JSON.parse(JSON.stringify(value.style)) || {};
|
|
1868
1870
|
}
|
|
1869
1871
|
};
|
|
@@ -1904,7 +1906,8 @@ var ExcelTS = (function(exports) {
|
|
|
1904
1906
|
width: this.width,
|
|
1905
1907
|
style: this.style,
|
|
1906
1908
|
hidden: this.hidden,
|
|
1907
|
-
outlineLevel: this.outlineLevel
|
|
1909
|
+
outlineLevel: this.outlineLevel,
|
|
1910
|
+
bestFit: this.bestFit
|
|
1908
1911
|
};
|
|
1909
1912
|
}
|
|
1910
1913
|
set defn(value) {
|
|
@@ -1916,12 +1919,14 @@ var ExcelTS = (function(exports) {
|
|
|
1916
1919
|
else this.style = {};
|
|
1917
1920
|
this.header = value.header;
|
|
1918
1921
|
this._hidden = !!value.hidden;
|
|
1922
|
+
this.bestFit = value.bestFit;
|
|
1919
1923
|
} else {
|
|
1920
1924
|
delete this._header;
|
|
1921
1925
|
delete this._key;
|
|
1922
1926
|
delete this.width;
|
|
1923
1927
|
this.style = {};
|
|
1924
1928
|
this.outlineLevel = 0;
|
|
1929
|
+
delete this.bestFit;
|
|
1925
1930
|
}
|
|
1926
1931
|
}
|
|
1927
1932
|
/**
|
|
@@ -1993,12 +1998,13 @@ var ExcelTS = (function(exports) {
|
|
|
1993
1998
|
return this.width === other.width && this.hidden === other.hidden && this.outlineLevel === other.outlineLevel && isEqual(this.style, other.style);
|
|
1994
1999
|
}
|
|
1995
2000
|
equivalentToModel(model) {
|
|
1996
|
-
return this.width === model.width && this.hidden === model.hidden && this.outlineLevel === model.outlineLevel && isEqual(this.style, model.style);
|
|
2001
|
+
return this.width === model.width && this.hidden === model.hidden && this.outlineLevel === model.outlineLevel && this.bestFit === model.bestFit && isEqual(this.style, model.style);
|
|
1997
2002
|
}
|
|
1998
2003
|
get isDefault() {
|
|
1999
2004
|
if (this.isCustomWidth) return false;
|
|
2000
2005
|
if (this.hidden) return false;
|
|
2001
2006
|
if (this.outlineLevel) return false;
|
|
2007
|
+
if (this.bestFit) return false;
|
|
2002
2008
|
const s = this.style;
|
|
2003
2009
|
if (s && (s.font || s.numFmt || s.alignment || s.border || s.fill || s.protection)) return false;
|
|
2004
2010
|
return true;
|
|
@@ -2126,7 +2132,8 @@ var ExcelTS = (function(exports) {
|
|
|
2126
2132
|
isCustomWidth: column.isCustomWidth,
|
|
2127
2133
|
hidden: column.hidden,
|
|
2128
2134
|
outlineLevel: column.outlineLevel,
|
|
2129
|
-
collapsed: column.collapsed
|
|
2135
|
+
collapsed: column.collapsed,
|
|
2136
|
+
bestFit: column.bestFit
|
|
2130
2137
|
};
|
|
2131
2138
|
cols.push(col);
|
|
2132
2139
|
} else col.max = index + 1;
|
|
@@ -2261,12 +2268,12 @@ var ExcelTS = (function(exports) {
|
|
|
2261
2268
|
default: throw new Error("Invalid Image Type");
|
|
2262
2269
|
}
|
|
2263
2270
|
}
|
|
2264
|
-
set model({ type, imageId, range
|
|
2271
|
+
set model({ type, imageId, range, hyperlinks }) {
|
|
2265
2272
|
this.type = type;
|
|
2266
2273
|
this.imageId = imageId;
|
|
2267
2274
|
if (type === "image") {
|
|
2268
|
-
if (typeof range
|
|
2269
|
-
const decoded = colCache.decode(range
|
|
2275
|
+
if (typeof range === "string") {
|
|
2276
|
+
const decoded = colCache.decode(range);
|
|
2270
2277
|
if ("top" in decoded) this.range = {
|
|
2271
2278
|
tl: new Anchor(this.worksheet, {
|
|
2272
2279
|
col: decoded.left,
|
|
@@ -2278,12 +2285,12 @@ var ExcelTS = (function(exports) {
|
|
|
2278
2285
|
}, 0),
|
|
2279
2286
|
editAs: "oneCell"
|
|
2280
2287
|
};
|
|
2281
|
-
} else if (range
|
|
2282
|
-
tl: new Anchor(this.worksheet, range
|
|
2283
|
-
br: range
|
|
2284
|
-
ext: range
|
|
2285
|
-
editAs: range
|
|
2286
|
-
hyperlinks: hyperlinks || ("hyperlinks" in range
|
|
2288
|
+
} else if (range) this.range = {
|
|
2289
|
+
tl: new Anchor(this.worksheet, range.tl, 0),
|
|
2290
|
+
br: range.br ? new Anchor(this.worksheet, range.br, 0) : void 0,
|
|
2291
|
+
ext: range.ext,
|
|
2292
|
+
editAs: range.editAs,
|
|
2293
|
+
hyperlinks: hyperlinks || ("hyperlinks" in range ? range.hyperlinks : void 0)
|
|
2287
2294
|
};
|
|
2288
2295
|
}
|
|
2289
2296
|
}
|
|
@@ -2395,17 +2402,17 @@ var ExcelTS = (function(exports) {
|
|
|
2395
2402
|
}
|
|
2396
2403
|
validate() {
|
|
2397
2404
|
const { table } = this;
|
|
2398
|
-
const assign
|
|
2405
|
+
const assign = (o, name, dflt) => {
|
|
2399
2406
|
if (o[name] === void 0) o[name] = dflt;
|
|
2400
2407
|
};
|
|
2401
|
-
assign
|
|
2402
|
-
assign
|
|
2403
|
-
assign
|
|
2404
|
-
assign
|
|
2405
|
-
assign
|
|
2406
|
-
assign
|
|
2407
|
-
assign
|
|
2408
|
-
assign
|
|
2408
|
+
assign(table, "headerRow", true);
|
|
2409
|
+
assign(table, "totalsRow", false);
|
|
2410
|
+
assign(table, "style", {});
|
|
2411
|
+
assign(table.style, "theme", "TableStyleMedium2");
|
|
2412
|
+
assign(table.style, "showFirstColumn", false);
|
|
2413
|
+
assign(table.style, "showLastColumn", false);
|
|
2414
|
+
assign(table.style, "showRowStripes", false);
|
|
2415
|
+
assign(table.style, "showColumnStripes", false);
|
|
2409
2416
|
const assert = (test, message) => {
|
|
2410
2417
|
if (!test) throw new Error(message);
|
|
2411
2418
|
};
|
|
@@ -2421,9 +2428,9 @@ var ExcelTS = (function(exports) {
|
|
|
2421
2428
|
table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
|
|
2422
2429
|
table.columns.forEach((column, i) => {
|
|
2423
2430
|
assert(!!column.name, `Column ${i} must have a name`);
|
|
2424
|
-
if (i === 0) assign
|
|
2431
|
+
if (i === 0) assign(column, "totalsRowLabel", "Total");
|
|
2425
2432
|
else {
|
|
2426
|
-
assign
|
|
2433
|
+
assign(column, "totalsRowFunction", "none");
|
|
2427
2434
|
column.totalsRowFormula = this.getFormula(column) || void 0;
|
|
2428
2435
|
}
|
|
2429
2436
|
});
|
|
@@ -2654,8 +2661,8 @@ var ExcelTS = (function(exports) {
|
|
|
2654
2661
|
constructor(model) {
|
|
2655
2662
|
this.model = model || {};
|
|
2656
2663
|
}
|
|
2657
|
-
add(address, validation
|
|
2658
|
-
return this.model[address] = validation
|
|
2664
|
+
add(address, validation) {
|
|
2665
|
+
return this.model[address] = validation;
|
|
2659
2666
|
}
|
|
2660
2667
|
find(address) {
|
|
2661
2668
|
const direct = this.model[address];
|
|
@@ -2699,9 +2706,9 @@ var ExcelTS = (function(exports) {
|
|
|
2699
2706
|
/** Default end row offset in EMUs (~20 pixels) */
|
|
2700
2707
|
const DEFAULT_END_ROW_OFF = 190500;
|
|
2701
2708
|
var FormCheckbox = class FormCheckbox {
|
|
2702
|
-
constructor(worksheet, range
|
|
2709
|
+
constructor(worksheet, range, options) {
|
|
2703
2710
|
this.worksheet = worksheet;
|
|
2704
|
-
const { tl, br } = this._parseRange(range
|
|
2711
|
+
const { tl, br } = this._parseRange(range);
|
|
2705
2712
|
const shapeId = 1025 + (worksheet.formControls?.length || 0);
|
|
2706
2713
|
let link;
|
|
2707
2714
|
if (options?.link) link = this._toAbsoluteRef(options.link);
|
|
@@ -2764,11 +2771,11 @@ var ExcelTS = (function(exports) {
|
|
|
2764
2771
|
/**
|
|
2765
2772
|
* Parse range input into anchor positions
|
|
2766
2773
|
*/
|
|
2767
|
-
_parseRange(range
|
|
2774
|
+
_parseRange(range) {
|
|
2768
2775
|
let tl;
|
|
2769
2776
|
let br;
|
|
2770
|
-
if (typeof range
|
|
2771
|
-
const decoded = colCache.decode(range
|
|
2777
|
+
if (typeof range === "string") if (range.includes(":")) {
|
|
2778
|
+
const decoded = colCache.decode(range);
|
|
2772
2779
|
if ("top" in decoded) if (decoded.left === decoded.right && decoded.top === decoded.bottom) {
|
|
2773
2780
|
const col = decoded.left - 1;
|
|
2774
2781
|
const row = decoded.top - 1;
|
|
@@ -2813,7 +2820,7 @@ var ExcelTS = (function(exports) {
|
|
|
2813
2820
|
};
|
|
2814
2821
|
}
|
|
2815
2822
|
} else {
|
|
2816
|
-
const decoded = colCache.decodeAddress(range
|
|
2823
|
+
const decoded = colCache.decodeAddress(range);
|
|
2817
2824
|
tl = {
|
|
2818
2825
|
col: decoded.col - 1,
|
|
2819
2826
|
colOff: DEFAULT_COL_OFF,
|
|
@@ -2827,22 +2834,22 @@ var ExcelTS = (function(exports) {
|
|
|
2827
2834
|
rowOff: DEFAULT_END_ROW_OFF
|
|
2828
2835
|
};
|
|
2829
2836
|
}
|
|
2830
|
-
else if ("startCol" in range
|
|
2837
|
+
else if ("startCol" in range) {
|
|
2831
2838
|
tl = {
|
|
2832
|
-
col: range
|
|
2833
|
-
colOff: range
|
|
2834
|
-
row: range
|
|
2835
|
-
rowOff: range
|
|
2839
|
+
col: range.startCol,
|
|
2840
|
+
colOff: range.startColOff ?? DEFAULT_COL_OFF,
|
|
2841
|
+
row: range.startRow,
|
|
2842
|
+
rowOff: range.startRowOff ?? DEFAULT_ROW_OFF
|
|
2836
2843
|
};
|
|
2837
2844
|
br = {
|
|
2838
|
-
col: range
|
|
2839
|
-
colOff: range
|
|
2840
|
-
row: range
|
|
2841
|
-
rowOff: range
|
|
2845
|
+
col: range.endCol,
|
|
2846
|
+
colOff: range.endColOff ?? DEFAULT_END_COL_OFF,
|
|
2847
|
+
row: range.endRow,
|
|
2848
|
+
rowOff: range.endRowOff ?? DEFAULT_END_ROW_OFF
|
|
2842
2849
|
};
|
|
2843
2850
|
} else {
|
|
2844
|
-
if (typeof range
|
|
2845
|
-
const decoded = colCache.decodeAddress(range
|
|
2851
|
+
if (typeof range.tl === "string") {
|
|
2852
|
+
const decoded = colCache.decodeAddress(range.tl);
|
|
2846
2853
|
tl = {
|
|
2847
2854
|
col: decoded.col - 1,
|
|
2848
2855
|
colOff: DEFAULT_COL_OFF,
|
|
@@ -2850,13 +2857,13 @@ var ExcelTS = (function(exports) {
|
|
|
2850
2857
|
rowOff: DEFAULT_ROW_OFF
|
|
2851
2858
|
};
|
|
2852
2859
|
} else tl = {
|
|
2853
|
-
col: range
|
|
2854
|
-
colOff: range
|
|
2855
|
-
row: range
|
|
2856
|
-
rowOff: range
|
|
2860
|
+
col: range.tl.col,
|
|
2861
|
+
colOff: range.tl.colOff ?? DEFAULT_COL_OFF,
|
|
2862
|
+
row: range.tl.row,
|
|
2863
|
+
rowOff: range.tl.rowOff ?? DEFAULT_ROW_OFF
|
|
2857
2864
|
};
|
|
2858
|
-
if (range
|
|
2859
|
-
const decoded = colCache.decodeAddress(range
|
|
2865
|
+
if (range.br) if (typeof range.br === "string") {
|
|
2866
|
+
const decoded = colCache.decodeAddress(range.br);
|
|
2860
2867
|
br = {
|
|
2861
2868
|
col: decoded.col - 1,
|
|
2862
2869
|
colOff: DEFAULT_END_COL_OFF,
|
|
@@ -2864,10 +2871,10 @@ var ExcelTS = (function(exports) {
|
|
|
2864
2871
|
rowOff: DEFAULT_END_ROW_OFF
|
|
2865
2872
|
};
|
|
2866
2873
|
} else br = {
|
|
2867
|
-
col: range
|
|
2868
|
-
colOff: range
|
|
2869
|
-
row: range
|
|
2870
|
-
rowOff: range
|
|
2874
|
+
col: range.br.col,
|
|
2875
|
+
colOff: range.br.colOff ?? DEFAULT_END_COL_OFF,
|
|
2876
|
+
row: range.br.row,
|
|
2877
|
+
rowOff: range.br.rowOff ?? DEFAULT_END_ROW_OFF
|
|
2871
2878
|
};
|
|
2872
2879
|
else br = {
|
|
2873
2880
|
col: tl.col + 2,
|
|
@@ -3080,9 +3087,9 @@ var ExcelTS = (function(exports) {
|
|
|
3080
3087
|
if (latin1Decoder) try {
|
|
3081
3088
|
return btoa(latin1Decoder.decode(bytes));
|
|
3082
3089
|
} catch {}
|
|
3083
|
-
const CHUNK_SIZE
|
|
3090
|
+
const CHUNK_SIZE = 32768;
|
|
3084
3091
|
const chunks = [];
|
|
3085
|
-
for (let i = 0; i < bytes.length; i += CHUNK_SIZE
|
|
3092
|
+
for (let i = 0; i < bytes.length; i += CHUNK_SIZE) chunks.push(String.fromCharCode.apply(null, bytes.subarray(i, i + CHUNK_SIZE)));
|
|
3086
3093
|
return btoa(chunks.join(""));
|
|
3087
3094
|
}
|
|
3088
3095
|
/**
|
|
@@ -3512,11 +3519,11 @@ var ExcelTS = (function(exports) {
|
|
|
3512
3519
|
this._didRead = true;
|
|
3513
3520
|
if (this._bufferedLength() > 0) {
|
|
3514
3521
|
if (this.objectMode || size === void 0) {
|
|
3515
|
-
const chunk
|
|
3516
|
-
if (!this.objectMode) this._bufferSize -= this._getChunkSize(chunk
|
|
3517
|
-
const decoded
|
|
3522
|
+
const chunk = this._bufferShift();
|
|
3523
|
+
if (!this.objectMode) this._bufferSize -= this._getChunkSize(chunk);
|
|
3524
|
+
const decoded = this._applyEncoding(chunk);
|
|
3518
3525
|
if (this._ended && this._bufferedLength() === 0) queueMicrotask(() => this._emitEndOnce());
|
|
3519
|
-
return decoded
|
|
3526
|
+
return decoded;
|
|
3520
3527
|
}
|
|
3521
3528
|
const chunk = this._bufferShift();
|
|
3522
3529
|
if (!this.objectMode) this._bufferSize -= this._getChunkSize(chunk);
|
|
@@ -3924,8 +3931,8 @@ var ExcelTS = (function(exports) {
|
|
|
3924
3931
|
while (true) {
|
|
3925
3932
|
if (streamError) throw streamError;
|
|
3926
3933
|
if (dataQueueIndex < dataQueue.length) {
|
|
3927
|
-
const chunk
|
|
3928
|
-
queuedSize -= chunkSizeForBackpressure(chunk
|
|
3934
|
+
const chunk = dataQueue[dataQueueIndex++];
|
|
3935
|
+
queuedSize -= chunkSizeForBackpressure(chunk);
|
|
3929
3936
|
if (dataQueueIndex >= 1024 && dataQueueIndex * 2 >= dataQueue.length) {
|
|
3930
3937
|
dataQueue.splice(0, dataQueueIndex);
|
|
3931
3938
|
dataQueueIndex = 0;
|
|
@@ -3934,7 +3941,7 @@ var ExcelTS = (function(exports) {
|
|
|
3934
3941
|
pausedByIterator = false;
|
|
3935
3942
|
this.resume();
|
|
3936
3943
|
}
|
|
3937
|
-
yield chunk
|
|
3944
|
+
yield chunk;
|
|
3938
3945
|
continue;
|
|
3939
3946
|
}
|
|
3940
3947
|
if (done) break;
|
|
@@ -3951,7 +3958,6 @@ var ExcelTS = (function(exports) {
|
|
|
3951
3958
|
yield chunk;
|
|
3952
3959
|
}
|
|
3953
3960
|
}
|
|
3954
|
-
if (streamError) throw streamError;
|
|
3955
3961
|
} finally {
|
|
3956
3962
|
this.off("data", dataHandler);
|
|
3957
3963
|
this.off("end", endHandler);
|
|
@@ -6044,8 +6050,8 @@ var ExcelTS = (function(exports) {
|
|
|
6044
6050
|
}
|
|
6045
6051
|
}
|
|
6046
6052
|
}
|
|
6047
|
-
fillFormula(range
|
|
6048
|
-
const { top, left, bottom, right } = colCache.decode(range
|
|
6053
|
+
fillFormula(range, formula, results, shareType = "shared") {
|
|
6054
|
+
const { top, left, bottom, right } = colCache.decode(range);
|
|
6049
6055
|
const width = right - left + 1;
|
|
6050
6056
|
const masterAddress = colCache.encodeAddress(top, left);
|
|
6051
6057
|
const isShared = shareType === "shared";
|
|
@@ -6060,7 +6066,7 @@ var ExcelTS = (function(exports) {
|
|
|
6060
6066
|
cell.value = {
|
|
6061
6067
|
shareType,
|
|
6062
6068
|
formula,
|
|
6063
|
-
ref: range
|
|
6069
|
+
ref: range,
|
|
6064
6070
|
result: getResult(r, c)
|
|
6065
6071
|
};
|
|
6066
6072
|
first = false;
|
|
@@ -6073,11 +6079,11 @@ var ExcelTS = (function(exports) {
|
|
|
6073
6079
|
* Using the image id from `Workbook.addImage`,
|
|
6074
6080
|
* embed an image within the worksheet to cover a range
|
|
6075
6081
|
*/
|
|
6076
|
-
addImage(imageId, range
|
|
6082
|
+
addImage(imageId, range) {
|
|
6077
6083
|
const model = {
|
|
6078
6084
|
type: "image",
|
|
6079
6085
|
imageId: String(imageId),
|
|
6080
|
-
range
|
|
6086
|
+
range
|
|
6081
6087
|
};
|
|
6082
6088
|
this._media.push(new Image(this, model));
|
|
6083
6089
|
}
|
|
@@ -6122,8 +6128,8 @@ var ExcelTS = (function(exports) {
|
|
|
6122
6128
|
* checked: false
|
|
6123
6129
|
* });
|
|
6124
6130
|
*/
|
|
6125
|
-
addFormCheckbox(range
|
|
6126
|
-
const checkbox = new FormCheckbox(this, range
|
|
6131
|
+
addFormCheckbox(range, options) {
|
|
6132
|
+
const checkbox = new FormCheckbox(this, range, options);
|
|
6127
6133
|
this.formControls.push(checkbox);
|
|
6128
6134
|
return checkbox;
|
|
6129
6135
|
}
|
|
@@ -6217,7 +6223,8 @@ var ExcelTS = (function(exports) {
|
|
|
6217
6223
|
tables: Object.values(this.tables).map((table) => table.model),
|
|
6218
6224
|
pivotTables: this.pivotTables,
|
|
6219
6225
|
conditionalFormattings: this.conditionalFormattings,
|
|
6220
|
-
formControls: this.formControls.map((fc) => fc.model)
|
|
6226
|
+
formControls: this.formControls.map((fc) => fc.model),
|
|
6227
|
+
drawing: this._drawing
|
|
6221
6228
|
};
|
|
6222
6229
|
model.cols = Column.toModel(this.columns || []);
|
|
6223
6230
|
const rows = model.rows = [];
|
|
@@ -6272,6 +6279,7 @@ var ExcelTS = (function(exports) {
|
|
|
6272
6279
|
this.pivotTables = value.pivotTables;
|
|
6273
6280
|
this.conditionalFormattings = value.conditionalFormattings;
|
|
6274
6281
|
this.formControls = [];
|
|
6282
|
+
this._drawing = value.drawing;
|
|
6275
6283
|
}
|
|
6276
6284
|
};
|
|
6277
6285
|
|
|
@@ -6470,7 +6478,7 @@ var ExcelTS = (function(exports) {
|
|
|
6470
6478
|
_explore(matrix, cell) {
|
|
6471
6479
|
cell.mark = false;
|
|
6472
6480
|
const { sheetName } = cell;
|
|
6473
|
-
const range
|
|
6481
|
+
const range = new Range(cell.row, cell.col, cell.row, cell.col, sheetName);
|
|
6474
6482
|
let x;
|
|
6475
6483
|
let y;
|
|
6476
6484
|
const getCell = (row, col) => {
|
|
@@ -6479,7 +6487,7 @@ var ExcelTS = (function(exports) {
|
|
|
6479
6487
|
function vGrow(yy, edge) {
|
|
6480
6488
|
const c = getCell(yy, cell.col);
|
|
6481
6489
|
if (!c || !c.mark) return false;
|
|
6482
|
-
range
|
|
6490
|
+
range[edge] = yy;
|
|
6483
6491
|
c.mark = false;
|
|
6484
6492
|
return true;
|
|
6485
6493
|
}
|
|
@@ -6487,18 +6495,18 @@ var ExcelTS = (function(exports) {
|
|
|
6487
6495
|
for (y = cell.row + 1; vGrow(y, "bottom"); y++);
|
|
6488
6496
|
function hGrow(xx, edge) {
|
|
6489
6497
|
const cells = [];
|
|
6490
|
-
for (y = range
|
|
6498
|
+
for (y = range.top; y <= range.bottom; y++) {
|
|
6491
6499
|
const c = getCell(y, xx);
|
|
6492
6500
|
if (c && c.mark) cells.push(c);
|
|
6493
6501
|
else return false;
|
|
6494
6502
|
}
|
|
6495
|
-
range
|
|
6503
|
+
range[edge] = xx;
|
|
6496
6504
|
for (let i = 0; i < cells.length; i++) cells[i].mark = false;
|
|
6497
6505
|
return true;
|
|
6498
6506
|
}
|
|
6499
6507
|
for (x = cell.col - 1; hGrow(x, "left"); x--);
|
|
6500
6508
|
for (x = cell.col + 1; hGrow(x, "right"); x++);
|
|
6501
|
-
return range
|
|
6509
|
+
return range;
|
|
6502
6510
|
}
|
|
6503
6511
|
getRanges(name, matrix) {
|
|
6504
6512
|
matrix = matrix || this.matrixMap[name];
|
|
@@ -6511,7 +6519,7 @@ var ExcelTS = (function(exports) {
|
|
|
6511
6519
|
});
|
|
6512
6520
|
return {
|
|
6513
6521
|
name,
|
|
6514
|
-
ranges: matrix.map((cell) => cell.mark && this._explore(matrix, cell)).filter(Boolean).map((range
|
|
6522
|
+
ranges: matrix.map((cell) => cell.mark && this._explore(matrix, cell)).filter(Boolean).map((range) => range.$shortRange)
|
|
6515
6523
|
};
|
|
6516
6524
|
}
|
|
6517
6525
|
normaliseMatrix(matrix, sheetName) {
|
|
@@ -6764,8 +6772,6 @@ var ExcelTS = (function(exports) {
|
|
|
6764
6772
|
quot: "\"",
|
|
6765
6773
|
apos: "'"
|
|
6766
6774
|
};
|
|
6767
|
-
const HAN_CELL_PREFIXES = /^(ep|cp|dc|dcterms|dcmitype|vt):/;
|
|
6768
|
-
const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
6769
6775
|
const S_TEXT = 0;
|
|
6770
6776
|
const S_OPEN_WAKA = 1;
|
|
6771
6777
|
const S_OPEN_WAKA_BANG = 2;
|
|
@@ -6817,7 +6823,6 @@ var ExcelTS = (function(exports) {
|
|
|
6817
6823
|
this.positionAtNewLine = 0;
|
|
6818
6824
|
this.chunkPosition = 0;
|
|
6819
6825
|
this.ENTITIES = { ...XML_ENTITIES };
|
|
6820
|
-
this.nsPrefix = null;
|
|
6821
6826
|
this.trackPosition = opt?.position !== false;
|
|
6822
6827
|
this.fileName = opt?.fileName;
|
|
6823
6828
|
this.fragment = opt?.fragment ?? false;
|
|
@@ -6852,11 +6857,6 @@ var ExcelTS = (function(exports) {
|
|
|
6852
6857
|
this.chunk = "";
|
|
6853
6858
|
this.i = 0;
|
|
6854
6859
|
this.prevI = 0;
|
|
6855
|
-
this.nsPrefix = null;
|
|
6856
|
-
}
|
|
6857
|
-
stripNsPrefix(name) {
|
|
6858
|
-
const n = name.replace(HAN_CELL_PREFIXES, "");
|
|
6859
|
-
return this.nsPrefix && n.startsWith(this.nsPrefix + ":") ? n.slice(this.nsPrefix.length + 1) : n;
|
|
6860
6860
|
}
|
|
6861
6861
|
on(name, handler) {
|
|
6862
6862
|
switch (name) {
|
|
@@ -7196,7 +7196,7 @@ var ExcelTS = (function(exports) {
|
|
|
7196
7196
|
return;
|
|
7197
7197
|
}
|
|
7198
7198
|
this.tag = {
|
|
7199
|
-
name: this.
|
|
7199
|
+
name: this.name,
|
|
7200
7200
|
attributes: Object.create(null),
|
|
7201
7201
|
isSelfClosing: false
|
|
7202
7202
|
};
|
|
@@ -7492,7 +7492,8 @@ var ExcelTS = (function(exports) {
|
|
|
7492
7492
|
openTag() {
|
|
7493
7493
|
const tag = this.tag;
|
|
7494
7494
|
tag.isSelfClosing = false;
|
|
7495
|
-
this.
|
|
7495
|
+
for (const { name, value } of this.attribList) tag.attributes[name] = value;
|
|
7496
|
+
this.attribList = [];
|
|
7496
7497
|
this.openTagHandler?.(tag);
|
|
7497
7498
|
this.tags.push(tag);
|
|
7498
7499
|
this.name = "";
|
|
@@ -7501,26 +7502,16 @@ var ExcelTS = (function(exports) {
|
|
|
7501
7502
|
openSelfClosingTag() {
|
|
7502
7503
|
const tag = this.tag;
|
|
7503
7504
|
tag.isSelfClosing = true;
|
|
7504
|
-
this.
|
|
7505
|
+
for (const { name, value } of this.attribList) tag.attributes[name] = value;
|
|
7506
|
+
this.attribList = [];
|
|
7505
7507
|
this.openTagHandler?.(tag);
|
|
7506
7508
|
this.closeTagHandler?.(tag);
|
|
7507
7509
|
if (this.tags.length === 0) this.closedRoot = true;
|
|
7508
7510
|
this.name = "";
|
|
7509
7511
|
this.state = S_TEXT;
|
|
7510
7512
|
}
|
|
7511
|
-
processAttributes(tag) {
|
|
7512
|
-
for (const { name, value } of this.attribList) {
|
|
7513
|
-
tag.attributes[name] = value;
|
|
7514
|
-
if (name.startsWith("xmlns:") && value === SPREADSHEETML_NS) {
|
|
7515
|
-
this.nsPrefix = name.slice(6);
|
|
7516
|
-
tag.name = this.stripNsPrefix(tag.name);
|
|
7517
|
-
}
|
|
7518
|
-
}
|
|
7519
|
-
this.attribList = [];
|
|
7520
|
-
}
|
|
7521
7513
|
closeTag() {
|
|
7522
|
-
const { tags } = this;
|
|
7523
|
-
const name = this.stripNsPrefix(this.name);
|
|
7514
|
+
const { tags, name } = this;
|
|
7524
7515
|
this.state = S_TEXT;
|
|
7525
7516
|
this.name = "";
|
|
7526
7517
|
if (name === "") {
|
|
@@ -7595,6 +7586,30 @@ var ExcelTS = (function(exports) {
|
|
|
7595
7586
|
|
|
7596
7587
|
//#endregion
|
|
7597
7588
|
//#region src/modules/excel/xlsx/xform/base-xform.ts
|
|
7589
|
+
const HAN_CELL_PREFIXES = new Set([
|
|
7590
|
+
"ep",
|
|
7591
|
+
"cp",
|
|
7592
|
+
"dc",
|
|
7593
|
+
"dcterms",
|
|
7594
|
+
"dcmitype",
|
|
7595
|
+
"vt"
|
|
7596
|
+
]);
|
|
7597
|
+
const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
7598
|
+
function detectHanCellPrefix(tagName, attrs) {
|
|
7599
|
+
for (const key in attrs) if (key.length > 6 && key.startsWith("xmlns:")) {
|
|
7600
|
+
const prefix = key.slice(6);
|
|
7601
|
+
if (attrs[key] === SPREADSHEETML_NS) return prefix;
|
|
7602
|
+
if (HAN_CELL_PREFIXES.has(prefix)) return null;
|
|
7603
|
+
}
|
|
7604
|
+
const i = tagName.indexOf(":");
|
|
7605
|
+
return i !== -1 && HAN_CELL_PREFIXES.has(tagName.slice(0, i)) ? null : void 0;
|
|
7606
|
+
}
|
|
7607
|
+
function stripPrefix(name, nsPrefix) {
|
|
7608
|
+
const i = name.indexOf(":");
|
|
7609
|
+
if (i === -1) return name;
|
|
7610
|
+
const p = name.slice(0, i);
|
|
7611
|
+
return p === nsPrefix || HAN_CELL_PREFIXES.has(p) ? name.slice(i + 1) : name;
|
|
7612
|
+
}
|
|
7598
7613
|
var BaseXform = class BaseXform {
|
|
7599
7614
|
prepare(_model, _options) {}
|
|
7600
7615
|
render(_xmlStream, _model) {}
|
|
@@ -7606,9 +7621,9 @@ var ExcelTS = (function(exports) {
|
|
|
7606
7621
|
reconcile(_model, _options) {}
|
|
7607
7622
|
reset() {
|
|
7608
7623
|
this.model = null;
|
|
7609
|
-
if (this.map) Object.values(this.map).forEach((xform
|
|
7610
|
-
if (xform
|
|
7611
|
-
else if (xform
|
|
7624
|
+
if (this.map) Object.values(this.map).forEach((xform) => {
|
|
7625
|
+
if (xform instanceof BaseXform) xform.reset();
|
|
7626
|
+
else if (xform.xform) xform.xform.reset();
|
|
7612
7627
|
});
|
|
7613
7628
|
}
|
|
7614
7629
|
mergeModel(obj) {
|
|
@@ -7617,12 +7632,38 @@ var ExcelTS = (function(exports) {
|
|
|
7617
7632
|
async parse(saxParser) {
|
|
7618
7633
|
let done = false;
|
|
7619
7634
|
let finalModel;
|
|
7635
|
+
let nsMode = 0;
|
|
7636
|
+
let nsPrefix = null;
|
|
7620
7637
|
for await (const events of saxParser) {
|
|
7621
7638
|
if (done) continue;
|
|
7622
|
-
for (const { eventType, value } of events) if (eventType === "opentag")
|
|
7623
|
-
|
|
7639
|
+
for (const { eventType, value } of events) if (eventType === "opentag") {
|
|
7640
|
+
if (nsMode === 1) {
|
|
7641
|
+
this.parseOpen(value);
|
|
7642
|
+
continue;
|
|
7643
|
+
}
|
|
7644
|
+
if (nsMode === 0) {
|
|
7645
|
+
const prefix = detectHanCellPrefix(value.name, value.attributes);
|
|
7646
|
+
if (prefix === void 0) {
|
|
7647
|
+
nsMode = 1;
|
|
7648
|
+
this.parseOpen(value);
|
|
7649
|
+
continue;
|
|
7650
|
+
}
|
|
7651
|
+
nsMode = 2;
|
|
7652
|
+
nsPrefix = prefix;
|
|
7653
|
+
}
|
|
7654
|
+
value.name = stripPrefix(value.name, nsPrefix);
|
|
7655
|
+
this.parseOpen(value);
|
|
7656
|
+
} else if (eventType === "text") this.parseText(value);
|
|
7624
7657
|
else if (eventType === "closetag") {
|
|
7625
|
-
if (
|
|
7658
|
+
if (nsMode === 1) {
|
|
7659
|
+
if (!this.parseClose(value.name)) {
|
|
7660
|
+
done = true;
|
|
7661
|
+
finalModel = this.model;
|
|
7662
|
+
break;
|
|
7663
|
+
}
|
|
7664
|
+
continue;
|
|
7665
|
+
}
|
|
7666
|
+
if (!this.parseClose(stripPrefix(value.name, nsPrefix))) {
|
|
7626
7667
|
done = true;
|
|
7627
7668
|
finalModel = this.model;
|
|
7628
7669
|
break;
|
|
@@ -8972,12 +9013,13 @@ var ExcelTS = (function(exports) {
|
|
|
8972
9013
|
borderId: model.borderId || 0
|
|
8973
9014
|
});
|
|
8974
9015
|
if (this.xfId) xmlStream.addAttribute("xfId", model.xfId || 0);
|
|
8975
|
-
if (model.numFmtId) xmlStream.addAttribute("applyNumberFormat", "1");
|
|
8976
|
-
if (model.fontId) xmlStream.addAttribute("applyFont", "1");
|
|
8977
|
-
if (model.fillId) xmlStream.addAttribute("applyFill", "1");
|
|
8978
|
-
if (model.borderId) xmlStream.addAttribute("applyBorder", "1");
|
|
8979
|
-
if (model.alignment) xmlStream.addAttribute("applyAlignment", "1");
|
|
8980
|
-
if (model.protection) xmlStream.addAttribute("applyProtection", "1");
|
|
9016
|
+
if (model.applyNumberFormat || model.numFmtId) xmlStream.addAttribute("applyNumberFormat", "1");
|
|
9017
|
+
if (model.applyFont || model.fontId) xmlStream.addAttribute("applyFont", "1");
|
|
9018
|
+
if (model.applyFill || model.fillId) xmlStream.addAttribute("applyFill", "1");
|
|
9019
|
+
if (model.applyBorder || model.borderId) xmlStream.addAttribute("applyBorder", "1");
|
|
9020
|
+
if (model.applyAlignment || model.alignment) xmlStream.addAttribute("applyAlignment", "1");
|
|
9021
|
+
if (model.applyProtection || model.protection) xmlStream.addAttribute("applyProtection", "1");
|
|
9022
|
+
if (model.pivotButton) xmlStream.addAttribute("pivotButton", "1");
|
|
8981
9023
|
/**
|
|
8982
9024
|
* Rendering tags causes close of XML stream.
|
|
8983
9025
|
* Therefore adding attributes must be done before rendering tags.
|
|
@@ -9010,6 +9052,15 @@ var ExcelTS = (function(exports) {
|
|
|
9010
9052
|
borderId: parseInt(node.attributes.borderId, 10)
|
|
9011
9053
|
};
|
|
9012
9054
|
if (this.xfId) this.model.xfId = parseInt(node.attributes.xfId, 10);
|
|
9055
|
+
if (node.attributes.pivotButton === "1") this.model.pivotButton = true;
|
|
9056
|
+
for (const flag of [
|
|
9057
|
+
"applyNumberFormat",
|
|
9058
|
+
"applyFont",
|
|
9059
|
+
"applyFill",
|
|
9060
|
+
"applyBorder",
|
|
9061
|
+
"applyAlignment",
|
|
9062
|
+
"applyProtection"
|
|
9063
|
+
]) if (node.attributes[flag] === "1") this.model[flag] = true;
|
|
9013
9064
|
return true;
|
|
9014
9065
|
case "alignment":
|
|
9015
9066
|
this.parser = this.map.alignment;
|
|
@@ -9203,6 +9254,13 @@ var ExcelTS = (function(exports) {
|
|
|
9203
9254
|
this.weakMap = /* @__PURE__ */ new WeakMap();
|
|
9204
9255
|
this._hasCheckboxes = false;
|
|
9205
9256
|
}
|
|
9257
|
+
/**
|
|
9258
|
+
* Set the default font to use when no font is explicitly specified.
|
|
9259
|
+
* This preserves the original file's default font during round-trip.
|
|
9260
|
+
*/
|
|
9261
|
+
setDefaultFont(font) {
|
|
9262
|
+
this.defaultFont = font;
|
|
9263
|
+
}
|
|
9206
9264
|
render(xmlStream, model) {
|
|
9207
9265
|
const renderModel = model || this.model;
|
|
9208
9266
|
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
@@ -9215,7 +9273,7 @@ var ExcelTS = (function(exports) {
|
|
|
9215
9273
|
});
|
|
9216
9274
|
xmlStream.closeNode();
|
|
9217
9275
|
}
|
|
9218
|
-
if (!renderModel.fonts.length) this._addFont({
|
|
9276
|
+
if (!renderModel.fonts.length) this._addFont(this.defaultFont || {
|
|
9219
9277
|
size: 11,
|
|
9220
9278
|
color: { theme: 1 },
|
|
9221
9279
|
name: "Calibri",
|
|
@@ -9298,8 +9356,8 @@ var ExcelTS = (function(exports) {
|
|
|
9298
9356
|
switch (name) {
|
|
9299
9357
|
case "styleSheet": {
|
|
9300
9358
|
this.model = {};
|
|
9301
|
-
const add = (propName, xform
|
|
9302
|
-
if (xform
|
|
9359
|
+
const add = (propName, xform) => {
|
|
9360
|
+
if (xform.model && xform.model.length) this.model[propName] = xform.model;
|
|
9303
9361
|
};
|
|
9304
9362
|
add("numFmts", this.map.numFmts);
|
|
9305
9363
|
add("fonts", this.map.fonts);
|
|
@@ -9307,6 +9365,7 @@ var ExcelTS = (function(exports) {
|
|
|
9307
9365
|
add("borders", this.map.borders);
|
|
9308
9366
|
add("styles", this.map.cellXfs);
|
|
9309
9367
|
add("dxfs", this.map.dxfs);
|
|
9368
|
+
if (this.map.fonts.model && this.map.fonts.model.length > 0) this.defaultFont = this.map.fonts.model[0];
|
|
9310
9369
|
this.index = {
|
|
9311
9370
|
model: [],
|
|
9312
9371
|
numFmt: {}
|
|
@@ -9324,7 +9383,7 @@ var ExcelTS = (function(exports) {
|
|
|
9324
9383
|
}
|
|
9325
9384
|
addStyleModel(model, cellType) {
|
|
9326
9385
|
if (!model) return 0;
|
|
9327
|
-
if (!this.model.fonts.length) this._addFont({
|
|
9386
|
+
if (!this.model.fonts.length) this._addFont(this.defaultFont || {
|
|
9328
9387
|
size: 11,
|
|
9329
9388
|
color: { theme: 1 },
|
|
9330
9389
|
name: "Calibri",
|
|
@@ -9349,6 +9408,15 @@ var ExcelTS = (function(exports) {
|
|
|
9349
9408
|
if (model.fill) style.fillId = this._addFill(model.fill);
|
|
9350
9409
|
if (model.alignment) style.alignment = model.alignment;
|
|
9351
9410
|
if (model.protection) style.protection = model.protection;
|
|
9411
|
+
for (const flag of [
|
|
9412
|
+
"pivotButton",
|
|
9413
|
+
"applyNumberFormat",
|
|
9414
|
+
"applyFont",
|
|
9415
|
+
"applyFill",
|
|
9416
|
+
"applyBorder",
|
|
9417
|
+
"applyAlignment",
|
|
9418
|
+
"applyProtection"
|
|
9419
|
+
]) if (model[flag]) style[flag] = true;
|
|
9352
9420
|
if (type === Enums.ValueType.Checkbox) {
|
|
9353
9421
|
this._hasCheckboxes = true;
|
|
9354
9422
|
style.alignment = style.alignment || {};
|
|
@@ -9380,6 +9448,15 @@ var ExcelTS = (function(exports) {
|
|
|
9380
9448
|
addStyle("fill", this.model.fills, style.fillId);
|
|
9381
9449
|
if (style.alignment) model.alignment = style.alignment;
|
|
9382
9450
|
if (style.protection) model.protection = style.protection;
|
|
9451
|
+
for (const flag of [
|
|
9452
|
+
"pivotButton",
|
|
9453
|
+
"applyNumberFormat",
|
|
9454
|
+
"applyFont",
|
|
9455
|
+
"applyFill",
|
|
9456
|
+
"applyBorder",
|
|
9457
|
+
"applyAlignment",
|
|
9458
|
+
"applyProtection"
|
|
9459
|
+
]) if (style[flag]) model[flag] = true;
|
|
9383
9460
|
return model;
|
|
9384
9461
|
}
|
|
9385
9462
|
addDxfStyle(style) {
|
|
@@ -10407,28 +10484,26 @@ var ExcelTS = (function(exports) {
|
|
|
10407
10484
|
ContentType: "application/vnd.openxmlformats-officedocument.drawing+xml"
|
|
10408
10485
|
});
|
|
10409
10486
|
});
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
});
|
|
10421
|
-
}
|
|
10422
|
-
if (model.formControlRefs) {
|
|
10423
|
-
if (!model.commentRefs) xmlStream.leafNode("Default", {
|
|
10424
|
-
Extension: "vml",
|
|
10425
|
-
ContentType: "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
10426
|
-
});
|
|
10427
|
-
for (const ctrlPropId of model.formControlRefs) xmlStream.leafNode("Override", {
|
|
10428
|
-
PartName: toContentTypesPartName(ctrlPropPath(ctrlPropId)),
|
|
10429
|
-
ContentType: "application/vnd.ms-excel.controlproperties+xml"
|
|
10487
|
+
const hasComments = model.commentRefs && model.commentRefs.length > 0;
|
|
10488
|
+
const hasFormControls = model.formControlRefs && model.formControlRefs.length > 0;
|
|
10489
|
+
if (hasComments || hasFormControls) xmlStream.leafNode("Default", {
|
|
10490
|
+
Extension: "vml",
|
|
10491
|
+
ContentType: "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
10492
|
+
});
|
|
10493
|
+
if (hasComments) model.commentRefs.forEach(({ commentName }) => {
|
|
10494
|
+
xmlStream.leafNode("Override", {
|
|
10495
|
+
PartName: toContentTypesPartName(commentsPathFromName(commentName)),
|
|
10496
|
+
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
10430
10497
|
});
|
|
10431
|
-
}
|
|
10498
|
+
});
|
|
10499
|
+
if (hasFormControls) for (const ctrlPropId of model.formControlRefs) xmlStream.leafNode("Override", {
|
|
10500
|
+
PartName: toContentTypesPartName(ctrlPropPath(ctrlPropId)),
|
|
10501
|
+
ContentType: "application/vnd.ms-excel.controlproperties+xml"
|
|
10502
|
+
});
|
|
10503
|
+
if (model.passthroughContentTypes) for (const { partName, contentType } of model.passthroughContentTypes) xmlStream.leafNode("Override", {
|
|
10504
|
+
PartName: toContentTypesPartName(partName),
|
|
10505
|
+
ContentType: contentType
|
|
10506
|
+
});
|
|
10432
10507
|
xmlStream.leafNode("Override", {
|
|
10433
10508
|
PartName: toContentTypesPartName(OOXML_PATHS.docPropsCore),
|
|
10434
10509
|
ContentType: "application/vnd.openxmlformats-package.core-properties+xml"
|
|
@@ -10621,12 +10696,12 @@ var ExcelTS = (function(exports) {
|
|
|
10621
10696
|
const cellRangeRegexp = /^[$]?[A-Za-z]{1,3}[$]?\d+(:[$]?[A-Za-z]{1,3}[$]?\d+)?$/;
|
|
10622
10697
|
const rowRangeRegexp = /^[$]?\d+:[$]?\d+$/;
|
|
10623
10698
|
const colRangeRegexp = /^[$]?[A-Za-z]{1,3}:[$]?[A-Za-z]{1,3}$/;
|
|
10624
|
-
function isValidRange(range
|
|
10625
|
-
if (range
|
|
10626
|
-
const cellRef = range
|
|
10699
|
+
function isValidRange(range) {
|
|
10700
|
+
if (range.startsWith("{") || range.endsWith("}")) return false;
|
|
10701
|
+
const cellRef = range.split("!").pop() || "";
|
|
10627
10702
|
if (!cellRangeRegexp.test(cellRef) && !rowRangeRegexp.test(cellRef) && !colRangeRegexp.test(cellRef)) return false;
|
|
10628
10703
|
try {
|
|
10629
|
-
const decoded = colCache.decodeEx(range
|
|
10704
|
+
const decoded = colCache.decodeEx(range);
|
|
10630
10705
|
if ("row" in decoded && typeof decoded.row === "number" || "top" in decoded && typeof decoded.top === "number" || "left" in decoded && typeof decoded.left === "number") return true;
|
|
10631
10706
|
return false;
|
|
10632
10707
|
} catch {
|
|
@@ -10942,8 +11017,8 @@ var ExcelTS = (function(exports) {
|
|
|
10942
11017
|
worksheet = worksheets[definedName.localSheetId];
|
|
10943
11018
|
if (worksheet) {
|
|
10944
11019
|
if (!worksheet.pageSetup) worksheet.pageSetup = {};
|
|
10945
|
-
const range
|
|
10946
|
-
worksheet.pageSetup.printArea = worksheet.pageSetup.printArea ? `${worksheet.pageSetup.printArea}&&${range
|
|
11020
|
+
const range = colCache.decodeEx(definedName.ranges[0]);
|
|
11021
|
+
worksheet.pageSetup.printArea = worksheet.pageSetup.printArea ? `${worksheet.pageSetup.printArea}&&${range.dimensions}` : range.dimensions;
|
|
10947
11022
|
}
|
|
10948
11023
|
} else if (definedName.name === "_xlnm.Print_Titles") {
|
|
10949
11024
|
worksheet = worksheets[definedName.localSheetId];
|
|
@@ -10953,13 +11028,13 @@ var ExcelTS = (function(exports) {
|
|
|
10953
11028
|
const dollarRegex = /\$/g;
|
|
10954
11029
|
const rowRangeMatches = rangeString.match(/\$\d+:\$\d+/);
|
|
10955
11030
|
if (rowRangeMatches && rowRangeMatches.length) {
|
|
10956
|
-
const range
|
|
10957
|
-
worksheet.pageSetup.printTitlesRow = range
|
|
11031
|
+
const range = rowRangeMatches[0];
|
|
11032
|
+
worksheet.pageSetup.printTitlesRow = range.replace(dollarRegex, "");
|
|
10958
11033
|
}
|
|
10959
11034
|
const columnRangeMatches = rangeString.match(/\$[A-Z]+:\$[A-Z]+/);
|
|
10960
11035
|
if (columnRangeMatches && columnRangeMatches.length) {
|
|
10961
|
-
const range
|
|
10962
|
-
worksheet.pageSetup.printTitlesColumn = range
|
|
11036
|
+
const range = columnRangeMatches[0];
|
|
11037
|
+
worksheet.pageSetup.printTitlesColumn = range.replace(dollarRegex, "");
|
|
10963
11038
|
}
|
|
10964
11039
|
}
|
|
10965
11040
|
} else definedNames.push(definedName);
|
|
@@ -11023,8 +11098,8 @@ var ExcelTS = (function(exports) {
|
|
|
11023
11098
|
add(merge) {
|
|
11024
11099
|
if (this.merges[merge.master]) this.merges[merge.master].expandToAddress(merge.address);
|
|
11025
11100
|
else {
|
|
11026
|
-
const range
|
|
11027
|
-
this.merges[merge.master] = new Range(range
|
|
11101
|
+
const range = `${merge.master}:${merge.address}`;
|
|
11102
|
+
this.merges[merge.master] = new Range(range);
|
|
11028
11103
|
}
|
|
11029
11104
|
}
|
|
11030
11105
|
get mergeCells() {
|
|
@@ -11047,8 +11122,8 @@ var ExcelTS = (function(exports) {
|
|
|
11047
11122
|
});
|
|
11048
11123
|
}
|
|
11049
11124
|
getMasterAddress(address) {
|
|
11050
|
-
const range
|
|
11051
|
-
return range
|
|
11125
|
+
const range = this.hash[address];
|
|
11126
|
+
return range && range.tl;
|
|
11052
11127
|
}
|
|
11053
11128
|
};
|
|
11054
11129
|
|
|
@@ -11440,6 +11515,7 @@ var ExcelTS = (function(exports) {
|
|
|
11440
11515
|
xmlStream.addAttribute("s", model.styleId);
|
|
11441
11516
|
xmlStream.addAttribute("customFormat", "1");
|
|
11442
11517
|
}
|
|
11518
|
+
if (model.dyDescent !== void 0) xmlStream.addAttribute("x14ac:dyDescent", model.dyDescent);
|
|
11443
11519
|
if (model.outlineLevel) xmlStream.addAttribute("outlineLevel", model.outlineLevel);
|
|
11444
11520
|
if (model.collapsed) xmlStream.addAttribute("collapsed", "1");
|
|
11445
11521
|
const cellXform = this.map.c;
|
|
@@ -11469,6 +11545,7 @@ var ExcelTS = (function(exports) {
|
|
|
11469
11545
|
if (node.attributes.ht) model.height = parseFloat(node.attributes.ht);
|
|
11470
11546
|
if (node.attributes.outlineLevel) model.outlineLevel = parseInt(node.attributes.outlineLevel, 10);
|
|
11471
11547
|
if (parseBoolean(node.attributes.collapsed)) model.collapsed = true;
|
|
11548
|
+
if (node.attributes["x14ac:dyDescent"] !== void 0) model.dyDescent = parseFloat(node.attributes["x14ac:dyDescent"]);
|
|
11472
11549
|
return true;
|
|
11473
11550
|
}
|
|
11474
11551
|
this.parser = this.map[node.name];
|
|
@@ -11969,10 +12046,10 @@ var ExcelTS = (function(exports) {
|
|
|
11969
12046
|
defaultRowHeight: model.defaultRowHeight,
|
|
11970
12047
|
outlineLevelRow: model.outlineLevelRow || void 0,
|
|
11971
12048
|
outlineLevelCol: model.outlineLevelCol || void 0,
|
|
11972
|
-
"x14ac:dyDescent": model.dyDescent
|
|
12049
|
+
"x14ac:dyDescent": model.dyDescent !== void 0 && model.dyDescent !== 0 ? model.dyDescent : void 0
|
|
11973
12050
|
};
|
|
11974
12051
|
if (model.defaultColWidth) attributes.defaultColWidth = model.defaultColWidth;
|
|
11975
|
-
if (
|
|
12052
|
+
if (model.customHeight) attributes.customHeight = "1";
|
|
11976
12053
|
if (Object.values(attributes).some((value) => value !== void 0)) xmlStream.leafNode("sheetFormatPr", attributes);
|
|
11977
12054
|
}
|
|
11978
12055
|
}
|
|
@@ -11980,11 +12057,12 @@ var ExcelTS = (function(exports) {
|
|
|
11980
12057
|
if (node.name === "sheetFormatPr") {
|
|
11981
12058
|
this.model = {
|
|
11982
12059
|
defaultRowHeight: parseFloat(node.attributes.defaultRowHeight || "0"),
|
|
11983
|
-
dyDescent: parseFloat(node.attributes["x14ac:dyDescent"]
|
|
12060
|
+
dyDescent: node.attributes["x14ac:dyDescent"] !== void 0 ? parseFloat(node.attributes["x14ac:dyDescent"]) : void 0,
|
|
11984
12061
|
outlineLevelRow: parseInt(node.attributes.outlineLevelRow || "0", 10),
|
|
11985
12062
|
outlineLevelCol: parseInt(node.attributes.outlineLevelCol || "0", 10)
|
|
11986
12063
|
};
|
|
11987
12064
|
if (node.attributes.defaultColWidth) this.model.defaultColWidth = parseFloat(node.attributes.defaultColWidth);
|
|
12065
|
+
if (node.attributes.customHeight === "1") this.model.customHeight = true;
|
|
11988
12066
|
return true;
|
|
11989
12067
|
}
|
|
11990
12068
|
return false;
|
|
@@ -12027,8 +12105,8 @@ var ExcelTS = (function(exports) {
|
|
|
12027
12105
|
add("showRuler", "0", model.showRuler === false);
|
|
12028
12106
|
add("showRowColHeaders", "0", model.showRowColHeaders === false);
|
|
12029
12107
|
add("showGridLines", "0", model.showGridLines === false);
|
|
12030
|
-
add("zoomScale", model.zoomScale, model.zoomScale);
|
|
12031
|
-
add("zoomScaleNormal", model.zoomScaleNormal, model.zoomScaleNormal);
|
|
12108
|
+
add("zoomScale", model.zoomScale, model.zoomScale !== void 0 && model.zoomScale !== 100);
|
|
12109
|
+
add("zoomScaleNormal", model.zoomScaleNormal, model.zoomScaleNormal !== void 0 && model.zoomScaleNormal !== 100);
|
|
12032
12110
|
add("view", model.style, model.style);
|
|
12033
12111
|
let topLeftCell;
|
|
12034
12112
|
let xSplit;
|
|
@@ -12124,6 +12202,7 @@ var ExcelTS = (function(exports) {
|
|
|
12124
12202
|
model = this.model = {
|
|
12125
12203
|
workbookViewId: this.sheetView.workbookViewId,
|
|
12126
12204
|
rightToLeft: this.sheetView.rightToLeft,
|
|
12205
|
+
tabSelected: this.sheetView.tabSelected,
|
|
12127
12206
|
state: VIEW_STATES[this.pane.state] || "split",
|
|
12128
12207
|
xSplit: this.pane.xSplit,
|
|
12129
12208
|
ySplit: this.pane.ySplit,
|
|
@@ -12142,6 +12221,7 @@ var ExcelTS = (function(exports) {
|
|
|
12142
12221
|
model = this.model = {
|
|
12143
12222
|
workbookViewId: this.sheetView.workbookViewId,
|
|
12144
12223
|
rightToLeft: this.sheetView.rightToLeft,
|
|
12224
|
+
tabSelected: this.sheetView.tabSelected,
|
|
12145
12225
|
state: "normal",
|
|
12146
12226
|
showRuler: this.sheetView.showRuler,
|
|
12147
12227
|
showRowColHeaders: this.sheetView.showRowColHeaders,
|
|
@@ -13863,6 +13943,17 @@ var ExcelTS = (function(exports) {
|
|
|
13863
13943
|
vmlDrawing: `vmlDrawing${model.id}`
|
|
13864
13944
|
});
|
|
13865
13945
|
}
|
|
13946
|
+
if (model.drawing && model.drawing.anchors) {
|
|
13947
|
+
const drawing = model.drawing;
|
|
13948
|
+
drawing.rId = nextRid(rels);
|
|
13949
|
+
if (!drawing.name) drawing.name = `drawing${++options.drawingsCount}`;
|
|
13950
|
+
options.drawings.push(drawing);
|
|
13951
|
+
rels.push({
|
|
13952
|
+
Id: drawing.rId,
|
|
13953
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
|
|
13954
|
+
Target: drawingRelTargetFromWorksheet(drawing.name)
|
|
13955
|
+
});
|
|
13956
|
+
}
|
|
13866
13957
|
const drawingRelsHash = [];
|
|
13867
13958
|
let bookImage;
|
|
13868
13959
|
model.media.forEach((medium) => {
|
|
@@ -14016,7 +14107,8 @@ var ExcelTS = (function(exports) {
|
|
|
14016
14107
|
defaultRowHeight: model.properties.defaultRowHeight,
|
|
14017
14108
|
dyDescent: model.properties.dyDescent,
|
|
14018
14109
|
outlineLevelCol: model.properties.outlineLevelCol,
|
|
14019
|
-
outlineLevelRow: model.properties.outlineLevelRow
|
|
14110
|
+
outlineLevelRow: model.properties.outlineLevelRow,
|
|
14111
|
+
customHeight: model.properties.customHeight
|
|
14020
14112
|
} : void 0;
|
|
14021
14113
|
if (model.properties && model.properties.defaultColWidth) sheetFormatPropertiesModel.defaultColWidth = model.properties.defaultColWidth;
|
|
14022
14114
|
const sheetPropertiesModel = {
|
|
@@ -14112,8 +14204,8 @@ var ExcelTS = (function(exports) {
|
|
|
14112
14204
|
return true;
|
|
14113
14205
|
}
|
|
14114
14206
|
if (node.name === "worksheet") {
|
|
14115
|
-
Object.values(this.map).forEach((xform
|
|
14116
|
-
xform
|
|
14207
|
+
Object.values(this.map).forEach((xform) => {
|
|
14208
|
+
xform.reset();
|
|
14117
14209
|
});
|
|
14118
14210
|
return true;
|
|
14119
14211
|
}
|
|
@@ -14200,17 +14292,25 @@ var ExcelTS = (function(exports) {
|
|
|
14200
14292
|
const match = rels[model.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);
|
|
14201
14293
|
if (match) {
|
|
14202
14294
|
const drawingName = match[1];
|
|
14203
|
-
options.drawings[drawingName]
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14295
|
+
const drawing = options.drawings[drawingName];
|
|
14296
|
+
if (drawing) {
|
|
14297
|
+
model.drawing = {
|
|
14298
|
+
...drawing,
|
|
14299
|
+
name: drawingName,
|
|
14300
|
+
rels: options.drawingRels?.[drawingName] || drawing.rels || []
|
|
14301
|
+
};
|
|
14302
|
+
drawing.anchors.forEach((anchor) => {
|
|
14303
|
+
if (anchor.medium) {
|
|
14304
|
+
const image = {
|
|
14305
|
+
type: "image",
|
|
14306
|
+
imageId: anchor.medium.index,
|
|
14307
|
+
range: anchor.range,
|
|
14308
|
+
hyperlinks: anchor.picture.hyperlinks
|
|
14309
|
+
};
|
|
14310
|
+
model.media.push(image);
|
|
14311
|
+
}
|
|
14312
|
+
});
|
|
14313
|
+
}
|
|
14214
14314
|
}
|
|
14215
14315
|
}
|
|
14216
14316
|
const backgroundRel = model.background && rels[model.background.rId];
|
|
@@ -15962,18 +16062,27 @@ var ExcelTS = (function(exports) {
|
|
|
15962
16062
|
var PivotTableXform = class PivotTableXform extends BaseXform {
|
|
15963
16063
|
constructor() {
|
|
15964
16064
|
super();
|
|
16065
|
+
this.state = {
|
|
16066
|
+
inPivotFields: false,
|
|
16067
|
+
inRowFields: false,
|
|
16068
|
+
inColFields: false,
|
|
16069
|
+
inDataFields: false,
|
|
16070
|
+
inRowItems: false,
|
|
16071
|
+
inColItems: false,
|
|
16072
|
+
inLocation: false,
|
|
16073
|
+
inItems: false,
|
|
16074
|
+
inPivotTableStyleInfo: false,
|
|
16075
|
+
inChartFormats: false,
|
|
16076
|
+
inPivotArea: false
|
|
16077
|
+
};
|
|
16078
|
+
this.currentPivotField = null;
|
|
16079
|
+
this.currentRowItem = null;
|
|
16080
|
+
this.currentColItem = null;
|
|
16081
|
+
this.currentChartFormat = null;
|
|
16082
|
+
this.pivotAreaXmlBuffer = [];
|
|
16083
|
+
this.pivotAreaDepth = 0;
|
|
15965
16084
|
this.map = {};
|
|
15966
16085
|
this.model = null;
|
|
15967
|
-
this.inPivotFields = false;
|
|
15968
|
-
this.inRowFields = false;
|
|
15969
|
-
this.inColFields = false;
|
|
15970
|
-
this.inDataFields = false;
|
|
15971
|
-
this.inRowItems = false;
|
|
15972
|
-
this.inColItems = false;
|
|
15973
|
-
this.inLocation = false;
|
|
15974
|
-
this.currentPivotField = null;
|
|
15975
|
-
this.inItems = false;
|
|
15976
|
-
this.inPivotTableStyleInfo = false;
|
|
15977
16086
|
}
|
|
15978
16087
|
prepare(_model) {}
|
|
15979
16088
|
get tag() {
|
|
@@ -15981,16 +16090,15 @@ var ExcelTS = (function(exports) {
|
|
|
15981
16090
|
}
|
|
15982
16091
|
reset() {
|
|
15983
16092
|
this.model = null;
|
|
15984
|
-
this.
|
|
15985
|
-
|
|
15986
|
-
|
|
15987
|
-
this.inDataFields = false;
|
|
15988
|
-
this.inRowItems = false;
|
|
15989
|
-
this.inColItems = false;
|
|
15990
|
-
this.inLocation = false;
|
|
16093
|
+
Object.keys(this.state).forEach((key) => {
|
|
16094
|
+
this.state[key] = false;
|
|
16095
|
+
});
|
|
15991
16096
|
this.currentPivotField = null;
|
|
15992
|
-
this.
|
|
15993
|
-
this.
|
|
16097
|
+
this.currentRowItem = null;
|
|
16098
|
+
this.currentColItem = null;
|
|
16099
|
+
this.currentChartFormat = null;
|
|
16100
|
+
this.pivotAreaXmlBuffer = [];
|
|
16101
|
+
this.pivotAreaDepth = 0;
|
|
15994
16102
|
}
|
|
15995
16103
|
/**
|
|
15996
16104
|
* Render pivot table XML.
|
|
@@ -16089,8 +16197,7 @@ var ExcelTS = (function(exports) {
|
|
|
16089
16197
|
* Render loaded pivot table (preserving original structure)
|
|
16090
16198
|
*/
|
|
16091
16199
|
renderLoaded(xmlStream, model) {
|
|
16092
|
-
|
|
16093
|
-
xmlStream.openNode(this.tag, {
|
|
16200
|
+
const attrs = {
|
|
16094
16201
|
...PivotTableXform.PIVOT_TABLE_ATTRIBUTES,
|
|
16095
16202
|
name: model.name || "PivotTable1",
|
|
16096
16203
|
cacheId: model.cacheId,
|
|
@@ -16099,7 +16206,7 @@ var ExcelTS = (function(exports) {
|
|
|
16099
16206
|
applyFontFormats: model.applyFontFormats || "0",
|
|
16100
16207
|
applyPatternFormats: model.applyPatternFormats || "0",
|
|
16101
16208
|
applyAlignmentFormats: model.applyAlignmentFormats || "0",
|
|
16102
|
-
applyWidthHeightFormats: model.applyWidthHeightFormats
|
|
16209
|
+
applyWidthHeightFormats: model.applyWidthHeightFormats ?? "0",
|
|
16103
16210
|
dataCaption: model.dataCaption || "Values",
|
|
16104
16211
|
updatedVersion: model.updatedVersion || "8",
|
|
16105
16212
|
minRefreshableVersion: model.minRefreshableVersion || "3",
|
|
@@ -16107,10 +16214,15 @@ var ExcelTS = (function(exports) {
|
|
|
16107
16214
|
itemPrintTitles: model.itemPrintTitles ? "1" : "0",
|
|
16108
16215
|
createdVersion: model.createdVersion || "8",
|
|
16109
16216
|
indent: model.indent !== void 0 ? String(model.indent) : "0",
|
|
16110
|
-
compact: model.compact ? "1" : "0",
|
|
16111
|
-
compactData: model.compactData ? "1" : "0",
|
|
16112
16217
|
multipleFieldFilters: model.multipleFieldFilters ? "1" : "0"
|
|
16113
|
-
}
|
|
16218
|
+
};
|
|
16219
|
+
if (model.outline) attrs.outline = "1";
|
|
16220
|
+
if (model.outlineData) attrs.outlineData = "1";
|
|
16221
|
+
if (model.chartFormat !== void 0) attrs.chartFormat = String(model.chartFormat);
|
|
16222
|
+
if (model.compact) attrs.compact = "1";
|
|
16223
|
+
if (model.compactData) attrs.compactData = "1";
|
|
16224
|
+
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
16225
|
+
xmlStream.openNode(this.tag, attrs);
|
|
16114
16226
|
if (model.location) xmlStream.leafNode("location", {
|
|
16115
16227
|
ref: model.location.ref,
|
|
16116
16228
|
firstHeaderRow: model.location.firstHeaderRow,
|
|
@@ -16127,30 +16239,48 @@ var ExcelTS = (function(exports) {
|
|
|
16127
16239
|
for (const fieldIndex of model.rowFields) xmlStream.leafNode("field", { x: fieldIndex });
|
|
16128
16240
|
xmlStream.closeNode();
|
|
16129
16241
|
}
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16140
|
-
|
|
16141
|
-
|
|
16142
|
-
|
|
16242
|
+
if (model.rowItems && model.rowItems.length > 0) {
|
|
16243
|
+
xmlStream.openNode("rowItems", { count: model.rowItems.length });
|
|
16244
|
+
for (const item of model.rowItems) this.renderRowColItem(xmlStream, item);
|
|
16245
|
+
xmlStream.closeNode();
|
|
16246
|
+
} else xmlStream.writeXml("<rowItems count=\"1\"><i t=\"grand\"><x/></i></rowItems>");
|
|
16247
|
+
if (model.hasColFields || model.colFields.length > 0) {
|
|
16248
|
+
const colFieldCount = model.colFields.length === 0 ? 1 : model.colFields.length;
|
|
16249
|
+
xmlStream.openNode("colFields", { count: colFieldCount });
|
|
16250
|
+
if (model.colFields.length === 0) xmlStream.leafNode("field", { x: -2 });
|
|
16251
|
+
else for (const fieldIndex of model.colFields) xmlStream.leafNode("field", { x: fieldIndex });
|
|
16252
|
+
xmlStream.closeNode();
|
|
16253
|
+
}
|
|
16254
|
+
if (model.colItems && model.colItems.length > 0) {
|
|
16255
|
+
xmlStream.openNode("colItems", { count: model.colItems.length });
|
|
16256
|
+
for (const item of model.colItems) this.renderRowColItem(xmlStream, item);
|
|
16257
|
+
xmlStream.closeNode();
|
|
16258
|
+
} else xmlStream.writeXml("<colItems count=\"1\"><i t=\"grand\"><x/></i></colItems>");
|
|
16143
16259
|
if (model.dataFields.length > 0) {
|
|
16144
16260
|
xmlStream.openNode("dataFields", { count: model.dataFields.length });
|
|
16145
16261
|
for (const dataField of model.dataFields) {
|
|
16146
|
-
const
|
|
16262
|
+
const dfAttrs = {
|
|
16147
16263
|
name: dataField.name,
|
|
16148
16264
|
fld: dataField.fld,
|
|
16149
16265
|
baseField: dataField.baseField ?? 0,
|
|
16150
16266
|
baseItem: dataField.baseItem ?? 0
|
|
16151
16267
|
};
|
|
16152
|
-
if (dataField.subtotal && dataField.subtotal !== "sum")
|
|
16153
|
-
xmlStream.leafNode("dataField",
|
|
16268
|
+
if (dataField.subtotal && dataField.subtotal !== "sum") dfAttrs.subtotal = dataField.subtotal;
|
|
16269
|
+
xmlStream.leafNode("dataField", dfAttrs);
|
|
16270
|
+
}
|
|
16271
|
+
xmlStream.closeNode();
|
|
16272
|
+
}
|
|
16273
|
+
if (model.chartFormats && model.chartFormats.length > 0) {
|
|
16274
|
+
xmlStream.openNode("chartFormats", { count: model.chartFormats.length });
|
|
16275
|
+
for (const cf of model.chartFormats) {
|
|
16276
|
+
xmlStream.openNode("chartFormat", {
|
|
16277
|
+
chart: cf.chart,
|
|
16278
|
+
format: cf.format,
|
|
16279
|
+
series: cf.series ? "1" : void 0
|
|
16280
|
+
});
|
|
16281
|
+
if (cf.pivotAreaXml) xmlStream.writeXml(cf.pivotAreaXml);
|
|
16282
|
+
else xmlStream.writeXml(`<pivotArea type="data" outline="0" fieldPosition="0"><references count="1"><reference field="4294967294" count="1" selected="0"><x v="0"/></reference></references></pivotArea>`);
|
|
16283
|
+
xmlStream.closeNode();
|
|
16154
16284
|
}
|
|
16155
16285
|
xmlStream.closeNode();
|
|
16156
16286
|
}
|
|
@@ -16162,47 +16292,35 @@ var ExcelTS = (function(exports) {
|
|
|
16162
16292
|
showColStripes: "0",
|
|
16163
16293
|
showLastColumn: "1"
|
|
16164
16294
|
});
|
|
16165
|
-
xmlStream.writeXml(
|
|
16166
|
-
<extLst>
|
|
16167
|
-
<ext
|
|
16168
|
-
uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}"
|
|
16169
|
-
xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
16170
|
-
>
|
|
16171
|
-
<x14:pivotTableDefinition
|
|
16172
|
-
hideValuesRow="1"
|
|
16173
|
-
xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main"
|
|
16174
|
-
/>
|
|
16175
|
-
</ext>
|
|
16176
|
-
<ext
|
|
16177
|
-
uri="{747A6164-185A-40DC-8AA5-F01512510D54}"
|
|
16178
|
-
xmlns:xpdl="http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout"
|
|
16179
|
-
>
|
|
16180
|
-
<xpdl:pivotTableDefinition16
|
|
16181
|
-
EnabledSubtotalsDefault="0"
|
|
16182
|
-
SubtotalsOnTopDefault="0"
|
|
16183
|
-
/>
|
|
16184
|
-
</ext>
|
|
16185
|
-
</extLst>
|
|
16186
|
-
`);
|
|
16295
|
+
xmlStream.writeXml(`<extLst><ext uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:pivotTableDefinition hideValuesRow="1" xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main"/></ext><ext uri="{747A6164-185A-40DC-8AA5-F01512510D54}" xmlns:xpdl="http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout"><xpdl:pivotTableDefinition16/></ext></extLst>`);
|
|
16187
16296
|
xmlStream.closeNode();
|
|
16188
16297
|
}
|
|
16189
16298
|
/**
|
|
16299
|
+
* Render a row or column item element
|
|
16300
|
+
*/
|
|
16301
|
+
renderRowColItem(xmlStream, item) {
|
|
16302
|
+
const attrs = {};
|
|
16303
|
+
if (item.t) attrs.t = item.t;
|
|
16304
|
+
if (item.x && item.x.length > 0) {
|
|
16305
|
+
xmlStream.openNode("i", attrs);
|
|
16306
|
+
for (const x of item.x) if (x.v && x.v !== 0) xmlStream.leafNode("x", { v: x.v });
|
|
16307
|
+
else xmlStream.leafNode("x");
|
|
16308
|
+
xmlStream.closeNode();
|
|
16309
|
+
} else xmlStream.leafNode("i", attrs);
|
|
16310
|
+
}
|
|
16311
|
+
/**
|
|
16190
16312
|
* Render a loaded pivot field
|
|
16191
16313
|
*/
|
|
16192
16314
|
renderPivotFieldLoaded(xmlStream, field) {
|
|
16193
|
-
const attrs = {
|
|
16194
|
-
compact: field.compact ? "1" : "0",
|
|
16195
|
-
outline: field.outline ? "1" : "0",
|
|
16196
|
-
showAll: field.showAll ? "1" : "0",
|
|
16197
|
-
defaultSubtotal: field.defaultSubtotal ? "1" : "0"
|
|
16198
|
-
};
|
|
16315
|
+
const attrs = {};
|
|
16199
16316
|
if (field.axis) attrs.axis = field.axis;
|
|
16200
16317
|
if (field.dataField) attrs.dataField = "1";
|
|
16318
|
+
attrs.showAll = field.showAll ? "1" : "0";
|
|
16201
16319
|
if (field.items && field.items.length > 0) {
|
|
16202
16320
|
xmlStream.openNode("pivotField", attrs);
|
|
16203
16321
|
xmlStream.openNode("items", { count: field.items.length + 1 });
|
|
16204
16322
|
for (const itemIndex of field.items) xmlStream.leafNode("item", { x: itemIndex });
|
|
16205
|
-
xmlStream.writeXml("<item t=\"default\"
|
|
16323
|
+
xmlStream.writeXml("<item t=\"default\"/>");
|
|
16206
16324
|
xmlStream.closeNode();
|
|
16207
16325
|
xmlStream.closeNode();
|
|
16208
16326
|
} else xmlStream.leafNode("pivotField", attrs);
|
|
@@ -16236,6 +16354,12 @@ var ExcelTS = (function(exports) {
|
|
|
16236
16354
|
compact: attributes.compact === "1",
|
|
16237
16355
|
compactData: attributes.compactData === "1",
|
|
16238
16356
|
multipleFieldFilters: attributes.multipleFieldFilters === "1",
|
|
16357
|
+
outline: attributes.outline === "1",
|
|
16358
|
+
outlineData: attributes.outlineData === "1",
|
|
16359
|
+
chartFormat: attributes.chartFormat ? parseInt(attributes.chartFormat, 10) : void 0,
|
|
16360
|
+
rowItems: [],
|
|
16361
|
+
colItems: [],
|
|
16362
|
+
chartFormats: [],
|
|
16239
16363
|
isLoaded: true
|
|
16240
16364
|
};
|
|
16241
16365
|
break;
|
|
@@ -16248,10 +16372,10 @@ var ExcelTS = (function(exports) {
|
|
|
16248
16372
|
};
|
|
16249
16373
|
break;
|
|
16250
16374
|
case "pivotFields":
|
|
16251
|
-
this.inPivotFields = true;
|
|
16375
|
+
this.state.inPivotFields = true;
|
|
16252
16376
|
break;
|
|
16253
16377
|
case "pivotField":
|
|
16254
|
-
if (this.inPivotFields) this.currentPivotField = {
|
|
16378
|
+
if (this.state.inPivotFields) this.currentPivotField = {
|
|
16255
16379
|
axis: attributes.axis,
|
|
16256
16380
|
dataField: attributes.dataField === "1",
|
|
16257
16381
|
items: [],
|
|
@@ -16262,35 +16386,78 @@ var ExcelTS = (function(exports) {
|
|
|
16262
16386
|
};
|
|
16263
16387
|
break;
|
|
16264
16388
|
case "items":
|
|
16265
|
-
if (this.currentPivotField) this.inItems = true;
|
|
16389
|
+
if (this.currentPivotField) this.state.inItems = true;
|
|
16266
16390
|
break;
|
|
16267
16391
|
case "item":
|
|
16268
|
-
if (this.inItems && this.currentPivotField && attributes.x !== void 0) this.currentPivotField.items.push(parseInt(attributes.x, 10));
|
|
16392
|
+
if (this.state.inItems && this.currentPivotField && attributes.x !== void 0) this.currentPivotField.items.push(parseInt(attributes.x, 10));
|
|
16269
16393
|
break;
|
|
16270
16394
|
case "rowFields":
|
|
16271
|
-
this.inRowFields = true;
|
|
16395
|
+
this.state.inRowFields = true;
|
|
16272
16396
|
break;
|
|
16273
16397
|
case "colFields":
|
|
16274
|
-
this.inColFields = true;
|
|
16398
|
+
this.state.inColFields = true;
|
|
16399
|
+
if (this.model) this.model.hasColFields = true;
|
|
16275
16400
|
break;
|
|
16276
16401
|
case "dataFields":
|
|
16277
|
-
this.inDataFields = true;
|
|
16402
|
+
this.state.inDataFields = true;
|
|
16278
16403
|
break;
|
|
16279
16404
|
case "rowItems":
|
|
16280
|
-
this.inRowItems = true;
|
|
16405
|
+
this.state.inRowItems = true;
|
|
16281
16406
|
break;
|
|
16282
16407
|
case "colItems":
|
|
16283
|
-
this.inColItems = true;
|
|
16408
|
+
this.state.inColItems = true;
|
|
16409
|
+
break;
|
|
16410
|
+
case "i":
|
|
16411
|
+
if (this.state.inRowItems && this.model) this.currentRowItem = {
|
|
16412
|
+
t: attributes.t,
|
|
16413
|
+
x: []
|
|
16414
|
+
};
|
|
16415
|
+
else if (this.state.inColItems && this.model) this.currentColItem = {
|
|
16416
|
+
t: attributes.t,
|
|
16417
|
+
x: []
|
|
16418
|
+
};
|
|
16419
|
+
break;
|
|
16420
|
+
case "x":
|
|
16421
|
+
if (this.state.inPivotArea) {
|
|
16422
|
+
const xAttrs = Object.entries(attributes).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
16423
|
+
this.pivotAreaXmlBuffer.push(xAttrs ? `<x ${xAttrs}/>` : "<x/>");
|
|
16424
|
+
} else if (this.currentRowItem) this.currentRowItem.x.push({ v: attributes.v ? parseInt(attributes.v, 10) : 0 });
|
|
16425
|
+
else if (this.currentColItem) this.currentColItem.x.push({ v: attributes.v ? parseInt(attributes.v, 10) : 0 });
|
|
16426
|
+
break;
|
|
16427
|
+
case "chartFormats":
|
|
16428
|
+
this.state.inChartFormats = true;
|
|
16429
|
+
break;
|
|
16430
|
+
case "chartFormat":
|
|
16431
|
+
if (this.state.inChartFormats && this.model) this.currentChartFormat = {
|
|
16432
|
+
chart: attributes.chart ? parseInt(attributes.chart, 10) : 0,
|
|
16433
|
+
format: attributes.format ? parseInt(attributes.format, 10) : 0,
|
|
16434
|
+
series: attributes.series === "1"
|
|
16435
|
+
};
|
|
16436
|
+
break;
|
|
16437
|
+
case "pivotArea":
|
|
16438
|
+
if (this.currentChartFormat) {
|
|
16439
|
+
this.state.inPivotArea = true;
|
|
16440
|
+
const attrsStr = Object.entries(attributes).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
16441
|
+
this.pivotAreaXmlBuffer = [attrsStr ? `<pivotArea ${attrsStr}>` : "<pivotArea>"];
|
|
16442
|
+
}
|
|
16443
|
+
break;
|
|
16444
|
+
case "references":
|
|
16445
|
+
case "reference":
|
|
16446
|
+
if (this.state.inPivotArea) {
|
|
16447
|
+
this.pivotAreaDepth++;
|
|
16448
|
+
const attrsStr = Object.entries(attributes).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
16449
|
+
this.pivotAreaXmlBuffer.push(`<${name}${attrsStr ? " " + attrsStr : ""}>`);
|
|
16450
|
+
}
|
|
16284
16451
|
break;
|
|
16285
16452
|
case "field":
|
|
16286
16453
|
if (this.model) {
|
|
16287
16454
|
const fieldIndex = parseInt(attributes.x || "0", 10);
|
|
16288
|
-
if (this.inRowFields) this.model.rowFields.push(fieldIndex);
|
|
16289
|
-
else if (this.inColFields) this.model.colFields.push(fieldIndex);
|
|
16455
|
+
if (this.state.inRowFields) this.model.rowFields.push(fieldIndex);
|
|
16456
|
+
else if (this.state.inColFields) this.model.colFields.push(fieldIndex);
|
|
16290
16457
|
}
|
|
16291
16458
|
break;
|
|
16292
16459
|
case "dataField":
|
|
16293
|
-
if (this.inDataFields && this.model) this.model.dataFields.push({
|
|
16460
|
+
if (this.state.inDataFields && this.model) this.model.dataFields.push({
|
|
16294
16461
|
name: xmlDecode(attributes.name || ""),
|
|
16295
16462
|
fld: parseInt(attributes.fld || "0", 10),
|
|
16296
16463
|
baseField: attributes.baseField ? parseInt(attributes.baseField, 10) : 0,
|
|
@@ -16306,10 +16473,25 @@ var ExcelTS = (function(exports) {
|
|
|
16306
16473
|
}
|
|
16307
16474
|
parseText(_text) {}
|
|
16308
16475
|
parseClose(name) {
|
|
16476
|
+
if (this.state.inPivotArea) {
|
|
16477
|
+
if (name === "pivotArea") {
|
|
16478
|
+
this.pivotAreaXmlBuffer.push("</pivotArea>");
|
|
16479
|
+
if (this.currentChartFormat) this.currentChartFormat.pivotAreaXml = this.pivotAreaXmlBuffer.join("");
|
|
16480
|
+
this.state.inPivotArea = false;
|
|
16481
|
+
this.pivotAreaXmlBuffer = [];
|
|
16482
|
+
this.pivotAreaDepth = 0;
|
|
16483
|
+
return true;
|
|
16484
|
+
} else if (name === "references" || name === "reference") {
|
|
16485
|
+
this.pivotAreaXmlBuffer.push(`</${name}>`);
|
|
16486
|
+
this.pivotAreaDepth--;
|
|
16487
|
+
return true;
|
|
16488
|
+
}
|
|
16489
|
+
return true;
|
|
16490
|
+
}
|
|
16309
16491
|
switch (name) {
|
|
16310
16492
|
case this.tag: return false;
|
|
16311
16493
|
case "pivotFields":
|
|
16312
|
-
this.inPivotFields = false;
|
|
16494
|
+
this.state.inPivotFields = false;
|
|
16313
16495
|
break;
|
|
16314
16496
|
case "pivotField":
|
|
16315
16497
|
if (this.currentPivotField && this.model) {
|
|
@@ -16318,22 +16500,40 @@ var ExcelTS = (function(exports) {
|
|
|
16318
16500
|
}
|
|
16319
16501
|
break;
|
|
16320
16502
|
case "items":
|
|
16321
|
-
this.inItems = false;
|
|
16503
|
+
this.state.inItems = false;
|
|
16322
16504
|
break;
|
|
16323
16505
|
case "rowFields":
|
|
16324
|
-
this.inRowFields = false;
|
|
16506
|
+
this.state.inRowFields = false;
|
|
16325
16507
|
break;
|
|
16326
16508
|
case "colFields":
|
|
16327
|
-
this.inColFields = false;
|
|
16509
|
+
this.state.inColFields = false;
|
|
16328
16510
|
break;
|
|
16329
16511
|
case "dataFields":
|
|
16330
|
-
this.inDataFields = false;
|
|
16512
|
+
this.state.inDataFields = false;
|
|
16331
16513
|
break;
|
|
16332
16514
|
case "rowItems":
|
|
16333
|
-
this.inRowItems = false;
|
|
16515
|
+
this.state.inRowItems = false;
|
|
16334
16516
|
break;
|
|
16335
16517
|
case "colItems":
|
|
16336
|
-
this.inColItems = false;
|
|
16518
|
+
this.state.inColItems = false;
|
|
16519
|
+
break;
|
|
16520
|
+
case "i":
|
|
16521
|
+
if (this.currentRowItem && this.model) {
|
|
16522
|
+
this.model.rowItems.push(this.currentRowItem);
|
|
16523
|
+
this.currentRowItem = null;
|
|
16524
|
+
} else if (this.currentColItem && this.model) {
|
|
16525
|
+
this.model.colItems.push(this.currentColItem);
|
|
16526
|
+
this.currentColItem = null;
|
|
16527
|
+
}
|
|
16528
|
+
break;
|
|
16529
|
+
case "chartFormats":
|
|
16530
|
+
this.state.inChartFormats = false;
|
|
16531
|
+
break;
|
|
16532
|
+
case "chartFormat":
|
|
16533
|
+
if (this.currentChartFormat && this.model) {
|
|
16534
|
+
this.model.chartFormats.push(this.currentChartFormat);
|
|
16535
|
+
this.currentChartFormat = null;
|
|
16536
|
+
}
|
|
16337
16537
|
break;
|
|
16338
16538
|
}
|
|
16339
16539
|
return true;
|
|
@@ -16373,13 +16573,13 @@ var ExcelTS = (function(exports) {
|
|
|
16373
16573
|
function buildColItems(columns, cacheFields, valueCount) {
|
|
16374
16574
|
if (columns.length === 0) {
|
|
16375
16575
|
if (valueCount > 1) {
|
|
16376
|
-
const items
|
|
16377
|
-
for (let i = 0; i < valueCount; i++) if (i === 0) items
|
|
16378
|
-
else items
|
|
16379
|
-
items
|
|
16576
|
+
const items = [];
|
|
16577
|
+
for (let i = 0; i < valueCount; i++) if (i === 0) items.push("<i><x /></i>");
|
|
16578
|
+
else items.push(`<i><x v="${i}" /></i>`);
|
|
16579
|
+
items.push("<i t=\"grand\"><x /></i>");
|
|
16380
16580
|
return {
|
|
16381
|
-
count: items
|
|
16382
|
-
xml: items
|
|
16581
|
+
count: items.length,
|
|
16582
|
+
xml: items.join("\n ")
|
|
16383
16583
|
};
|
|
16384
16584
|
}
|
|
16385
16585
|
return {
|
|
@@ -17084,7 +17284,6 @@ var ExcelTS = (function(exports) {
|
|
|
17084
17284
|
switch (checked) {
|
|
17085
17285
|
case "Checked": return "1";
|
|
17086
17286
|
case "Mixed": return "2";
|
|
17087
|
-
case "Unchecked":
|
|
17088
17287
|
default: return "0";
|
|
17089
17288
|
}
|
|
17090
17289
|
}
|
|
@@ -17273,9 +17472,9 @@ var ExcelTS = (function(exports) {
|
|
|
17273
17472
|
read(size) {
|
|
17274
17473
|
if (size === 0) return null;
|
|
17275
17474
|
if (size === void 0 || size >= this.length) {
|
|
17276
|
-
const buf
|
|
17475
|
+
const buf = this.toBuffer();
|
|
17277
17476
|
this.iRead = this.iWrite;
|
|
17278
|
-
return buf
|
|
17477
|
+
return buf;
|
|
17279
17478
|
}
|
|
17280
17479
|
const buf = this.buffer.slice(this.iRead, this.iRead + size);
|
|
17281
17480
|
this.iRead += size;
|
|
@@ -17453,18 +17652,18 @@ var ExcelTS = (function(exports) {
|
|
|
17453
17652
|
*/
|
|
17454
17653
|
read(size) {
|
|
17455
17654
|
if (size) {
|
|
17456
|
-
const buffers
|
|
17655
|
+
const buffers = [];
|
|
17457
17656
|
let remaining = size;
|
|
17458
17657
|
while (remaining && this.buffers.length && !this.buffers[0].eod) {
|
|
17459
17658
|
const first = this.buffers[0];
|
|
17460
17659
|
const buffer = first.read(remaining);
|
|
17461
17660
|
if (buffer) {
|
|
17462
17661
|
remaining -= buffer.length;
|
|
17463
|
-
buffers
|
|
17662
|
+
buffers.push(buffer);
|
|
17464
17663
|
}
|
|
17465
17664
|
if (first.eod && first.full) this.buffers.shift();
|
|
17466
17665
|
}
|
|
17467
|
-
return concatUint8Arrays$1(buffers
|
|
17666
|
+
return concatUint8Arrays$1(buffers);
|
|
17468
17667
|
}
|
|
17469
17668
|
const buffers = this.buffers.map((buf) => buf.toBuffer()).filter(Boolean);
|
|
17470
17669
|
this.buffers = [];
|
|
@@ -17970,7 +18169,7 @@ var ExcelTS = (function(exports) {
|
|
|
17970
18169
|
const hdist = reader.readBits(5) + 1;
|
|
17971
18170
|
const hclen = reader.readBits(4) + 4;
|
|
17972
18171
|
const codeLengthLengths = new Uint8Array(19);
|
|
17973
|
-
for (let i
|
|
18172
|
+
for (let i = 0; i < hclen; i++) codeLengthLengths[CODE_LENGTH_ORDER[i]] = reader.readBits(3);
|
|
17974
18173
|
const codeLengthTree = buildHuffmanTree(codeLengthLengths, 19);
|
|
17975
18174
|
const allLengths = new Uint8Array(hlit + hdist);
|
|
17976
18175
|
let i = 0;
|
|
@@ -18432,7 +18631,7 @@ var ExcelTS = (function(exports) {
|
|
|
18432
18631
|
const c = this._chunks[0];
|
|
18433
18632
|
const start = this._headOffset;
|
|
18434
18633
|
const end = start + length;
|
|
18435
|
-
const out
|
|
18634
|
+
const out = c.subarray(start, end);
|
|
18436
18635
|
this._headOffset = end;
|
|
18437
18636
|
this._length -= length;
|
|
18438
18637
|
if (this._length === 0) {
|
|
@@ -18442,7 +18641,7 @@ var ExcelTS = (function(exports) {
|
|
|
18442
18641
|
this._chunks.shift();
|
|
18443
18642
|
this._headOffset = 0;
|
|
18444
18643
|
}
|
|
18445
|
-
return out
|
|
18644
|
+
return out;
|
|
18446
18645
|
}
|
|
18447
18646
|
const out = new Uint8Array(length);
|
|
18448
18647
|
let outOffset = 0;
|
|
@@ -18624,10 +18823,10 @@ var ExcelTS = (function(exports) {
|
|
|
18624
18823
|
}
|
|
18625
18824
|
/** Peek a little-endian uint32 at `offset` without consuming bytes. Returns null if not enough bytes. */
|
|
18626
18825
|
peekUint32LE(offset) {
|
|
18627
|
-
const off
|
|
18628
|
-
if (off
|
|
18826
|
+
const off = offset | 0;
|
|
18827
|
+
if (off < 0 || off + 4 > this._length) return null;
|
|
18629
18828
|
const chunks = this._chunks;
|
|
18630
|
-
let remaining = off
|
|
18829
|
+
let remaining = off;
|
|
18631
18830
|
for (let i = 0; i < chunks.length; i++) {
|
|
18632
18831
|
const c = chunks[i];
|
|
18633
18832
|
const start = i === 0 ? this._headOffset : 0;
|
|
@@ -18635,11 +18834,11 @@ var ExcelTS = (function(exports) {
|
|
|
18635
18834
|
if (remaining < avail) {
|
|
18636
18835
|
const idx = start + remaining;
|
|
18637
18836
|
if (idx + 4 <= c.length) {
|
|
18638
|
-
const b0
|
|
18639
|
-
const b1
|
|
18640
|
-
const b2
|
|
18641
|
-
const b3
|
|
18642
|
-
return (b0
|
|
18837
|
+
const b0 = c[idx] | 0;
|
|
18838
|
+
const b1 = c[idx + 1] | 0;
|
|
18839
|
+
const b2 = c[idx + 2] | 0;
|
|
18840
|
+
const b3 = c[idx + 3] | 0;
|
|
18841
|
+
return (b0 | b1 << 8 | b2 << 16 | b3 << 24) >>> 0;
|
|
18643
18842
|
}
|
|
18644
18843
|
const b0 = c[idx] | 0;
|
|
18645
18844
|
let b1 = 0;
|
|
@@ -18668,9 +18867,9 @@ var ExcelTS = (function(exports) {
|
|
|
18668
18867
|
}
|
|
18669
18868
|
/** Peek a single byte at `offset` without consuming bytes. */
|
|
18670
18869
|
peekByte(offset) {
|
|
18671
|
-
const off
|
|
18672
|
-
if (off
|
|
18673
|
-
let remaining = off
|
|
18870
|
+
const off = offset | 0;
|
|
18871
|
+
if (off < 0 || off >= this._length) throw new RangeError("ByteQueue: peek beyond available data");
|
|
18872
|
+
let remaining = off;
|
|
18674
18873
|
for (let i = 0; i < this._chunks.length; i++) {
|
|
18675
18874
|
const c = this._chunks[i];
|
|
18676
18875
|
const start = i === 0 ? this._headOffset : 0;
|
|
@@ -18954,9 +19153,9 @@ var ExcelTS = (function(exports) {
|
|
|
18954
19153
|
}
|
|
18955
19154
|
};
|
|
18956
19155
|
var BufferedCodec = class extends EventEmitter {
|
|
18957
|
-
constructor(process
|
|
19156
|
+
constructor(process) {
|
|
18958
19157
|
super();
|
|
18959
|
-
this.process = process
|
|
19158
|
+
this.process = process;
|
|
18960
19159
|
this.chunks = [];
|
|
18961
19160
|
this.ended = false;
|
|
18962
19161
|
}
|
|
@@ -19564,27 +19763,27 @@ var ExcelTS = (function(exports) {
|
|
|
19564
19763
|
}
|
|
19565
19764
|
_pushUnchained(data, final, callback) {
|
|
19566
19765
|
if (this._finalized) {
|
|
19567
|
-
const promise
|
|
19568
|
-
this._tapCallback(promise
|
|
19569
|
-
return promise
|
|
19766
|
+
const promise = Promise.reject(/* @__PURE__ */ new Error("Cannot push to finalized ZipDeflateFile"));
|
|
19767
|
+
this._tapCallback(promise, callback);
|
|
19768
|
+
return promise;
|
|
19570
19769
|
}
|
|
19571
19770
|
if (this._deflateWanted === null) {
|
|
19572
19771
|
this._accumulateSample(data);
|
|
19573
19772
|
if (!this._shouldDecide(final)) {
|
|
19574
19773
|
if (data.length > 0) this._pendingChunks.push(data);
|
|
19575
|
-
const promise
|
|
19576
|
-
this._tapCallback(promise
|
|
19577
|
-
return promise
|
|
19774
|
+
const promise = Promise.resolve();
|
|
19775
|
+
this._tapCallback(promise, callback);
|
|
19776
|
+
return promise;
|
|
19578
19777
|
}
|
|
19579
19778
|
this._decideCompressionIfNeeded(final);
|
|
19580
19779
|
this._emitHeaderIfNeeded();
|
|
19581
19780
|
const hadPendingChunks = this._pendingChunks.length > 0;
|
|
19582
19781
|
const flushPromise = this._flushPendingChunks();
|
|
19583
|
-
let writePromise
|
|
19584
|
-
if (data.length > 0) writePromise
|
|
19585
|
-
const promise
|
|
19586
|
-
this._tapCallback(promise
|
|
19587
|
-
return promise
|
|
19782
|
+
let writePromise = flushPromise;
|
|
19783
|
+
if (data.length > 0) writePromise = hadPendingChunks ? flushPromise.then(() => this._writeData(data)) : this._writeData(data);
|
|
19784
|
+
const promise = final ? this._finalizeAfterWrite(writePromise) : writePromise;
|
|
19785
|
+
this._tapCallback(promise, callback);
|
|
19786
|
+
return promise;
|
|
19588
19787
|
}
|
|
19589
19788
|
this._emitHeaderIfNeeded();
|
|
19590
19789
|
const writePromise = this._writeData(data);
|
|
@@ -20206,6 +20405,115 @@ var ExcelTS = (function(exports) {
|
|
|
20206
20405
|
}
|
|
20207
20406
|
};
|
|
20208
20407
|
|
|
20408
|
+
//#endregion
|
|
20409
|
+
//#region src/modules/excel/utils/passthrough-manager.ts
|
|
20410
|
+
/**
|
|
20411
|
+
* Content type definitions for passthrough files
|
|
20412
|
+
*/
|
|
20413
|
+
const PASSTHROUGH_CONTENT_TYPES = new Map([
|
|
20414
|
+
[/^xl\/charts\/chart\d+\.xml$/, "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"],
|
|
20415
|
+
[/^xl\/charts\/style\d+\.xml$/, "application/vnd.ms-office.chartstyle+xml"],
|
|
20416
|
+
[/^xl\/charts\/colors\d+\.xml$/, "application/vnd.ms-office.chartcolorstyle+xml"]
|
|
20417
|
+
]);
|
|
20418
|
+
/**
|
|
20419
|
+
* Passthrough path prefixes that should be preserved
|
|
20420
|
+
*/
|
|
20421
|
+
const PASSTHROUGH_PREFIXES = ["xl/charts/"];
|
|
20422
|
+
/**
|
|
20423
|
+
* PassthroughManager handles storage and retrieval of passthrough files
|
|
20424
|
+
* that need to be preserved during Excel read/write cycles.
|
|
20425
|
+
*/
|
|
20426
|
+
var PassthroughManager = class PassthroughManager {
|
|
20427
|
+
constructor() {
|
|
20428
|
+
this.files = /* @__PURE__ */ new Map();
|
|
20429
|
+
}
|
|
20430
|
+
/**
|
|
20431
|
+
* Check if a path should be treated as passthrough
|
|
20432
|
+
*/
|
|
20433
|
+
static isPassthroughPath(path) {
|
|
20434
|
+
return PASSTHROUGH_PREFIXES.some((prefix) => path.startsWith(prefix));
|
|
20435
|
+
}
|
|
20436
|
+
/**
|
|
20437
|
+
* Get the content type for a passthrough file path
|
|
20438
|
+
* @returns Content type string or undefined if unknown
|
|
20439
|
+
*/
|
|
20440
|
+
static getContentType(path) {
|
|
20441
|
+
if (path.startsWith("xl/charts/_rels/")) return;
|
|
20442
|
+
for (const [regex, contentType] of PASSTHROUGH_CONTENT_TYPES) if (regex.test(path)) return contentType;
|
|
20443
|
+
}
|
|
20444
|
+
/**
|
|
20445
|
+
* Add a file to passthrough storage
|
|
20446
|
+
*/
|
|
20447
|
+
add(path, data) {
|
|
20448
|
+
this.files.set(path, data);
|
|
20449
|
+
}
|
|
20450
|
+
/**
|
|
20451
|
+
* Get a file from passthrough storage
|
|
20452
|
+
*/
|
|
20453
|
+
get(path) {
|
|
20454
|
+
return this.files.get(path);
|
|
20455
|
+
}
|
|
20456
|
+
/**
|
|
20457
|
+
* Check if a file exists in passthrough storage
|
|
20458
|
+
*/
|
|
20459
|
+
has(path) {
|
|
20460
|
+
return this.files.has(path);
|
|
20461
|
+
}
|
|
20462
|
+
/**
|
|
20463
|
+
* Get all stored paths
|
|
20464
|
+
*/
|
|
20465
|
+
getPaths() {
|
|
20466
|
+
return [...this.files.keys()];
|
|
20467
|
+
}
|
|
20468
|
+
/**
|
|
20469
|
+
* Get all files as a record (for serialization)
|
|
20470
|
+
*/
|
|
20471
|
+
toRecord() {
|
|
20472
|
+
const record = {};
|
|
20473
|
+
for (const [path, data] of this.files) record[path] = data;
|
|
20474
|
+
return record;
|
|
20475
|
+
}
|
|
20476
|
+
/**
|
|
20477
|
+
* Load files from a record (for deserialization)
|
|
20478
|
+
*/
|
|
20479
|
+
fromRecord(record) {
|
|
20480
|
+
this.files.clear();
|
|
20481
|
+
for (const [path, data] of Object.entries(record)) this.files.set(path, data);
|
|
20482
|
+
}
|
|
20483
|
+
/**
|
|
20484
|
+
* Get content types for all stored files that have known types
|
|
20485
|
+
*/
|
|
20486
|
+
getContentTypes() {
|
|
20487
|
+
const contentTypes = [];
|
|
20488
|
+
for (const path of this.files.keys()) {
|
|
20489
|
+
const contentType = PassthroughManager.getContentType(path);
|
|
20490
|
+
if (contentType) contentTypes.push({
|
|
20491
|
+
partName: path,
|
|
20492
|
+
contentType
|
|
20493
|
+
});
|
|
20494
|
+
}
|
|
20495
|
+
return contentTypes;
|
|
20496
|
+
}
|
|
20497
|
+
/**
|
|
20498
|
+
* Write all passthrough files to a ZIP writer
|
|
20499
|
+
*/
|
|
20500
|
+
writeToZip(zip) {
|
|
20501
|
+
for (const [path, data] of this.files) zip.append(data, { name: path });
|
|
20502
|
+
}
|
|
20503
|
+
/**
|
|
20504
|
+
* Clear all stored files
|
|
20505
|
+
*/
|
|
20506
|
+
clear() {
|
|
20507
|
+
this.files.clear();
|
|
20508
|
+
}
|
|
20509
|
+
/**
|
|
20510
|
+
* Get the number of stored files
|
|
20511
|
+
*/
|
|
20512
|
+
get size() {
|
|
20513
|
+
return this.files.size;
|
|
20514
|
+
}
|
|
20515
|
+
};
|
|
20516
|
+
|
|
20209
20517
|
//#endregion
|
|
20210
20518
|
//#region src/modules/excel/xlsx/xlsx.browser.ts
|
|
20211
20519
|
/**
|
|
@@ -20345,22 +20653,23 @@ var ExcelTS = (function(exports) {
|
|
|
20345
20653
|
* Write all workbook content to a ZIP writer
|
|
20346
20654
|
* Shared by both Node.js write() and browser writeBuffer()
|
|
20347
20655
|
*/
|
|
20348
|
-
async writeToZip(zip
|
|
20656
|
+
async writeToZip(zip, options) {
|
|
20349
20657
|
const { model } = this.workbook;
|
|
20350
20658
|
this.prepareModel(model, options);
|
|
20351
|
-
await this.addContentTypes(zip
|
|
20352
|
-
await this.addOfficeRels(zip
|
|
20353
|
-
await this.addWorkbookRels(zip
|
|
20354
|
-
await this.addWorksheets(zip
|
|
20355
|
-
await this.addSharedStrings(zip
|
|
20356
|
-
this.addDrawings(zip
|
|
20357
|
-
this.addTables(zip
|
|
20358
|
-
this.addPivotTables(zip
|
|
20359
|
-
|
|
20360
|
-
await this.
|
|
20361
|
-
await this.
|
|
20362
|
-
await
|
|
20363
|
-
await this.
|
|
20659
|
+
await this.addContentTypes(zip, model);
|
|
20660
|
+
await this.addOfficeRels(zip, model);
|
|
20661
|
+
await this.addWorkbookRels(zip, model);
|
|
20662
|
+
await this.addWorksheets(zip, model);
|
|
20663
|
+
await this.addSharedStrings(zip, model);
|
|
20664
|
+
this.addDrawings(zip, model);
|
|
20665
|
+
this.addTables(zip, model);
|
|
20666
|
+
this.addPivotTables(zip, model);
|
|
20667
|
+
this.addPassthrough(zip, model);
|
|
20668
|
+
await Promise.all([this.addThemes(zip, model), this.addStyles(zip, model)]);
|
|
20669
|
+
await this.addFeaturePropertyBag(zip, model);
|
|
20670
|
+
await this.addMedia(zip, model);
|
|
20671
|
+
await Promise.all([this.addApp(zip, model), this.addCore(zip, model)]);
|
|
20672
|
+
await this.addWorkbook(zip, model);
|
|
20364
20673
|
}
|
|
20365
20674
|
/**
|
|
20366
20675
|
* Read workbook from a stream
|
|
@@ -20396,10 +20705,10 @@ var ExcelTS = (function(exports) {
|
|
|
20396
20705
|
options = options || {};
|
|
20397
20706
|
options.zip = options.zip || {};
|
|
20398
20707
|
options.zip.modTime ??= this.workbook.modified ?? this.workbook.created;
|
|
20399
|
-
const zip
|
|
20400
|
-
zip
|
|
20401
|
-
await this.writeToZip(zip
|
|
20402
|
-
return this._finalize(zip
|
|
20708
|
+
const zip = this.createZipWriter(options.zip);
|
|
20709
|
+
zip.pipe(stream);
|
|
20710
|
+
await this.writeToZip(zip, options);
|
|
20711
|
+
return this._finalize(zip);
|
|
20403
20712
|
}
|
|
20404
20713
|
/**
|
|
20405
20714
|
* Load workbook from buffer/ArrayBuffer/Uint8Array
|
|
@@ -20429,8 +20738,12 @@ var ExcelTS = (function(exports) {
|
|
|
20429
20738
|
* This is the foundation for TRUE streaming reads on platforms that have a
|
|
20430
20739
|
* streaming ZIP parser (e.g. Node.js `modules/archive` Parse).
|
|
20431
20740
|
*/
|
|
20432
|
-
|
|
20433
|
-
|
|
20741
|
+
/**
|
|
20742
|
+
* Create an empty model for parsing XLSX files.
|
|
20743
|
+
* Shared by loadFromZipEntries and loadFromFiles.
|
|
20744
|
+
*/
|
|
20745
|
+
createEmptyModel() {
|
|
20746
|
+
return {
|
|
20434
20747
|
worksheets: [],
|
|
20435
20748
|
worksheetHash: {},
|
|
20436
20749
|
worksheetRels: [],
|
|
@@ -20439,6 +20752,7 @@ var ExcelTS = (function(exports) {
|
|
|
20439
20752
|
mediaIndex: {},
|
|
20440
20753
|
drawings: {},
|
|
20441
20754
|
drawingRels: {},
|
|
20755
|
+
rawDrawings: {},
|
|
20442
20756
|
comments: {},
|
|
20443
20757
|
tables: {},
|
|
20444
20758
|
vmlDrawings: {},
|
|
@@ -20446,8 +20760,93 @@ var ExcelTS = (function(exports) {
|
|
|
20446
20760
|
pivotTableRels: {},
|
|
20447
20761
|
pivotCacheDefinitions: {},
|
|
20448
20762
|
pivotCacheDefinitionRels: {},
|
|
20449
|
-
pivotCacheRecords: {}
|
|
20763
|
+
pivotCacheRecords: {},
|
|
20764
|
+
passthrough: {}
|
|
20450
20765
|
};
|
|
20766
|
+
}
|
|
20767
|
+
/**
|
|
20768
|
+
* Collect all data from a stream into a single Uint8Array.
|
|
20769
|
+
* Reusable helper for passthrough and drawing processing.
|
|
20770
|
+
*/
|
|
20771
|
+
async collectStreamData(stream) {
|
|
20772
|
+
const chunks = [];
|
|
20773
|
+
await new Promise((resolve, reject) => {
|
|
20774
|
+
stream.on("data", (chunk) => {
|
|
20775
|
+
if (typeof chunk === "string") chunks.push(new TextEncoder().encode(chunk));
|
|
20776
|
+
else if (chunk instanceof Uint8Array) chunks.push(chunk);
|
|
20777
|
+
else chunks.push(new Uint8Array(chunk));
|
|
20778
|
+
});
|
|
20779
|
+
stream.on("end", () => resolve());
|
|
20780
|
+
stream.on("error", reject);
|
|
20781
|
+
});
|
|
20782
|
+
return concatUint8Arrays$2(chunks);
|
|
20783
|
+
}
|
|
20784
|
+
/**
|
|
20785
|
+
* Check if a drawing has chart references in its relationships
|
|
20786
|
+
*/
|
|
20787
|
+
drawingHasChartReference(drawing) {
|
|
20788
|
+
return drawing.rels && drawing.rels.some((rel) => rel.Target && rel.Target.includes("/charts/"));
|
|
20789
|
+
}
|
|
20790
|
+
/**
|
|
20791
|
+
* Check if a drawing rels list references charts.
|
|
20792
|
+
* Used to decide whether we need to keep raw drawing XML for passthrough.
|
|
20793
|
+
*/
|
|
20794
|
+
drawingRelsHasChartReference(drawingRels) {
|
|
20795
|
+
return Array.isArray(drawingRels) && drawingRels.some((rel) => typeof rel?.Target === "string" && rel.Target.includes("/charts/"));
|
|
20796
|
+
}
|
|
20797
|
+
/**
|
|
20798
|
+
* Process a known OOXML entry (workbook, styles, shared strings, etc.)
|
|
20799
|
+
* Returns true if handled, false if should be passed to _processDefaultEntry
|
|
20800
|
+
*/
|
|
20801
|
+
async _processKnownEntry(stream, model, entryName, options) {
|
|
20802
|
+
const sheetNo = getWorksheetNoFromWorksheetPath(entryName);
|
|
20803
|
+
if (sheetNo !== void 0) {
|
|
20804
|
+
await this._processWorksheetEntry(stream, model, sheetNo, options, entryName);
|
|
20805
|
+
return true;
|
|
20806
|
+
}
|
|
20807
|
+
switch (entryName) {
|
|
20808
|
+
case OOXML_PATHS.rootRels:
|
|
20809
|
+
model.globalRels = await this.parseRels(stream);
|
|
20810
|
+
return true;
|
|
20811
|
+
case OOXML_PATHS.xlWorkbook: {
|
|
20812
|
+
const workbook = await this.parseWorkbook(stream);
|
|
20813
|
+
model.sheets = workbook.sheets;
|
|
20814
|
+
model.definedNames = workbook.definedNames;
|
|
20815
|
+
model.views = workbook.views;
|
|
20816
|
+
model.properties = workbook.properties;
|
|
20817
|
+
model.calcProperties = workbook.calcProperties;
|
|
20818
|
+
model.pivotCaches = workbook.pivotCaches;
|
|
20819
|
+
return true;
|
|
20820
|
+
}
|
|
20821
|
+
case OOXML_PATHS.xlSharedStrings:
|
|
20822
|
+
model.sharedStrings = new SharedStringsXform();
|
|
20823
|
+
await model.sharedStrings.parseStream(stream);
|
|
20824
|
+
return true;
|
|
20825
|
+
case OOXML_PATHS.xlWorkbookRels:
|
|
20826
|
+
model.workbookRels = await this.parseRels(stream);
|
|
20827
|
+
return true;
|
|
20828
|
+
case OOXML_PATHS.docPropsApp: {
|
|
20829
|
+
const appProperties = await new AppXform().parseStream(stream);
|
|
20830
|
+
if (appProperties) {
|
|
20831
|
+
model.company = appProperties.company;
|
|
20832
|
+
model.manager = appProperties.manager;
|
|
20833
|
+
}
|
|
20834
|
+
return true;
|
|
20835
|
+
}
|
|
20836
|
+
case OOXML_PATHS.docPropsCore: {
|
|
20837
|
+
const coreProperties = await new CoreXform().parseStream(stream);
|
|
20838
|
+
Object.assign(model, coreProperties);
|
|
20839
|
+
return true;
|
|
20840
|
+
}
|
|
20841
|
+
case OOXML_PATHS.xlStyles:
|
|
20842
|
+
model.styles = new StylesXform();
|
|
20843
|
+
await model.styles.parseStream(stream);
|
|
20844
|
+
return true;
|
|
20845
|
+
default: return false;
|
|
20846
|
+
}
|
|
20847
|
+
}
|
|
20848
|
+
async loadFromZipEntries(entries, options) {
|
|
20849
|
+
const model = this.createEmptyModel();
|
|
20451
20850
|
for await (const entry of entries) {
|
|
20452
20851
|
let drained = false;
|
|
20453
20852
|
const drainEntry = async () => {
|
|
@@ -20462,52 +20861,8 @@ var ExcelTS = (function(exports) {
|
|
|
20462
20861
|
const entryName = normalizeZipPath(entry.name);
|
|
20463
20862
|
const stream = entry.stream;
|
|
20464
20863
|
try {
|
|
20465
|
-
|
|
20466
|
-
|
|
20467
|
-
await this._processWorksheetEntry(stream, model, sheetNo, options, entryName);
|
|
20468
|
-
continue;
|
|
20469
|
-
}
|
|
20470
|
-
switch (entryName) {
|
|
20471
|
-
case OOXML_PATHS.rootRels:
|
|
20472
|
-
model.globalRels = await this.parseRels(stream);
|
|
20473
|
-
break;
|
|
20474
|
-
case OOXML_PATHS.xlWorkbook: {
|
|
20475
|
-
const workbook = await this.parseWorkbook(stream);
|
|
20476
|
-
model.sheets = workbook.sheets;
|
|
20477
|
-
model.definedNames = workbook.definedNames;
|
|
20478
|
-
model.views = workbook.views;
|
|
20479
|
-
model.properties = workbook.properties;
|
|
20480
|
-
model.calcProperties = workbook.calcProperties;
|
|
20481
|
-
model.pivotCaches = workbook.pivotCaches;
|
|
20482
|
-
break;
|
|
20483
|
-
}
|
|
20484
|
-
case OOXML_PATHS.xlSharedStrings:
|
|
20485
|
-
model.sharedStrings = new SharedStringsXform();
|
|
20486
|
-
await model.sharedStrings.parseStream(stream);
|
|
20487
|
-
break;
|
|
20488
|
-
case OOXML_PATHS.xlWorkbookRels:
|
|
20489
|
-
model.workbookRels = await this.parseRels(stream);
|
|
20490
|
-
break;
|
|
20491
|
-
case OOXML_PATHS.docPropsApp: {
|
|
20492
|
-
const appProperties = await new AppXform().parseStream(stream);
|
|
20493
|
-
if (appProperties) {
|
|
20494
|
-
model.company = appProperties.company;
|
|
20495
|
-
model.manager = appProperties.manager;
|
|
20496
|
-
}
|
|
20497
|
-
break;
|
|
20498
|
-
}
|
|
20499
|
-
case OOXML_PATHS.docPropsCore: {
|
|
20500
|
-
const coreProperties = await new CoreXform().parseStream(stream);
|
|
20501
|
-
Object.assign(model, coreProperties);
|
|
20502
|
-
break;
|
|
20503
|
-
}
|
|
20504
|
-
case OOXML_PATHS.xlStyles:
|
|
20505
|
-
model.styles = new StylesXform();
|
|
20506
|
-
await model.styles.parseStream(stream);
|
|
20507
|
-
break;
|
|
20508
|
-
default:
|
|
20509
|
-
if (!await this._processDefaultEntry(stream, model, entryName)) await drainEntry();
|
|
20510
|
-
break;
|
|
20864
|
+
if (!await this._processKnownEntry(stream, model, entryName, options)) {
|
|
20865
|
+
if (!await this._processDefaultEntry(stream, model, entryName)) await drainEntry();
|
|
20511
20866
|
}
|
|
20512
20867
|
} finally {
|
|
20513
20868
|
try {
|
|
@@ -20526,32 +20881,32 @@ var ExcelTS = (function(exports) {
|
|
|
20526
20881
|
options = options || {};
|
|
20527
20882
|
options.zip = options.zip || {};
|
|
20528
20883
|
options.zip.modTime ??= this.workbook.modified ?? this.workbook.created;
|
|
20529
|
-
const zip
|
|
20884
|
+
const zip = this.createZipWriter(options.zip);
|
|
20530
20885
|
const stream = this.createStreamBuf();
|
|
20531
|
-
zip
|
|
20532
|
-
await this.writeToZip(zip
|
|
20533
|
-
await this._finalize(zip
|
|
20886
|
+
zip.pipe(stream);
|
|
20887
|
+
await this.writeToZip(zip, options);
|
|
20888
|
+
await this._finalize(zip);
|
|
20534
20889
|
return stream.read() || new Uint8Array(0);
|
|
20535
20890
|
}
|
|
20536
20891
|
/**
|
|
20537
20892
|
* Add media files to ZIP
|
|
20538
20893
|
* Supports buffer, base64, and filename (if readFileAsync is provided)
|
|
20539
20894
|
*/
|
|
20540
|
-
async addMedia(zip
|
|
20895
|
+
async addMedia(zip, model) {
|
|
20541
20896
|
await Promise.all(model.media.map(async (medium) => {
|
|
20542
20897
|
if (medium.type !== "image") throw new Error("Unsupported media");
|
|
20543
20898
|
const filename = mediaPath(`${medium.name ?? "undefined"}.${medium.extension}`);
|
|
20544
20899
|
if (medium.filename) {
|
|
20545
20900
|
if (this.readFileAsync) {
|
|
20546
20901
|
const data = await this.readFileAsync(medium.filename);
|
|
20547
|
-
return zip
|
|
20902
|
+
return zip.append(data, { name: filename });
|
|
20548
20903
|
}
|
|
20549
20904
|
throw new Error("Loading images from filename is not supported in this environment");
|
|
20550
20905
|
}
|
|
20551
|
-
if (medium.buffer) return zip
|
|
20906
|
+
if (medium.buffer) return zip.append(medium.buffer, { name: filename });
|
|
20552
20907
|
if (medium.base64) {
|
|
20553
20908
|
const content = medium.base64.substring(medium.base64.indexOf(",") + 1);
|
|
20554
|
-
return zip
|
|
20909
|
+
return zip.append(content, {
|
|
20555
20910
|
name: filename,
|
|
20556
20911
|
base64: true
|
|
20557
20912
|
});
|
|
@@ -20596,6 +20951,10 @@ var ExcelTS = (function(exports) {
|
|
|
20596
20951
|
drawingXform.reconcile(drawing, drawingOptions);
|
|
20597
20952
|
}
|
|
20598
20953
|
});
|
|
20954
|
+
if (model.rawDrawings && model.drawingRels) for (const name of Object.keys(model.rawDrawings)) {
|
|
20955
|
+
const drawingRel = model.drawingRels[name];
|
|
20956
|
+
if (drawingRel && !this.drawingRelsHasChartReference(drawingRel)) delete model.rawDrawings[name];
|
|
20957
|
+
}
|
|
20599
20958
|
const tableOptions = { styles: model.styles };
|
|
20600
20959
|
Object.values(model.tables).forEach((table) => {
|
|
20601
20960
|
tableXform.reconcile(table, tableOptions);
|
|
@@ -20608,6 +20967,7 @@ var ExcelTS = (function(exports) {
|
|
|
20608
20967
|
mediaIndex: model.mediaIndex,
|
|
20609
20968
|
date1904: model.properties && model.properties.date1904,
|
|
20610
20969
|
drawings: model.drawings,
|
|
20970
|
+
drawingRels: model.drawingRels,
|
|
20611
20971
|
comments: model.comments,
|
|
20612
20972
|
tables: model.tables,
|
|
20613
20973
|
vmlDrawings: model.vmlDrawings,
|
|
@@ -20623,6 +20983,7 @@ var ExcelTS = (function(exports) {
|
|
|
20623
20983
|
delete model.sharedStrings;
|
|
20624
20984
|
delete model.workbookRels;
|
|
20625
20985
|
delete model.sheetDefs;
|
|
20986
|
+
model.defaultFont = model.styles?.defaultFont;
|
|
20626
20987
|
delete model.styles;
|
|
20627
20988
|
delete model.mediaIndex;
|
|
20628
20989
|
delete model.drawings;
|
|
@@ -20764,8 +21125,12 @@ var ExcelTS = (function(exports) {
|
|
|
20764
21125
|
}
|
|
20765
21126
|
}
|
|
20766
21127
|
async _processDrawingEntry(entry, model, name) {
|
|
20767
|
-
const
|
|
21128
|
+
const rawData = await this.collectStreamData(entry);
|
|
21129
|
+
const xform = new DrawingXform();
|
|
21130
|
+
const xmlString = this.bufferToString(rawData);
|
|
21131
|
+
const drawing = await xform.parseStream(this.createTextStream(xmlString));
|
|
20768
21132
|
model.drawings[name] = drawing;
|
|
21133
|
+
model.rawDrawings[name] = rawData;
|
|
20769
21134
|
}
|
|
20770
21135
|
async _processDrawingRelsEntry(entry, model, name) {
|
|
20771
21136
|
const relationships = await new RelationshipsXform().parseStream(entry);
|
|
@@ -20820,24 +21185,7 @@ var ExcelTS = (function(exports) {
|
|
|
20820
21185
|
if (cacheRecords) model.pivotCacheRecords[name] = cacheRecords;
|
|
20821
21186
|
}
|
|
20822
21187
|
async loadFromFiles(zipData, options) {
|
|
20823
|
-
const model =
|
|
20824
|
-
worksheets: [],
|
|
20825
|
-
worksheetHash: {},
|
|
20826
|
-
worksheetRels: [],
|
|
20827
|
-
themes: {},
|
|
20828
|
-
media: [],
|
|
20829
|
-
mediaIndex: {},
|
|
20830
|
-
drawings: {},
|
|
20831
|
-
drawingRels: {},
|
|
20832
|
-
comments: {},
|
|
20833
|
-
tables: {},
|
|
20834
|
-
vmlDrawings: {},
|
|
20835
|
-
pivotTables: {},
|
|
20836
|
-
pivotTableRels: {},
|
|
20837
|
-
pivotCacheDefinitions: {},
|
|
20838
|
-
pivotCacheDefinitionRels: {},
|
|
20839
|
-
pivotCacheRecords: {}
|
|
20840
|
-
};
|
|
21188
|
+
const model = this.createEmptyModel();
|
|
20841
21189
|
const entries = Object.keys(zipData).map((name) => ({
|
|
20842
21190
|
name,
|
|
20843
21191
|
dir: name.endsWith("/"),
|
|
@@ -20846,48 +21194,7 @@ var ExcelTS = (function(exports) {
|
|
|
20846
21194
|
for (const entry of entries) if (!entry.dir) {
|
|
20847
21195
|
const entryName = normalizeZipPath(entry.name);
|
|
20848
21196
|
const stream = isBinaryEntryPath(entryName) ? this.createBinaryStream(entry.data) : this.createTextStream(this.bufferToString(entry.data));
|
|
20849
|
-
|
|
20850
|
-
if (sheetNo !== void 0) await this._processWorksheetEntry(stream, model, sheetNo, options, entryName);
|
|
20851
|
-
else switch (entryName) {
|
|
20852
|
-
case OOXML_PATHS.rootRels:
|
|
20853
|
-
model.globalRels = await this.parseRels(stream);
|
|
20854
|
-
break;
|
|
20855
|
-
case OOXML_PATHS.xlWorkbook: {
|
|
20856
|
-
const workbook = await this.parseWorkbook(stream);
|
|
20857
|
-
model.sheets = workbook.sheets;
|
|
20858
|
-
model.definedNames = workbook.definedNames;
|
|
20859
|
-
model.views = workbook.views;
|
|
20860
|
-
model.properties = workbook.properties;
|
|
20861
|
-
model.calcProperties = workbook.calcProperties;
|
|
20862
|
-
model.pivotCaches = workbook.pivotCaches;
|
|
20863
|
-
break;
|
|
20864
|
-
}
|
|
20865
|
-
case OOXML_PATHS.xlSharedStrings:
|
|
20866
|
-
model.sharedStrings = new SharedStringsXform();
|
|
20867
|
-
await model.sharedStrings.parseStream(stream);
|
|
20868
|
-
break;
|
|
20869
|
-
case OOXML_PATHS.xlWorkbookRels:
|
|
20870
|
-
model.workbookRels = await this.parseRels(stream);
|
|
20871
|
-
break;
|
|
20872
|
-
case OOXML_PATHS.docPropsApp: {
|
|
20873
|
-
const appProperties = await new AppXform().parseStream(stream);
|
|
20874
|
-
if (appProperties) {
|
|
20875
|
-
model.company = appProperties.company;
|
|
20876
|
-
model.manager = appProperties.manager;
|
|
20877
|
-
}
|
|
20878
|
-
break;
|
|
20879
|
-
}
|
|
20880
|
-
case OOXML_PATHS.docPropsCore: {
|
|
20881
|
-
const coreProperties = await new CoreXform().parseStream(stream);
|
|
20882
|
-
Object.assign(model, coreProperties);
|
|
20883
|
-
break;
|
|
20884
|
-
}
|
|
20885
|
-
case OOXML_PATHS.xlStyles:
|
|
20886
|
-
model.styles = new StylesXform();
|
|
20887
|
-
await model.styles.parseStream(stream);
|
|
20888
|
-
break;
|
|
20889
|
-
default: await this._processDefaultEntry(stream, model, entryName);
|
|
20890
|
-
}
|
|
21197
|
+
if (!await this._processKnownEntry(stream, model, entryName, options)) await this._processDefaultEntry(stream, model, entryName, entry.data);
|
|
20891
21198
|
}
|
|
20892
21199
|
this.reconcile(model, options);
|
|
20893
21200
|
this.workbook.model = model;
|
|
@@ -20895,11 +21202,11 @@ var ExcelTS = (function(exports) {
|
|
|
20895
21202
|
}
|
|
20896
21203
|
/**
|
|
20897
21204
|
* Process default entries (drawings, comments, tables, etc.)
|
|
21205
|
+
* @param rawData Optional raw entry data for passthrough preservation (used by loadFromFiles)
|
|
20898
21206
|
*/
|
|
20899
|
-
async _processDefaultEntry(stream, model, entryName) {
|
|
20900
|
-
const
|
|
20901
|
-
if (
|
|
20902
|
-
const sheetNo = worksheetRelsSheetNo;
|
|
21207
|
+
async _processDefaultEntry(stream, model, entryName, rawData) {
|
|
21208
|
+
const sheetNo = getWorksheetNoFromWorksheetRelsPath(entryName);
|
|
21209
|
+
if (sheetNo !== void 0) {
|
|
20903
21210
|
await this._processWorksheetRelsEntry(stream, model, sheetNo);
|
|
20904
21211
|
return true;
|
|
20905
21212
|
}
|
|
@@ -20911,6 +21218,7 @@ var ExcelTS = (function(exports) {
|
|
|
20911
21218
|
const drawingName = getDrawingNameFromPath(entryName);
|
|
20912
21219
|
if (drawingName) {
|
|
20913
21220
|
await this._processDrawingEntry(stream, model, drawingName);
|
|
21221
|
+
if (rawData) model.rawDrawings[drawingName] = rawData;
|
|
20914
21222
|
return true;
|
|
20915
21223
|
}
|
|
20916
21224
|
const drawingRelsName = getDrawingNameFromRelsPath(entryName);
|
|
@@ -20963,28 +21271,41 @@ var ExcelTS = (function(exports) {
|
|
|
20963
21271
|
await this._processPivotCacheRecordsEntry(stream, model, pivotCacheRecordsName);
|
|
20964
21272
|
return true;
|
|
20965
21273
|
}
|
|
21274
|
+
if (PassthroughManager.isPassthroughPath(entryName)) {
|
|
21275
|
+
if (rawData) model.passthrough[entryName] = rawData;
|
|
21276
|
+
else await this._processPassthroughEntry(stream, model, entryName);
|
|
21277
|
+
return true;
|
|
21278
|
+
}
|
|
20966
21279
|
return false;
|
|
20967
21280
|
}
|
|
20968
|
-
|
|
21281
|
+
/**
|
|
21282
|
+
* Store a passthrough file for preservation during read/write cycles.
|
|
21283
|
+
* These files are not parsed but stored as raw bytes to be written back unchanged.
|
|
21284
|
+
*/
|
|
21285
|
+
async _processPassthroughEntry(stream, model, entryName) {
|
|
21286
|
+
const data = await this.collectStreamData(stream);
|
|
21287
|
+
model.passthrough[entryName] = data;
|
|
21288
|
+
}
|
|
21289
|
+
async addContentTypes(zip, model) {
|
|
20969
21290
|
const xml = new ContentTypesXform().toXml(model);
|
|
20970
|
-
zip
|
|
21291
|
+
zip.append(xml, { name: OOXML_PATHS.contentTypes });
|
|
20971
21292
|
}
|
|
20972
|
-
async addApp(zip
|
|
21293
|
+
async addApp(zip, model) {
|
|
20973
21294
|
const xml = new AppXform().toXml(model);
|
|
20974
|
-
zip
|
|
21295
|
+
zip.append(xml, { name: OOXML_PATHS.docPropsApp });
|
|
20975
21296
|
}
|
|
20976
|
-
async addCore(zip
|
|
20977
|
-
const xform
|
|
20978
|
-
zip
|
|
21297
|
+
async addCore(zip, model) {
|
|
21298
|
+
const xform = new CoreXform();
|
|
21299
|
+
zip.append(xform.toXml(model), { name: OOXML_PATHS.docPropsCore });
|
|
20979
21300
|
}
|
|
20980
|
-
async addThemes(zip
|
|
21301
|
+
async addThemes(zip, model) {
|
|
20981
21302
|
const themes = model.themes || { theme1: theme1Xml };
|
|
20982
21303
|
Object.keys(themes).forEach((name) => {
|
|
20983
21304
|
const xml = themes[name];
|
|
20984
|
-
zip
|
|
21305
|
+
zip.append(xml, { name: themePath(name) });
|
|
20985
21306
|
});
|
|
20986
21307
|
}
|
|
20987
|
-
async addOfficeRels(zip
|
|
21308
|
+
async addOfficeRels(zip, _model) {
|
|
20988
21309
|
const xml = new RelationshipsXform().toXml([
|
|
20989
21310
|
{
|
|
20990
21311
|
Id: "rId1",
|
|
@@ -21002,9 +21323,9 @@ var ExcelTS = (function(exports) {
|
|
|
21002
21323
|
Target: OOXML_PATHS.docPropsApp
|
|
21003
21324
|
}
|
|
21004
21325
|
]);
|
|
21005
|
-
zip
|
|
21326
|
+
zip.append(xml, { name: OOXML_PATHS.rootRels });
|
|
21006
21327
|
}
|
|
21007
|
-
async addWorkbookRels(zip
|
|
21328
|
+
async addWorkbookRels(zip, model) {
|
|
21008
21329
|
let count = 1;
|
|
21009
21330
|
const relationships = [{
|
|
21010
21331
|
Id: `rId${count++}`,
|
|
@@ -21043,25 +21364,25 @@ var ExcelTS = (function(exports) {
|
|
|
21043
21364
|
});
|
|
21044
21365
|
});
|
|
21045
21366
|
const xml = new RelationshipsXform().toXml(relationships);
|
|
21046
|
-
zip
|
|
21367
|
+
zip.append(xml, { name: OOXML_PATHS.xlWorkbookRels });
|
|
21047
21368
|
}
|
|
21048
|
-
async addFeaturePropertyBag(zip
|
|
21369
|
+
async addFeaturePropertyBag(zip, model) {
|
|
21049
21370
|
if (!model.hasCheckboxes) return;
|
|
21050
|
-
const xform
|
|
21051
|
-
zip
|
|
21371
|
+
const xform = new FeaturePropertyBagXform();
|
|
21372
|
+
zip.append(xform.toXml({}), { name: OOXML_PATHS.xlFeaturePropertyBag });
|
|
21052
21373
|
}
|
|
21053
|
-
async addSharedStrings(zip
|
|
21054
|
-
if (model.sharedStrings && model.sharedStrings.count) zip
|
|
21374
|
+
async addSharedStrings(zip, model) {
|
|
21375
|
+
if (model.sharedStrings && model.sharedStrings.count) zip.append(model.sharedStrings.xml, { name: OOXML_PATHS.xlSharedStrings });
|
|
21055
21376
|
}
|
|
21056
|
-
async addStyles(zip
|
|
21377
|
+
async addStyles(zip, model) {
|
|
21057
21378
|
const { xml } = model.styles;
|
|
21058
|
-
if (xml) zip
|
|
21379
|
+
if (xml) zip.append(xml, { name: OOXML_PATHS.xlStyles });
|
|
21059
21380
|
}
|
|
21060
|
-
async addWorkbook(zip
|
|
21061
|
-
const xform
|
|
21062
|
-
zip
|
|
21381
|
+
async addWorkbook(zip, model) {
|
|
21382
|
+
const xform = new WorkbookXform();
|
|
21383
|
+
zip.append(xform.toXml(model), { name: OOXML_PATHS.xlWorkbook });
|
|
21063
21384
|
}
|
|
21064
|
-
async addWorksheets(zip
|
|
21385
|
+
async addWorksheets(zip, model) {
|
|
21065
21386
|
const worksheetXform = new WorkSheetXform();
|
|
21066
21387
|
const relationshipsXform = new RelationshipsXform();
|
|
21067
21388
|
const commentsXform = new CommentsXform();
|
|
@@ -21071,16 +21392,16 @@ var ExcelTS = (function(exports) {
|
|
|
21071
21392
|
const fileIndex = worksheet.fileIndex || index + 1;
|
|
21072
21393
|
let xmlStream = new XmlStream();
|
|
21073
21394
|
worksheetXform.render(xmlStream, worksheet);
|
|
21074
|
-
zip
|
|
21395
|
+
zip.append(xmlStream.xml, { name: worksheetPath(fileIndex) });
|
|
21075
21396
|
if (worksheet.rels && worksheet.rels.length) {
|
|
21076
21397
|
xmlStream = new XmlStream();
|
|
21077
21398
|
relationshipsXform.render(xmlStream, worksheet.rels);
|
|
21078
|
-
zip
|
|
21399
|
+
zip.append(xmlStream.xml, { name: worksheetRelsPath(fileIndex) });
|
|
21079
21400
|
}
|
|
21080
21401
|
if (worksheet.comments.length > 0) {
|
|
21081
21402
|
xmlStream = new XmlStream();
|
|
21082
21403
|
commentsXform.render(xmlStream, worksheet);
|
|
21083
|
-
zip
|
|
21404
|
+
zip.append(xmlStream.xml, { name: commentsPath(fileIndex) });
|
|
21084
21405
|
}
|
|
21085
21406
|
const hasComments = worksheet.comments.length > 0;
|
|
21086
21407
|
const hasFormControls = worksheet.formControls && worksheet.formControls.length > 0;
|
|
@@ -21090,40 +21411,64 @@ var ExcelTS = (function(exports) {
|
|
|
21090
21411
|
comments: hasComments ? worksheet.comments : [],
|
|
21091
21412
|
formControls: hasFormControls ? worksheet.formControls : []
|
|
21092
21413
|
});
|
|
21093
|
-
zip
|
|
21414
|
+
zip.append(xmlStream.xml, { name: vmlDrawingPath(fileIndex) });
|
|
21094
21415
|
}
|
|
21095
21416
|
if (hasFormControls) worksheet.formControls.forEach((control) => {
|
|
21096
21417
|
const xml = ctrlPropXform.toXml(control);
|
|
21097
|
-
zip
|
|
21418
|
+
zip.append(xml, { name: ctrlPropPath(control.ctrlPropId) });
|
|
21098
21419
|
});
|
|
21099
21420
|
});
|
|
21100
21421
|
}
|
|
21101
|
-
addDrawings(zip
|
|
21422
|
+
addDrawings(zip, model) {
|
|
21102
21423
|
const drawingXform = new DrawingXform();
|
|
21103
21424
|
const relsXform = new RelationshipsXform();
|
|
21425
|
+
const rawDrawings = model.rawDrawings || {};
|
|
21104
21426
|
model.worksheets.forEach((worksheet) => {
|
|
21105
21427
|
const { drawing } = worksheet;
|
|
21106
21428
|
if (drawing) {
|
|
21107
|
-
|
|
21108
|
-
|
|
21109
|
-
|
|
21110
|
-
|
|
21111
|
-
|
|
21429
|
+
if (this.drawingHasChartReference(drawing) && rawDrawings[drawing.name]) zip.append(rawDrawings[drawing.name], { name: drawingPath(drawing.name) });
|
|
21430
|
+
else {
|
|
21431
|
+
const filteredAnchors = (drawing.anchors || []).filter((a) => {
|
|
21432
|
+
if (a == null) return false;
|
|
21433
|
+
if (a.range?.br && a.shape) return true;
|
|
21434
|
+
if (!a.br && !a.picture) return false;
|
|
21435
|
+
if (a.br && !a.picture && !a.shape) return false;
|
|
21436
|
+
return true;
|
|
21437
|
+
});
|
|
21438
|
+
const drawingForWrite = drawing.anchors ? {
|
|
21439
|
+
...drawing,
|
|
21440
|
+
anchors: filteredAnchors
|
|
21441
|
+
} : drawing;
|
|
21442
|
+
drawingXform.prepare(drawingForWrite);
|
|
21443
|
+
const xml = drawingXform.toXml(drawingForWrite);
|
|
21444
|
+
zip.append(xml, { name: drawingPath(drawing.name) });
|
|
21445
|
+
}
|
|
21446
|
+
const relsXml = relsXform.toXml(drawing.rels);
|
|
21447
|
+
zip.append(relsXml, { name: drawingRelsPath(drawing.name) });
|
|
21112
21448
|
}
|
|
21113
21449
|
});
|
|
21114
21450
|
}
|
|
21115
|
-
addTables(zip
|
|
21451
|
+
addTables(zip, model) {
|
|
21116
21452
|
const tableXform = new TableXform();
|
|
21117
21453
|
model.worksheets.forEach((worksheet) => {
|
|
21118
21454
|
const { tables } = worksheet;
|
|
21119
21455
|
tables.forEach((table) => {
|
|
21120
21456
|
tableXform.prepare(table, {});
|
|
21121
21457
|
const tableXml = tableXform.toXml(table);
|
|
21122
|
-
zip
|
|
21458
|
+
zip.append(tableXml, { name: tablePath(table.target) });
|
|
21123
21459
|
});
|
|
21124
21460
|
});
|
|
21125
21461
|
}
|
|
21126
|
-
|
|
21462
|
+
/**
|
|
21463
|
+
* Write passthrough files (charts, etc.) that were preserved during read.
|
|
21464
|
+
* These files are written back unchanged to preserve unsupported features.
|
|
21465
|
+
*/
|
|
21466
|
+
addPassthrough(zip, model) {
|
|
21467
|
+
const passthroughManager = new PassthroughManager();
|
|
21468
|
+
passthroughManager.fromRecord(model.passthrough || {});
|
|
21469
|
+
passthroughManager.writeToZip(zip);
|
|
21470
|
+
}
|
|
21471
|
+
addPivotTables(zip, model) {
|
|
21127
21472
|
if (!model.pivotTables.length) return;
|
|
21128
21473
|
const pivotCacheRecordsXform = new PivotCacheRecordsXform();
|
|
21129
21474
|
const pivotCacheDefinitionXform = new PivotCacheDefinitionXform();
|
|
@@ -21133,42 +21478,42 @@ var ExcelTS = (function(exports) {
|
|
|
21133
21478
|
const n = pivotTable.tableNumber;
|
|
21134
21479
|
if (pivotTable.isLoaded) {
|
|
21135
21480
|
if (pivotTable.cacheDefinition) {
|
|
21136
|
-
const xml
|
|
21137
|
-
zip
|
|
21481
|
+
const xml = pivotCacheDefinitionXform.toXml(pivotTable.cacheDefinition);
|
|
21482
|
+
zip.append(xml, { name: pivotCacheDefinitionPath(n) });
|
|
21138
21483
|
}
|
|
21139
21484
|
if (pivotTable.cacheRecords) {
|
|
21140
|
-
const xml
|
|
21141
|
-
zip
|
|
21485
|
+
const xml = pivotCacheRecordsXform.toXml(pivotTable.cacheRecords);
|
|
21486
|
+
zip.append(xml, { name: pivotCacheRecordsPath(n) });
|
|
21142
21487
|
}
|
|
21143
21488
|
} else {
|
|
21144
|
-
let xml
|
|
21145
|
-
zip
|
|
21146
|
-
xml
|
|
21147
|
-
zip
|
|
21489
|
+
let xml = pivotCacheRecordsXform.toXml(pivotTable);
|
|
21490
|
+
zip.append(xml, { name: pivotCacheRecordsPath(n) });
|
|
21491
|
+
xml = pivotCacheDefinitionXform.toXml(pivotTable);
|
|
21492
|
+
zip.append(xml, { name: pivotCacheDefinitionPath(n) });
|
|
21148
21493
|
}
|
|
21149
21494
|
let xml = relsXform.toXml([{
|
|
21150
21495
|
Id: "rId1",
|
|
21151
21496
|
Type: XLSX.RelType.PivotCacheRecords,
|
|
21152
21497
|
Target: pivotCacheRecordsRelTarget(n)
|
|
21153
21498
|
}]);
|
|
21154
|
-
zip
|
|
21499
|
+
zip.append(xml, { name: pivotCacheDefinitionRelsPath(n) });
|
|
21155
21500
|
xml = pivotTableXform.toXml(pivotTable);
|
|
21156
|
-
zip
|
|
21501
|
+
zip.append(xml, { name: pivotTablePath(n) });
|
|
21157
21502
|
xml = relsXform.toXml([{
|
|
21158
21503
|
Id: "rId1",
|
|
21159
21504
|
Type: XLSX.RelType.PivotCacheDefinition,
|
|
21160
21505
|
Target: pivotCacheDefinitionRelTargetFromPivotTable(n)
|
|
21161
21506
|
}]);
|
|
21162
|
-
zip
|
|
21507
|
+
zip.append(xml, { name: pivotTableRelsPath(n) });
|
|
21163
21508
|
});
|
|
21164
21509
|
}
|
|
21165
|
-
_finalize(zip
|
|
21510
|
+
_finalize(zip) {
|
|
21166
21511
|
return new Promise((resolve, reject) => {
|
|
21167
|
-
zip
|
|
21512
|
+
zip.on("finish", () => {
|
|
21168
21513
|
resolve(this);
|
|
21169
21514
|
});
|
|
21170
|
-
zip
|
|
21171
|
-
zip
|
|
21515
|
+
zip.on("error", reject);
|
|
21516
|
+
zip.finalize();
|
|
21172
21517
|
});
|
|
21173
21518
|
}
|
|
21174
21519
|
prepareModel(model, options) {
|
|
@@ -21179,7 +21524,9 @@ var ExcelTS = (function(exports) {
|
|
|
21179
21524
|
model.useSharedStrings = options.useSharedStrings !== void 0 ? options.useSharedStrings : true;
|
|
21180
21525
|
model.useStyles = options.useStyles !== void 0 ? options.useStyles : true;
|
|
21181
21526
|
model.sharedStrings = new SharedStringsXform();
|
|
21527
|
+
const oldDefaultFont = model.defaultFont;
|
|
21182
21528
|
model.styles = model.useStyles ? new StylesXform(true) : new StylesXform.Mock();
|
|
21529
|
+
if (oldDefaultFont && model.styles.setDefaultFont) model.styles.setDefaultFont(oldDefaultFont);
|
|
21183
21530
|
const workbookXform = new WorkbookXform();
|
|
21184
21531
|
const worksheetXform = new WorkSheetXform();
|
|
21185
21532
|
workbookXform.prepare(model);
|
|
@@ -21205,6 +21552,10 @@ var ExcelTS = (function(exports) {
|
|
|
21205
21552
|
worksheetXform.prepare(worksheet, worksheetOptions);
|
|
21206
21553
|
});
|
|
21207
21554
|
model.hasCheckboxes = model.styles.hasCheckboxes;
|
|
21555
|
+
const passthrough = model.passthrough || {};
|
|
21556
|
+
const passthroughManager = new PassthroughManager();
|
|
21557
|
+
passthroughManager.fromRecord(passthrough);
|
|
21558
|
+
model.passthroughContentTypes = passthroughManager.getContentTypes();
|
|
21208
21559
|
}
|
|
21209
21560
|
};
|
|
21210
21561
|
|
|
@@ -21363,26 +21714,26 @@ var ExcelTS = (function(exports) {
|
|
|
21363
21714
|
parseAll(values) {
|
|
21364
21715
|
const len = values.length;
|
|
21365
21716
|
const out = new Array(len);
|
|
21366
|
-
const parse
|
|
21367
|
-
for (let i = 0; i < len; i++) out[i] = parse
|
|
21717
|
+
const parse = this.parse;
|
|
21718
|
+
for (let i = 0; i < len; i++) out[i] = parse(values[i]);
|
|
21368
21719
|
return out;
|
|
21369
21720
|
}
|
|
21370
21721
|
/** Parse and filter valid dates */
|
|
21371
21722
|
parseValid(values) {
|
|
21372
21723
|
const out = [];
|
|
21373
|
-
const parse
|
|
21724
|
+
const parse = this.parse;
|
|
21374
21725
|
for (let i = 0, len = values.length; i < len; i++) {
|
|
21375
|
-
const d = parse
|
|
21726
|
+
const d = parse(values[i]);
|
|
21376
21727
|
if (d) out.push(d);
|
|
21377
21728
|
}
|
|
21378
21729
|
return out;
|
|
21379
21730
|
}
|
|
21380
21731
|
};
|
|
21381
21732
|
function tzOffset(d) {
|
|
21382
|
-
const off
|
|
21383
|
-
const sign = off
|
|
21384
|
-
const h = Math.abs(off
|
|
21385
|
-
const m = Math.abs(off
|
|
21733
|
+
const off = -d.getTimezoneOffset();
|
|
21734
|
+
const sign = off >= 0 ? "+" : "-";
|
|
21735
|
+
const h = Math.abs(off) / 60 | 0;
|
|
21736
|
+
const m = Math.abs(off) % 60;
|
|
21386
21737
|
return `${sign}${PAD2[h]}:${PAD2[m]}`;
|
|
21387
21738
|
}
|
|
21388
21739
|
/**
|
|
@@ -21426,9 +21777,9 @@ var ExcelTS = (function(exports) {
|
|
|
21426
21777
|
});
|
|
21427
21778
|
}
|
|
21428
21779
|
/** Create custom format formatter */
|
|
21429
|
-
static create(format
|
|
21780
|
+
static create(format, options) {
|
|
21430
21781
|
const utc = options?.utc ?? false;
|
|
21431
|
-
if (format
|
|
21782
|
+
if (format === "YYYY-MM-DD") return utc ? new DateFormatter((d) => {
|
|
21432
21783
|
if (!(d instanceof Date)) return "";
|
|
21433
21784
|
const t = d.getTime();
|
|
21434
21785
|
if (t !== t) return "";
|
|
@@ -21439,7 +21790,7 @@ var ExcelTS = (function(exports) {
|
|
|
21439
21790
|
if (t !== t) return "";
|
|
21440
21791
|
return `${d.getFullYear()}-${PAD2[d.getMonth() + 1]}-${PAD2[d.getDate()]}`;
|
|
21441
21792
|
});
|
|
21442
|
-
if (format
|
|
21793
|
+
if (format === "YYYY-MM-DD HH:mm:ss") return utc ? new DateFormatter((d) => {
|
|
21443
21794
|
if (!(d instanceof Date)) return "";
|
|
21444
21795
|
const t = d.getTime();
|
|
21445
21796
|
if (t !== t) return "";
|
|
@@ -21450,8 +21801,8 @@ var ExcelTS = (function(exports) {
|
|
|
21450
21801
|
if (t !== t) return "";
|
|
21451
21802
|
return `${d.getFullYear()}-${PAD2[d.getMonth() + 1]}-${PAD2[d.getDate()]} ${PAD2[d.getHours()]}:${PAD2[d.getMinutes()]}:${PAD2[d.getSeconds()]}`;
|
|
21452
21803
|
});
|
|
21453
|
-
if (format
|
|
21454
|
-
const sep = format
|
|
21804
|
+
if (format === "MM-DD-YYYY" || format === "MM/DD/YYYY") {
|
|
21805
|
+
const sep = format.charAt(2);
|
|
21455
21806
|
return utc ? new DateFormatter((d) => {
|
|
21456
21807
|
if (!(d instanceof Date)) return "";
|
|
21457
21808
|
const t = d.getTime();
|
|
@@ -21464,8 +21815,8 @@ var ExcelTS = (function(exports) {
|
|
|
21464
21815
|
return `${PAD2[d.getMonth() + 1]}${sep}${PAD2[d.getDate()]}${sep}${d.getFullYear()}`;
|
|
21465
21816
|
});
|
|
21466
21817
|
}
|
|
21467
|
-
if (format
|
|
21468
|
-
const sep = format
|
|
21818
|
+
if (format === "DD-MM-YYYY" || format === "DD/MM/YYYY") {
|
|
21819
|
+
const sep = format.charAt(2);
|
|
21469
21820
|
return utc ? new DateFormatter((d) => {
|
|
21470
21821
|
if (!(d instanceof Date)) return "";
|
|
21471
21822
|
const t = d.getTime();
|
|
@@ -21478,12 +21829,12 @@ var ExcelTS = (function(exports) {
|
|
|
21478
21829
|
return `${PAD2[d.getDate()]}${sep}${PAD2[d.getMonth() + 1]}${sep}${d.getFullYear()}`;
|
|
21479
21830
|
});
|
|
21480
21831
|
}
|
|
21481
|
-
return DateFormatter.createGeneric(format
|
|
21832
|
+
return DateFormatter.createGeneric(format, utc);
|
|
21482
21833
|
}
|
|
21483
21834
|
/** Generic formatter for arbitrary formats */
|
|
21484
|
-
static createGeneric(format
|
|
21835
|
+
static createGeneric(format, utc) {
|
|
21485
21836
|
const esc = [];
|
|
21486
|
-
const tpl = format
|
|
21837
|
+
const tpl = format.replace(/\[([^\]]*)\]/g, (_, c) => {
|
|
21487
21838
|
esc.push(c);
|
|
21488
21839
|
return `\x00${esc.length - 1}\x00`;
|
|
21489
21840
|
});
|
|
@@ -21565,8 +21916,8 @@ var ExcelTS = (function(exports) {
|
|
|
21565
21916
|
/**
|
|
21566
21917
|
* Check if a validate function is synchronous (1 argument) vs async (2 arguments)
|
|
21567
21918
|
*/
|
|
21568
|
-
function isSyncValidate(validate
|
|
21569
|
-
return validate
|
|
21919
|
+
function isSyncValidate(validate) {
|
|
21920
|
+
return validate.length === 1;
|
|
21570
21921
|
}
|
|
21571
21922
|
/**
|
|
21572
21923
|
* Check if headers are unique
|
|
@@ -21584,7 +21935,7 @@ var ExcelTS = (function(exports) {
|
|
|
21584
21935
|
* Parse a CSV string into rows of fields
|
|
21585
21936
|
*/
|
|
21586
21937
|
function parseCsv(input, options = {}) {
|
|
21587
|
-
const { delimiter = ",", quote: quoteOption = "\"", escape: escapeOption = "\"", skipEmptyLines = false, ignoreEmpty = false, trim = false, ltrim = false, rtrim = false, headers = false, renameHeaders = false, comment, maxRows, skipLines = 0, skipRows = 0, strictColumnHandling = false, discardUnmappedColumns = false, transform, validate
|
|
21938
|
+
const { delimiter = ",", quote: quoteOption = "\"", escape: escapeOption = "\"", skipEmptyLines = false, ignoreEmpty = false, trim = false, ltrim = false, rtrim = false, headers = false, renameHeaders = false, comment, maxRows, skipLines = 0, skipRows = 0, strictColumnHandling = false, discardUnmappedColumns = false, transform, validate } = options;
|
|
21588
21939
|
const shouldSkipEmpty = skipEmptyLines || ignoreEmpty;
|
|
21589
21940
|
const quoteEnabled = quoteOption !== null && quoteOption !== false;
|
|
21590
21941
|
const quote = quoteEnabled ? String(quoteOption) : "";
|
|
@@ -21734,10 +22085,10 @@ var ExcelTS = (function(exports) {
|
|
|
21734
22085
|
return obj;
|
|
21735
22086
|
});
|
|
21736
22087
|
if (transform) dataRows = dataRows.map((row) => transform(row)).filter((row) => row !== null && row !== void 0);
|
|
21737
|
-
if (validate
|
|
22088
|
+
if (validate) {
|
|
21738
22089
|
const validatedRows = [];
|
|
21739
22090
|
for (const row of dataRows) {
|
|
21740
|
-
const result = validate
|
|
22091
|
+
const result = validate(row);
|
|
21741
22092
|
if (typeof result === "boolean") if (result) validatedRows.push(row);
|
|
21742
22093
|
else invalidRows.push({
|
|
21743
22094
|
row: Object.values(row),
|
|
@@ -21751,7 +22102,7 @@ var ExcelTS = (function(exports) {
|
|
|
21751
22102
|
}
|
|
21752
22103
|
dataRows = validatedRows;
|
|
21753
22104
|
}
|
|
21754
|
-
if ((strictColumnHandling || validate
|
|
22105
|
+
if ((strictColumnHandling || validate) && invalidRows.length > 0) return {
|
|
21755
22106
|
headers: headerRow.filter((h) => h !== null && h !== void 0),
|
|
21756
22107
|
rows: dataRows,
|
|
21757
22108
|
invalidRows
|
|
@@ -21763,11 +22114,11 @@ var ExcelTS = (function(exports) {
|
|
|
21763
22114
|
}
|
|
21764
22115
|
let resultRows = rows;
|
|
21765
22116
|
if (transform) resultRows = resultRows.map((row) => transform(row)).filter((row) => row !== null && row !== void 0);
|
|
21766
|
-
if (validate
|
|
22117
|
+
if (validate) {
|
|
21767
22118
|
const validatedRows = [];
|
|
21768
22119
|
const arrayInvalidRows = [];
|
|
21769
22120
|
for (const row of resultRows) {
|
|
21770
|
-
const result = validate
|
|
22121
|
+
const result = validate(row);
|
|
21771
22122
|
if (typeof result === "boolean") if (result) validatedRows.push(row);
|
|
21772
22123
|
else arrayInvalidRows.push({
|
|
21773
22124
|
row,
|
|
@@ -21796,7 +22147,7 @@ var ExcelTS = (function(exports) {
|
|
|
21796
22147
|
const quoteEnabled = quoteOption !== false && quoteOption !== null;
|
|
21797
22148
|
const quote = quoteEnabled ? String(quoteOption) : "";
|
|
21798
22149
|
const escape = escapeOption !== void 0 && escapeOption !== false && escapeOption !== null ? String(escapeOption) : quote;
|
|
21799
|
-
const needsQuoteRegex = quoteEnabled ?
|
|
22150
|
+
const needsQuoteRegex = quoteEnabled ? new RegExp(`[${escapeRegex$1(delimiter)}${escapeRegex$1(quote)}\r\n]`) : null;
|
|
21800
22151
|
const escapeQuoteRegex = quoteEnabled ? new RegExp(escapeRegex$1(quote), "g") : null;
|
|
21801
22152
|
const escapedQuote = escape + quote;
|
|
21802
22153
|
const lines = [];
|
|
@@ -22406,7 +22757,7 @@ var ExcelTS = (function(exports) {
|
|
|
22406
22757
|
else str = String(content);
|
|
22407
22758
|
const worksheet = this.workbook.addWorksheet(options?.sheetName);
|
|
22408
22759
|
const dateFormats = options?.dateFormats ?? DEFAULT_DATE_FORMATS;
|
|
22409
|
-
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator
|
|
22760
|
+
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator });
|
|
22410
22761
|
const rows = parseCsv(str, options?.parserOptions);
|
|
22411
22762
|
for (const row of rows) worksheet.addRow(row.map(map));
|
|
22412
22763
|
return worksheet;
|
|
@@ -22434,7 +22785,7 @@ var ExcelTS = (function(exports) {
|
|
|
22434
22785
|
async read(stream, options) {
|
|
22435
22786
|
const worksheet = this.workbook.addWorksheet(options?.sheetName);
|
|
22436
22787
|
const dateFormats = options?.dateFormats ?? DEFAULT_DATE_FORMATS;
|
|
22437
|
-
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator
|
|
22788
|
+
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator });
|
|
22438
22789
|
const parser = new CsvParserStream(options?.parserOptions);
|
|
22439
22790
|
return new Promise((resolve, reject) => {
|
|
22440
22791
|
parser.on("data", (row) => worksheet.addRow(row.map(map)));
|
|
@@ -22486,7 +22837,7 @@ var ExcelTS = (function(exports) {
|
|
|
22486
22837
|
createWriteStream(options) {
|
|
22487
22838
|
const worksheet = this.workbook.addWorksheet(options?.sheetName);
|
|
22488
22839
|
const dateFormats = options?.dateFormats ?? DEFAULT_DATE_FORMATS;
|
|
22489
|
-
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator
|
|
22840
|
+
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator });
|
|
22490
22841
|
const parser = new CsvParserStream(options?.parserOptions);
|
|
22491
22842
|
parser.on("data", (row) => worksheet.addRow(row.map(map)));
|
|
22492
22843
|
return parser;
|
|
@@ -23327,8 +23678,8 @@ var ExcelTS = (function(exports) {
|
|
|
23327
23678
|
media: this.media,
|
|
23328
23679
|
hasCheckboxes: this.styles.hasCheckboxes
|
|
23329
23680
|
};
|
|
23330
|
-
const xform
|
|
23331
|
-
this._addFile(xform
|
|
23681
|
+
const xform = new ContentTypesXform();
|
|
23682
|
+
this._addFile(xform.toXml(model), OOXML_PATHS.contentTypes);
|
|
23332
23683
|
resolve();
|
|
23333
23684
|
});
|
|
23334
23685
|
}
|
|
@@ -23355,30 +23706,30 @@ var ExcelTS = (function(exports) {
|
|
|
23355
23706
|
}
|
|
23356
23707
|
addApp() {
|
|
23357
23708
|
return new Promise((resolve) => {
|
|
23358
|
-
const xform
|
|
23359
|
-
this._addFile(xform
|
|
23709
|
+
const xform = new AppXform();
|
|
23710
|
+
this._addFile(xform.toXml({ worksheets: this._worksheets.filter(Boolean) }), OOXML_PATHS.docPropsApp);
|
|
23360
23711
|
resolve();
|
|
23361
23712
|
});
|
|
23362
23713
|
}
|
|
23363
23714
|
addCore() {
|
|
23364
23715
|
return new Promise((resolve) => {
|
|
23365
|
-
const xform
|
|
23366
|
-
this._addFile(xform
|
|
23716
|
+
const xform = new CoreXform();
|
|
23717
|
+
this._addFile(xform.toXml(this), OOXML_PATHS.docPropsCore);
|
|
23367
23718
|
resolve();
|
|
23368
23719
|
});
|
|
23369
23720
|
}
|
|
23370
23721
|
addSharedStrings() {
|
|
23371
23722
|
if (this.sharedStrings.count) return new Promise((resolve) => {
|
|
23372
|
-
const xform
|
|
23373
|
-
this._addFile(xform
|
|
23723
|
+
const xform = new SharedStringsXform();
|
|
23724
|
+
this._addFile(xform.toXml(this.sharedStrings), OOXML_PATHS.xlSharedStrings);
|
|
23374
23725
|
resolve();
|
|
23375
23726
|
});
|
|
23376
23727
|
return Promise.resolve();
|
|
23377
23728
|
}
|
|
23378
23729
|
addFeaturePropertyBag() {
|
|
23379
23730
|
if (this.styles.hasCheckboxes) {
|
|
23380
|
-
const xform
|
|
23381
|
-
this._addFile(xform
|
|
23731
|
+
const xform = new FeaturePropertyBagXform();
|
|
23732
|
+
this._addFile(xform.toXml({}), OOXML_PATHS.xlFeaturePropertyBag);
|
|
23382
23733
|
}
|
|
23383
23734
|
return Promise.resolve();
|
|
23384
23735
|
}
|
|
@@ -23414,8 +23765,8 @@ var ExcelTS = (function(exports) {
|
|
|
23414
23765
|
}
|
|
23415
23766
|
});
|
|
23416
23767
|
return new Promise((resolve) => {
|
|
23417
|
-
const xform
|
|
23418
|
-
this._addFile(xform
|
|
23768
|
+
const xform = new RelationshipsXform();
|
|
23769
|
+
this._addFile(xform.toXml(relationships), OOXML_PATHS.xlWorkbookRels);
|
|
23419
23770
|
resolve();
|
|
23420
23771
|
});
|
|
23421
23772
|
}
|
|
@@ -23428,9 +23779,9 @@ var ExcelTS = (function(exports) {
|
|
|
23428
23779
|
calcProperties: {}
|
|
23429
23780
|
};
|
|
23430
23781
|
return new Promise((resolve) => {
|
|
23431
|
-
const xform
|
|
23432
|
-
xform
|
|
23433
|
-
this._addFile(xform
|
|
23782
|
+
const xform = new WorkbookXform();
|
|
23783
|
+
xform.prepare(model);
|
|
23784
|
+
this._addFile(xform.toXml(model), OOXML_PATHS.xlWorkbook);
|
|
23434
23785
|
resolve();
|
|
23435
23786
|
});
|
|
23436
23787
|
}
|
|
@@ -23474,11 +23825,11 @@ var ExcelTS = (function(exports) {
|
|
|
23474
23825
|
* ]
|
|
23475
23826
|
* @returns An object with keys set to their associated extracted values.
|
|
23476
23827
|
*/
|
|
23477
|
-
function parse(buffer, format
|
|
23828
|
+
function parse(buffer, format) {
|
|
23478
23829
|
const result = {};
|
|
23479
23830
|
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
23480
23831
|
let offset = 0;
|
|
23481
|
-
for (const [key, size] of format
|
|
23832
|
+
for (const [key, size] of format) {
|
|
23482
23833
|
if (buffer.length >= offset + size) switch (size) {
|
|
23483
23834
|
case 1:
|
|
23484
23835
|
result[key] = view.getUint8(offset);
|
|
@@ -23501,8 +23852,8 @@ var ExcelTS = (function(exports) {
|
|
|
23501
23852
|
}
|
|
23502
23853
|
return result;
|
|
23503
23854
|
}
|
|
23504
|
-
function parseTyped(buffer, format
|
|
23505
|
-
return parse(buffer, format
|
|
23855
|
+
function parseTyped(buffer, format) {
|
|
23856
|
+
return parse(buffer, format);
|
|
23506
23857
|
}
|
|
23507
23858
|
|
|
23508
23859
|
//#endregion
|
|
@@ -23734,14 +24085,14 @@ var ExcelTS = (function(exports) {
|
|
|
23734
24085
|
* This encapsulates the shared logic used by both Node and browser parsers.
|
|
23735
24086
|
*/
|
|
23736
24087
|
function streamUntilValidatedDataDescriptor(options) {
|
|
23737
|
-
const { source, dataDescriptorSignature
|
|
24088
|
+
const { source, dataDescriptorSignature } = options;
|
|
23738
24089
|
const keepTailBytes = options.keepTailBytes ?? 20;
|
|
23739
24090
|
const errorMessage = options.errorMessage ?? "FILE_ENDED: Data descriptor not found";
|
|
23740
24091
|
const output = new PassThrough({ highWaterMark: DEFAULT_UNZIP_STREAM_HIGH_WATER_MARK$1 });
|
|
23741
24092
|
let done = false;
|
|
23742
24093
|
let waitingDrain = false;
|
|
23743
24094
|
let bytesEmitted = 0;
|
|
23744
|
-
const scanner = new PatternScanner(dataDescriptorSignature
|
|
24095
|
+
const scanner = new PatternScanner(dataDescriptorSignature);
|
|
23745
24096
|
let unsubscribe;
|
|
23746
24097
|
const cleanup = () => {
|
|
23747
24098
|
if (unsubscribe) {
|
|
@@ -23819,9 +24170,9 @@ var ExcelTS = (function(exports) {
|
|
|
23819
24170
|
const parts = source.peekChunks(flushLen);
|
|
23820
24171
|
let written = 0;
|
|
23821
24172
|
for (const part of parts) {
|
|
23822
|
-
const ok
|
|
24173
|
+
const ok = output.write(part);
|
|
23823
24174
|
written += part.length;
|
|
23824
|
-
if (!ok
|
|
24175
|
+
if (!ok) {
|
|
23825
24176
|
waitingDrain = true;
|
|
23826
24177
|
output.once("drain", () => {
|
|
23827
24178
|
waitingDrain = false;
|
|
@@ -23913,7 +24264,7 @@ var ExcelTS = (function(exports) {
|
|
|
23913
24264
|
}
|
|
23914
24265
|
}
|
|
23915
24266
|
async function pumpKnownCompressedSizeToEntry(io, inflater, entry, compressedSize) {
|
|
23916
|
-
const CHUNK_SIZE
|
|
24267
|
+
const CHUNK_SIZE = 256 * 1024;
|
|
23917
24268
|
let remaining = compressedSize;
|
|
23918
24269
|
let err = null;
|
|
23919
24270
|
const onError = (e) => {
|
|
@@ -23973,7 +24324,7 @@ var ExcelTS = (function(exports) {
|
|
|
23973
24324
|
while (remaining > 0) {
|
|
23974
24325
|
if (err) throw err;
|
|
23975
24326
|
if (!skipping && (entry.__autodraining || entry.destroyed)) await switchToSkip();
|
|
23976
|
-
const toPull = Math.min(CHUNK_SIZE
|
|
24327
|
+
const toPull = Math.min(CHUNK_SIZE, remaining);
|
|
23977
24328
|
const chunk = await io.pull(toPull);
|
|
23978
24329
|
if (chunk.length !== toPull) throw new Error("FILE_ENDED");
|
|
23979
24330
|
remaining -= chunk.length;
|
|
@@ -24405,7 +24756,7 @@ onmessage = async (ev) => {
|
|
|
24405
24756
|
* - Writable side: accepts ZIP data
|
|
24406
24757
|
* - Readable side: emits ZipEntry objects
|
|
24407
24758
|
*/
|
|
24408
|
-
return class Parse
|
|
24759
|
+
return class Parse extends Duplex {
|
|
24409
24760
|
constructor(opts = {}) {
|
|
24410
24761
|
super({
|
|
24411
24762
|
objectMode: true,
|
|
@@ -24614,10 +24965,10 @@ onmessage = async (ev) => {
|
|
|
24614
24965
|
this.match = match;
|
|
24615
24966
|
const endIndex = includeEof ? match + patternLen : match;
|
|
24616
24967
|
if (endIndex > 0) {
|
|
24617
|
-
const ok
|
|
24968
|
+
const ok = output.write(this._buffer.read(endIndex));
|
|
24618
24969
|
scanner.onConsume(endIndex);
|
|
24619
24970
|
this._maybeReleaseWriteCallback();
|
|
24620
|
-
if (!ok
|
|
24971
|
+
if (!ok) {
|
|
24621
24972
|
waitingDrain = true;
|
|
24622
24973
|
output.once("drain", () => {
|
|
24623
24974
|
waitingDrain = false;
|
|
@@ -25380,10 +25731,10 @@ onmessage = async (ev) => {
|
|
|
25380
25731
|
};
|
|
25381
25732
|
}
|
|
25382
25733
|
async *_parseEntries(stream) {
|
|
25383
|
-
const zip
|
|
25384
|
-
stream.on("error", (err) => zip
|
|
25385
|
-
stream.pipe(zip
|
|
25386
|
-
for await (const entry of iterateStream(zip
|
|
25734
|
+
const zip = createParse({ forceStream: true });
|
|
25735
|
+
stream.on("error", (err) => zip.emit("error", err));
|
|
25736
|
+
stream.pipe(zip);
|
|
25737
|
+
for await (const entry of iterateStream(zip)) {
|
|
25387
25738
|
let sheetNo;
|
|
25388
25739
|
const normalizedPath = normalizeZipPath(entry.path);
|
|
25389
25740
|
switch (normalizedPath) {
|
|
@@ -25433,9 +25784,9 @@ onmessage = async (ev) => {
|
|
|
25433
25784
|
}
|
|
25434
25785
|
async _storeWaitingWorksheet(sheetNo, entry) {
|
|
25435
25786
|
const chunks = [];
|
|
25436
|
-
const encoder
|
|
25787
|
+
const encoder = new TextEncoder();
|
|
25437
25788
|
for await (const chunk of iterateStream(entry)) if (chunk instanceof Uint8Array) chunks.push(chunk);
|
|
25438
|
-
else if (typeof chunk === "string") chunks.push(encoder
|
|
25789
|
+
else if (typeof chunk === "string") chunks.push(encoder.encode(chunk));
|
|
25439
25790
|
return {
|
|
25440
25791
|
sheetNo,
|
|
25441
25792
|
data: chunks
|
|
@@ -25487,6 +25838,8 @@ onmessage = async (ev) => {
|
|
|
25487
25838
|
this.views = [];
|
|
25488
25839
|
this.media = [];
|
|
25489
25840
|
this.pivotTables = [];
|
|
25841
|
+
this._passthrough = {};
|
|
25842
|
+
this._rawDrawings = {};
|
|
25490
25843
|
this._definedNames = new DefinedNames();
|
|
25491
25844
|
}
|
|
25492
25845
|
/**
|
|
@@ -25659,7 +26012,10 @@ onmessage = async (ev) => {
|
|
|
25659
26012
|
themes: this._themes,
|
|
25660
26013
|
media: this.media,
|
|
25661
26014
|
pivotTables: this.pivotTables,
|
|
25662
|
-
calcProperties: this.calcProperties
|
|
26015
|
+
calcProperties: this.calcProperties,
|
|
26016
|
+
passthrough: this._passthrough,
|
|
26017
|
+
rawDrawings: this._rawDrawings,
|
|
26018
|
+
defaultFont: this._defaultFont
|
|
25663
26019
|
};
|
|
25664
26020
|
}
|
|
25665
26021
|
set model(value) {
|
|
@@ -25698,25 +26054,28 @@ onmessage = async (ev) => {
|
|
|
25698
26054
|
this._themes = value.themes;
|
|
25699
26055
|
this.media = value.media || [];
|
|
25700
26056
|
this.pivotTables = value.pivotTables || value.loadedPivotTables || [];
|
|
26057
|
+
this._passthrough = value.passthrough || {};
|
|
26058
|
+
this._rawDrawings = value.rawDrawings || {};
|
|
26059
|
+
this._defaultFont = value.defaultFont;
|
|
25701
26060
|
}
|
|
25702
26061
|
};
|
|
25703
26062
|
|
|
25704
26063
|
//#endregion
|
|
25705
26064
|
//#region src/modules/excel/types.ts
|
|
25706
|
-
let PaperSize = /* @__PURE__ */ function(PaperSize
|
|
25707
|
-
PaperSize
|
|
25708
|
-
PaperSize
|
|
25709
|
-
PaperSize
|
|
25710
|
-
PaperSize
|
|
25711
|
-
PaperSize
|
|
25712
|
-
PaperSize
|
|
25713
|
-
PaperSize
|
|
25714
|
-
PaperSize
|
|
25715
|
-
PaperSize
|
|
25716
|
-
PaperSize
|
|
25717
|
-
PaperSize
|
|
25718
|
-
PaperSize
|
|
25719
|
-
return PaperSize
|
|
26065
|
+
let PaperSize = /* @__PURE__ */ function(PaperSize) {
|
|
26066
|
+
PaperSize[PaperSize["Legal"] = 5] = "Legal";
|
|
26067
|
+
PaperSize[PaperSize["Executive"] = 7] = "Executive";
|
|
26068
|
+
PaperSize[PaperSize["A4"] = 9] = "A4";
|
|
26069
|
+
PaperSize[PaperSize["A5"] = 11] = "A5";
|
|
26070
|
+
PaperSize[PaperSize["B5"] = 13] = "B5";
|
|
26071
|
+
PaperSize[PaperSize["Envelope_10"] = 20] = "Envelope_10";
|
|
26072
|
+
PaperSize[PaperSize["Envelope_DL"] = 27] = "Envelope_DL";
|
|
26073
|
+
PaperSize[PaperSize["Envelope_C5"] = 28] = "Envelope_C5";
|
|
26074
|
+
PaperSize[PaperSize["Envelope_B5"] = 34] = "Envelope_B5";
|
|
26075
|
+
PaperSize[PaperSize["Envelope_Monarch"] = 37] = "Envelope_Monarch";
|
|
26076
|
+
PaperSize[PaperSize["Double_Japan_Postcard_Rotated"] = 82] = "Double_Japan_Postcard_Rotated";
|
|
26077
|
+
PaperSize[PaperSize["K16_197x273_mm"] = 119] = "K16_197x273_mm";
|
|
26078
|
+
return PaperSize;
|
|
25720
26079
|
}({});
|
|
25721
26080
|
|
|
25722
26081
|
//#endregion
|
|
@@ -25913,9 +26272,9 @@ onmessage = async (ev) => {
|
|
|
25913
26272
|
const sign = val < 0 ? "-" : "";
|
|
25914
26273
|
const absVal = Math.abs(val);
|
|
25915
26274
|
if (absVal === 0) {
|
|
25916
|
-
const decMatch
|
|
25917
|
-
const decPlaces
|
|
25918
|
-
return "0." + "0".repeat(decPlaces
|
|
26275
|
+
const decMatch = fmt.match(/\.([0#]+)E/i);
|
|
26276
|
+
const decPlaces = decMatch ? decMatch[1].length : 2;
|
|
26277
|
+
return "0." + "0".repeat(decPlaces) + "E+00";
|
|
25919
26278
|
}
|
|
25920
26279
|
const decMatch = fmt.match(/\.([0#]+)E/i);
|
|
25921
26280
|
const decPlaces = decMatch ? decMatch[1].length : 2;
|
|
@@ -25975,15 +26334,15 @@ onmessage = async (ev) => {
|
|
|
25975
26334
|
const absVal = Math.abs(val);
|
|
25976
26335
|
const fixedDenomMatch = fmt.match(/\?+\s*\/\s*(\d+)/);
|
|
25977
26336
|
if (fixedDenomMatch) {
|
|
25978
|
-
const denom
|
|
25979
|
-
const whole
|
|
25980
|
-
const frac = absVal - whole
|
|
25981
|
-
const numer
|
|
26337
|
+
const denom = parseInt(fixedDenomMatch[1], 10);
|
|
26338
|
+
const whole = Math.floor(absVal);
|
|
26339
|
+
const frac = absVal - whole;
|
|
26340
|
+
const numer = Math.round(frac * denom);
|
|
25982
26341
|
if (fmt.includes("#") || fmt.includes("0")) {
|
|
25983
|
-
if (numer
|
|
25984
|
-
return sign + (whole
|
|
26342
|
+
if (numer === 0) return sign + whole.toString();
|
|
26343
|
+
return sign + (whole > 0 ? whole + " " : "") + numer + "/" + denom;
|
|
25985
26344
|
}
|
|
25986
|
-
return sign + (whole
|
|
26345
|
+
return sign + (whole * denom + numer) + "/" + denom;
|
|
25987
26346
|
}
|
|
25988
26347
|
const denomMatch = fmt.match(/\/\s*(\?+)/);
|
|
25989
26348
|
const maxDigits = denomMatch ? denomMatch[1].length : 2;
|
|
@@ -26112,8 +26471,8 @@ onmessage = async (ev) => {
|
|
|
26112
26471
|
*/
|
|
26113
26472
|
function chooseFormat(fmt, val) {
|
|
26114
26473
|
if (typeof val === "string") {
|
|
26115
|
-
const sections
|
|
26116
|
-
if (sections
|
|
26474
|
+
const sections = splitFormat(fmt);
|
|
26475
|
+
if (sections.length >= 4 && sections[3]) return processQuotedText(sections[3]).replace(/@/g, val);
|
|
26117
26476
|
return val;
|
|
26118
26477
|
}
|
|
26119
26478
|
if (typeof val === "boolean") return val ? "TRUE" : "FALSE";
|
|
@@ -26333,24 +26692,24 @@ onmessage = async (ev) => {
|
|
|
26333
26692
|
* Decode range string to Range object
|
|
26334
26693
|
* @example decodeRange("A1:B2") => {s: {c: 0, r: 0}, e: {c: 1, r: 1}}
|
|
26335
26694
|
*/
|
|
26336
|
-
function decodeRange(range
|
|
26337
|
-
const idx = range
|
|
26695
|
+
function decodeRange(range) {
|
|
26696
|
+
const idx = range.indexOf(":");
|
|
26338
26697
|
if (idx === -1) {
|
|
26339
|
-
const cell = decodeCell(range
|
|
26698
|
+
const cell = decodeCell(range);
|
|
26340
26699
|
return {
|
|
26341
26700
|
s: cell,
|
|
26342
26701
|
e: { ...cell }
|
|
26343
26702
|
};
|
|
26344
26703
|
}
|
|
26345
26704
|
return {
|
|
26346
|
-
s: decodeCell(range
|
|
26347
|
-
e: decodeCell(range
|
|
26705
|
+
s: decodeCell(range.slice(0, idx)),
|
|
26706
|
+
e: decodeCell(range.slice(idx + 1))
|
|
26348
26707
|
};
|
|
26349
26708
|
}
|
|
26350
26709
|
function encodeRange(startOrRange, end) {
|
|
26351
26710
|
if (end === void 0) {
|
|
26352
|
-
const range
|
|
26353
|
-
return encodeRange(range
|
|
26711
|
+
const range = startOrRange;
|
|
26712
|
+
return encodeRange(range.s, range.e);
|
|
26354
26713
|
}
|
|
26355
26714
|
const startStr = encodeCell(startOrRange);
|
|
26356
26715
|
const endStr = encodeCell(end);
|
|
@@ -26463,8 +26822,8 @@ onmessage = async (ev) => {
|
|
|
26463
26822
|
if (endRow < startRow || endCol < startCol) return [];
|
|
26464
26823
|
const headerOpt = o.header;
|
|
26465
26824
|
if (headerOpt === 1) {
|
|
26466
|
-
const result
|
|
26467
|
-
const includeBlank
|
|
26825
|
+
const result = [];
|
|
26826
|
+
const includeBlank = o.blankrows !== false;
|
|
26468
26827
|
for (let row = startRow; row <= endRow; row++) {
|
|
26469
26828
|
const rowData = [];
|
|
26470
26829
|
let isEmpty = true;
|
|
@@ -26477,13 +26836,13 @@ onmessage = async (ev) => {
|
|
|
26477
26836
|
} else if (o.defval !== void 0) rowData[col - startCol] = o.defval;
|
|
26478
26837
|
else rowData[col - startCol] = null;
|
|
26479
26838
|
}
|
|
26480
|
-
if (!isEmpty || includeBlank
|
|
26839
|
+
if (!isEmpty || includeBlank) result.push(rowData);
|
|
26481
26840
|
}
|
|
26482
|
-
return result
|
|
26841
|
+
return result;
|
|
26483
26842
|
}
|
|
26484
26843
|
if (headerOpt === "A") {
|
|
26485
|
-
const result
|
|
26486
|
-
const includeBlank
|
|
26844
|
+
const result = [];
|
|
26845
|
+
const includeBlank = o.blankrows === true;
|
|
26487
26846
|
for (let row = startRow; row <= endRow; row++) {
|
|
26488
26847
|
const rowData = {};
|
|
26489
26848
|
let isEmpty = true;
|
|
@@ -26496,13 +26855,13 @@ onmessage = async (ev) => {
|
|
|
26496
26855
|
isEmpty = false;
|
|
26497
26856
|
} else if (o.defval !== void 0) rowData[key] = o.defval;
|
|
26498
26857
|
}
|
|
26499
|
-
if (!isEmpty || includeBlank
|
|
26858
|
+
if (!isEmpty || includeBlank) result.push(rowData);
|
|
26500
26859
|
}
|
|
26501
|
-
return result
|
|
26860
|
+
return result;
|
|
26502
26861
|
}
|
|
26503
26862
|
if (Array.isArray(headerOpt)) {
|
|
26504
|
-
const result
|
|
26505
|
-
const includeBlank
|
|
26863
|
+
const result = [];
|
|
26864
|
+
const includeBlank = o.blankrows === true;
|
|
26506
26865
|
for (let row = startRow; row <= endRow; row++) {
|
|
26507
26866
|
const rowData = {};
|
|
26508
26867
|
let isEmpty = true;
|
|
@@ -26516,9 +26875,9 @@ onmessage = async (ev) => {
|
|
|
26516
26875
|
isEmpty = false;
|
|
26517
26876
|
} else if (o.defval !== void 0) rowData[key] = o.defval;
|
|
26518
26877
|
}
|
|
26519
|
-
if (!isEmpty || includeBlank
|
|
26878
|
+
if (!isEmpty || includeBlank) result.push(rowData);
|
|
26520
26879
|
}
|
|
26521
|
-
return result
|
|
26880
|
+
return result;
|
|
26522
26881
|
}
|
|
26523
26882
|
const headers = [];
|
|
26524
26883
|
const headerCounts = {};
|
|
@@ -27155,7 +27514,7 @@ onmessage = async (ev) => {
|
|
|
27155
27514
|
stream() {
|
|
27156
27515
|
this._sealed = true;
|
|
27157
27516
|
const queue = createAsyncQueue();
|
|
27158
|
-
const zip
|
|
27517
|
+
const zip = new StreamingZip((err, data, final) => {
|
|
27159
27518
|
if (err) {
|
|
27160
27519
|
queue.fail(err);
|
|
27161
27520
|
return;
|
|
@@ -27174,7 +27533,7 @@ onmessage = async (ev) => {
|
|
|
27174
27533
|
comment: entry.options?.comment,
|
|
27175
27534
|
smartStore: this._options.smartStore
|
|
27176
27535
|
});
|
|
27177
|
-
zip
|
|
27536
|
+
zip.add(file);
|
|
27178
27537
|
if (entry.source instanceof Uint8Array || entry.source instanceof ArrayBuffer || typeof entry.source === "string" || typeof Blob !== "undefined" && entry.source instanceof Blob) {
|
|
27179
27538
|
const bytes = await toUint8Array(entry.source);
|
|
27180
27539
|
await file.push(bytes, true);
|
|
@@ -27184,7 +27543,7 @@ onmessage = async (ev) => {
|
|
|
27184
27543
|
}
|
|
27185
27544
|
await file.complete();
|
|
27186
27545
|
}
|
|
27187
|
-
zip
|
|
27546
|
+
zip.end();
|
|
27188
27547
|
} catch (e) {
|
|
27189
27548
|
queue.fail(e instanceof Error ? e : new Error(String(e)));
|
|
27190
27549
|
}
|
|
@@ -27337,27 +27696,27 @@ onmessage = async (ev) => {
|
|
|
27337
27696
|
});
|
|
27338
27697
|
return;
|
|
27339
27698
|
}
|
|
27340
|
-
const parse
|
|
27699
|
+
const parse = createParse({
|
|
27341
27700
|
...this._options.parse ?? {},
|
|
27342
27701
|
forceStream: true
|
|
27343
27702
|
});
|
|
27344
27703
|
const feedPromise = (async () => {
|
|
27345
27704
|
try {
|
|
27346
27705
|
for await (const chunk of toAsyncIterable(this._source)) await new Promise((resolve, reject) => {
|
|
27347
|
-
parse
|
|
27706
|
+
parse.write(chunk, (err) => {
|
|
27348
27707
|
if (err) reject(err);
|
|
27349
27708
|
else resolve();
|
|
27350
27709
|
});
|
|
27351
27710
|
});
|
|
27352
|
-
parse
|
|
27353
|
-
await parse
|
|
27711
|
+
parse.end();
|
|
27712
|
+
await parse.promise();
|
|
27354
27713
|
} catch (e) {
|
|
27355
|
-
parse
|
|
27714
|
+
parse.destroy(e instanceof Error ? e : new Error(String(e)));
|
|
27356
27715
|
throw e;
|
|
27357
27716
|
}
|
|
27358
27717
|
})();
|
|
27359
27718
|
try {
|
|
27360
|
-
for await (const entry of parse
|
|
27719
|
+
for await (const entry of parse) yield new UnzipEntry({
|
|
27361
27720
|
kind: "stream",
|
|
27362
27721
|
entry
|
|
27363
27722
|
});
|