@cj-tech-master/excelts 4.2.2 → 4.2.3-canary.20260122073152.a9bb6b0
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/utils/parse-sax.d.ts +3 -0
- package/dist/browser/modules/excel/utils/parse-sax.js +32 -13
- 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 +8 -0
- package/dist/browser/modules/excel/workbook.js +9 -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/core/app-xform.js +3 -3
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/browser/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- package/dist/browser/modules/excel/xlsx/xform/list-xform.js +8 -10
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +34 -11
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +256 -86
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +38 -11
- package/dist/browser/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
- package/dist/browser/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +213 -127
- 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/utils/parse-sax.js +32 -13
- package/dist/cjs/modules/excel/utils/passthrough-manager.js +133 -0
- package/dist/cjs/modules/excel/workbook.js +9 -1
- package/dist/cjs/modules/excel/worksheet.js +4 -1
- package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/cjs/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- package/dist/cjs/modules/excel/xlsx/xform/list-xform.js +8 -10
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +256 -86
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +38 -11
- package/dist/cjs/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
- package/dist/cjs/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +213 -127
- 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/utils/parse-sax.js +32 -13
- package/dist/esm/modules/excel/utils/passthrough-manager.js +129 -0
- package/dist/esm/modules/excel/workbook.js +9 -1
- package/dist/esm/modules/excel/worksheet.js +4 -1
- package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/esm/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- package/dist/esm/modules/excel/xlsx/xform/list-xform.js +8 -10
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +256 -86
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +38 -11
- package/dist/esm/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
- package/dist/esm/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +213 -127
- package/dist/esm/modules/stream/streams.browser.js +0 -3
- package/dist/iife/excelts.iife.js +603 -333
- 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/utils/parse-sax.d.ts +3 -0
- package/dist/types/modules/excel/utils/passthrough-manager.d.ts +77 -0
- package/dist/types/modules/excel/workbook.d.ts +8 -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 +34 -11
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v4.2.
|
|
2
|
+
* @cj-tech-master/excelts v4.2.3-canary.20260122073152.a9bb6b0
|
|
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
|
|
@@ -3951,7 +3951,6 @@ var ExcelTS = (function(exports) {
|
|
|
3951
3951
|
yield chunk;
|
|
3952
3952
|
}
|
|
3953
3953
|
}
|
|
3954
|
-
if (streamError) throw streamError;
|
|
3955
3954
|
} finally {
|
|
3956
3955
|
this.off("data", dataHandler);
|
|
3957
3956
|
this.off("end", endHandler);
|
|
@@ -6217,7 +6216,8 @@ var ExcelTS = (function(exports) {
|
|
|
6217
6216
|
tables: Object.values(this.tables).map((table) => table.model),
|
|
6218
6217
|
pivotTables: this.pivotTables,
|
|
6219
6218
|
conditionalFormattings: this.conditionalFormattings,
|
|
6220
|
-
formControls: this.formControls.map((fc) => fc.model)
|
|
6219
|
+
formControls: this.formControls.map((fc) => fc.model),
|
|
6220
|
+
drawing: this._drawing
|
|
6221
6221
|
};
|
|
6222
6222
|
model.cols = Column.toModel(this.columns || []);
|
|
6223
6223
|
const rows = model.rows = [];
|
|
@@ -6272,6 +6272,7 @@ var ExcelTS = (function(exports) {
|
|
|
6272
6272
|
this.pivotTables = value.pivotTables;
|
|
6273
6273
|
this.conditionalFormattings = value.conditionalFormattings;
|
|
6274
6274
|
this.formControls = [];
|
|
6275
|
+
this._drawing = value.drawing;
|
|
6275
6276
|
}
|
|
6276
6277
|
};
|
|
6277
6278
|
|
|
@@ -6764,6 +6765,8 @@ var ExcelTS = (function(exports) {
|
|
|
6764
6765
|
quot: "\"",
|
|
6765
6766
|
apos: "'"
|
|
6766
6767
|
};
|
|
6768
|
+
const HAN_CELL_PREFIXES = /^(ep|cp|dc|dcterms|dcmitype|vt):/;
|
|
6769
|
+
const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
6767
6770
|
const S_TEXT = 0;
|
|
6768
6771
|
const S_OPEN_WAKA = 1;
|
|
6769
6772
|
const S_OPEN_WAKA_BANG = 2;
|
|
@@ -6815,6 +6818,7 @@ var ExcelTS = (function(exports) {
|
|
|
6815
6818
|
this.positionAtNewLine = 0;
|
|
6816
6819
|
this.chunkPosition = 0;
|
|
6817
6820
|
this.ENTITIES = { ...XML_ENTITIES };
|
|
6821
|
+
this.nsPrefix = null;
|
|
6818
6822
|
this.trackPosition = opt?.position !== false;
|
|
6819
6823
|
this.fileName = opt?.fileName;
|
|
6820
6824
|
this.fragment = opt?.fragment ?? false;
|
|
@@ -6849,6 +6853,11 @@ var ExcelTS = (function(exports) {
|
|
|
6849
6853
|
this.chunk = "";
|
|
6850
6854
|
this.i = 0;
|
|
6851
6855
|
this.prevI = 0;
|
|
6856
|
+
this.nsPrefix = null;
|
|
6857
|
+
}
|
|
6858
|
+
stripNsPrefix(name) {
|
|
6859
|
+
const n = name.replace(HAN_CELL_PREFIXES, "");
|
|
6860
|
+
return this.nsPrefix && n.startsWith(this.nsPrefix + ":") ? n.slice(this.nsPrefix.length + 1) : n;
|
|
6852
6861
|
}
|
|
6853
6862
|
on(name, handler) {
|
|
6854
6863
|
switch (name) {
|
|
@@ -7188,7 +7197,7 @@ var ExcelTS = (function(exports) {
|
|
|
7188
7197
|
return;
|
|
7189
7198
|
}
|
|
7190
7199
|
this.tag = {
|
|
7191
|
-
name: this.name,
|
|
7200
|
+
name: this.stripNsPrefix(this.name),
|
|
7192
7201
|
attributes: Object.create(null),
|
|
7193
7202
|
isSelfClosing: false
|
|
7194
7203
|
};
|
|
@@ -7484,8 +7493,7 @@ var ExcelTS = (function(exports) {
|
|
|
7484
7493
|
openTag() {
|
|
7485
7494
|
const tag = this.tag;
|
|
7486
7495
|
tag.isSelfClosing = false;
|
|
7487
|
-
|
|
7488
|
-
this.attribList = [];
|
|
7496
|
+
this.processAttributes(tag);
|
|
7489
7497
|
this.openTagHandler?.(tag);
|
|
7490
7498
|
this.tags.push(tag);
|
|
7491
7499
|
this.name = "";
|
|
@@ -7494,16 +7502,26 @@ var ExcelTS = (function(exports) {
|
|
|
7494
7502
|
openSelfClosingTag() {
|
|
7495
7503
|
const tag = this.tag;
|
|
7496
7504
|
tag.isSelfClosing = true;
|
|
7497
|
-
|
|
7498
|
-
this.attribList = [];
|
|
7505
|
+
this.processAttributes(tag);
|
|
7499
7506
|
this.openTagHandler?.(tag);
|
|
7500
7507
|
this.closeTagHandler?.(tag);
|
|
7501
7508
|
if (this.tags.length === 0) this.closedRoot = true;
|
|
7502
7509
|
this.name = "";
|
|
7503
7510
|
this.state = S_TEXT;
|
|
7504
7511
|
}
|
|
7512
|
+
processAttributes(tag) {
|
|
7513
|
+
for (const { name, value } of this.attribList) {
|
|
7514
|
+
tag.attributes[name] = value;
|
|
7515
|
+
if (name.startsWith("xmlns:") && value === SPREADSHEETML_NS) {
|
|
7516
|
+
this.nsPrefix = name.slice(6);
|
|
7517
|
+
tag.name = this.stripNsPrefix(tag.name);
|
|
7518
|
+
}
|
|
7519
|
+
}
|
|
7520
|
+
this.attribList = [];
|
|
7521
|
+
}
|
|
7505
7522
|
closeTag() {
|
|
7506
|
-
const { tags
|
|
7523
|
+
const { tags } = this;
|
|
7524
|
+
const name = this.stripNsPrefix(this.name);
|
|
7507
7525
|
this.state = S_TEXT;
|
|
7508
7526
|
this.name = "";
|
|
7509
7527
|
if (name === "") {
|
|
@@ -7730,17 +7748,15 @@ var ExcelTS = (function(exports) {
|
|
|
7730
7748
|
this.parser.parseOpen(node);
|
|
7731
7749
|
return true;
|
|
7732
7750
|
}
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
return true;
|
|
7737
|
-
default:
|
|
7738
|
-
if (this.childXform.parseOpen(node)) {
|
|
7739
|
-
this.parser = this.childXform;
|
|
7740
|
-
return true;
|
|
7741
|
-
}
|
|
7742
|
-
return false;
|
|
7751
|
+
if (node.name === this.tag) {
|
|
7752
|
+
this.model = [];
|
|
7753
|
+
return true;
|
|
7743
7754
|
}
|
|
7755
|
+
if (this.childXform.parseOpen(node)) {
|
|
7756
|
+
this.parser = this.childXform;
|
|
7757
|
+
return true;
|
|
7758
|
+
}
|
|
7759
|
+
return false;
|
|
7744
7760
|
}
|
|
7745
7761
|
parseText(text) {
|
|
7746
7762
|
if (this.parser) this.parser.parseText(text);
|
|
@@ -9591,34 +9607,52 @@ var ExcelTS = (function(exports) {
|
|
|
9591
9607
|
|
|
9592
9608
|
//#endregion
|
|
9593
9609
|
//#region src/modules/excel/xlsx/xform/core/core-xform.ts
|
|
9610
|
+
const PROPS = {
|
|
9611
|
+
creator: "dc:creator",
|
|
9612
|
+
title: "dc:title",
|
|
9613
|
+
subject: "dc:subject",
|
|
9614
|
+
description: "dc:description",
|
|
9615
|
+
identifier: "dc:identifier",
|
|
9616
|
+
language: "dc:language",
|
|
9617
|
+
keywords: "cp:keywords",
|
|
9618
|
+
category: "cp:category",
|
|
9619
|
+
lastModifiedBy: "cp:lastModifiedBy",
|
|
9620
|
+
lastPrinted: "cp:lastPrinted",
|
|
9621
|
+
revision: "cp:revision",
|
|
9622
|
+
version: "cp:version",
|
|
9623
|
+
contentStatus: "cp:contentStatus",
|
|
9624
|
+
contentType: "cp:contentType",
|
|
9625
|
+
created: "dcterms:created",
|
|
9626
|
+
modified: "dcterms:modified"
|
|
9627
|
+
};
|
|
9594
9628
|
var CoreXform = class CoreXform extends BaseXform {
|
|
9595
9629
|
constructor() {
|
|
9596
9630
|
super();
|
|
9597
9631
|
this.map = {
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
tag:
|
|
9632
|
+
creator: new StringXform({ tag: PROPS.creator }),
|
|
9633
|
+
title: new StringXform({ tag: PROPS.title }),
|
|
9634
|
+
subject: new StringXform({ tag: PROPS.subject }),
|
|
9635
|
+
description: new StringXform({ tag: PROPS.description }),
|
|
9636
|
+
identifier: new StringXform({ tag: PROPS.identifier }),
|
|
9637
|
+
language: new StringXform({ tag: PROPS.language }),
|
|
9638
|
+
keywords: new StringXform({ tag: PROPS.keywords }),
|
|
9639
|
+
category: new StringXform({ tag: PROPS.category }),
|
|
9640
|
+
lastModifiedBy: new StringXform({ tag: PROPS.lastModifiedBy }),
|
|
9641
|
+
lastPrinted: new DateXform({
|
|
9642
|
+
tag: PROPS.lastPrinted,
|
|
9609
9643
|
format: CoreXform.DateFormat
|
|
9610
9644
|
}),
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
tag:
|
|
9645
|
+
revision: new IntegerXform({ tag: PROPS.revision }),
|
|
9646
|
+
version: new StringXform({ tag: PROPS.version }),
|
|
9647
|
+
contentStatus: new StringXform({ tag: PROPS.contentStatus }),
|
|
9648
|
+
contentType: new StringXform({ tag: PROPS.contentType }),
|
|
9649
|
+
created: new DateXform({
|
|
9650
|
+
tag: PROPS.created,
|
|
9617
9651
|
attrs: CoreXform.DateAttrs,
|
|
9618
9652
|
format: CoreXform.DateFormat
|
|
9619
9653
|
}),
|
|
9620
|
-
|
|
9621
|
-
tag:
|
|
9654
|
+
modified: new DateXform({
|
|
9655
|
+
tag: PROPS.modified,
|
|
9622
9656
|
attrs: CoreXform.DateAttrs,
|
|
9623
9657
|
format: CoreXform.DateFormat
|
|
9624
9658
|
})
|
|
@@ -9627,22 +9661,7 @@ var ExcelTS = (function(exports) {
|
|
|
9627
9661
|
render(xmlStream, model) {
|
|
9628
9662
|
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
9629
9663
|
xmlStream.openNode("cp:coreProperties", CoreXform.CORE_PROPERTY_ATTRIBUTES);
|
|
9630
|
-
this.map[
|
|
9631
|
-
this.map["dc:title"].render(xmlStream, model.title);
|
|
9632
|
-
this.map["dc:subject"].render(xmlStream, model.subject);
|
|
9633
|
-
this.map["dc:description"].render(xmlStream, model.description);
|
|
9634
|
-
this.map["dc:identifier"].render(xmlStream, model.identifier);
|
|
9635
|
-
this.map["dc:language"].render(xmlStream, model.language);
|
|
9636
|
-
this.map["cp:keywords"].render(xmlStream, model.keywords);
|
|
9637
|
-
this.map["cp:category"].render(xmlStream, model.category);
|
|
9638
|
-
this.map["cp:lastModifiedBy"].render(xmlStream, model.lastModifiedBy);
|
|
9639
|
-
this.map["cp:lastPrinted"].render(xmlStream, model.lastPrinted);
|
|
9640
|
-
this.map["cp:revision"].render(xmlStream, model.revision);
|
|
9641
|
-
this.map["cp:version"].render(xmlStream, model.version);
|
|
9642
|
-
this.map["cp:contentStatus"].render(xmlStream, model.contentStatus);
|
|
9643
|
-
this.map["cp:contentType"].render(xmlStream, model.contentType);
|
|
9644
|
-
this.map["dcterms:created"].render(xmlStream, model.created);
|
|
9645
|
-
this.map["dcterms:modified"].render(xmlStream, model.modified);
|
|
9664
|
+
for (const key of Object.keys(PROPS)) this.map[key].render(xmlStream, model[key]);
|
|
9646
9665
|
xmlStream.closeNode();
|
|
9647
9666
|
}
|
|
9648
9667
|
parseOpen(node) {
|
|
@@ -9650,17 +9669,11 @@ var ExcelTS = (function(exports) {
|
|
|
9650
9669
|
this.parser.parseOpen(node);
|
|
9651
9670
|
return true;
|
|
9652
9671
|
}
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
default:
|
|
9657
|
-
this.parser = this.map[node.name];
|
|
9658
|
-
if (this.parser) {
|
|
9659
|
-
this.parser.parseOpen(node);
|
|
9660
|
-
return true;
|
|
9661
|
-
}
|
|
9662
|
-
throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`);
|
|
9672
|
+
if (node.name !== "coreProperties") {
|
|
9673
|
+
this.parser = this.map[node.name];
|
|
9674
|
+
if (this.parser) this.parser.parseOpen(node);
|
|
9663
9675
|
}
|
|
9676
|
+
return true;
|
|
9664
9677
|
}
|
|
9665
9678
|
parseText(text) {
|
|
9666
9679
|
if (this.parser) this.parser.parseText(text);
|
|
@@ -9670,29 +9683,15 @@ var ExcelTS = (function(exports) {
|
|
|
9670
9683
|
if (!this.parser.parseClose(name)) this.parser = void 0;
|
|
9671
9684
|
return true;
|
|
9672
9685
|
}
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
this.model
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
description: this.map["dc:description"].model,
|
|
9681
|
-
identifier: this.map["dc:identifier"].model,
|
|
9682
|
-
language: this.map["dc:language"].model,
|
|
9683
|
-
keywords: this.map["cp:keywords"].model,
|
|
9684
|
-
category: this.map["cp:category"].model,
|
|
9685
|
-
lastModifiedBy: this.map["cp:lastModifiedBy"].model,
|
|
9686
|
-
lastPrinted: this.map["cp:lastPrinted"].model,
|
|
9687
|
-
revision: this.map["cp:revision"].model,
|
|
9688
|
-
contentStatus: this.map["cp:contentStatus"].model,
|
|
9689
|
-
contentType: this.map["cp:contentType"].model,
|
|
9690
|
-
created: this.map["dcterms:created"].model,
|
|
9691
|
-
modified: this.map["dcterms:modified"].model
|
|
9692
|
-
};
|
|
9693
|
-
return false;
|
|
9694
|
-
default: throw new Error(`Unexpected xml node in parseClose: ${name}`);
|
|
9686
|
+
if (name === "coreProperties") {
|
|
9687
|
+
this.model = {};
|
|
9688
|
+
for (const key of Object.keys(PROPS)) {
|
|
9689
|
+
const val = this.map[key].model;
|
|
9690
|
+
if (val !== void 0 && val !== "") this.model[key] = val;
|
|
9691
|
+
}
|
|
9692
|
+
return false;
|
|
9695
9693
|
}
|
|
9694
|
+
return true;
|
|
9696
9695
|
}
|
|
9697
9696
|
static {
|
|
9698
9697
|
this.DateFormat = function(dt) {
|
|
@@ -9726,13 +9725,12 @@ var ExcelTS = (function(exports) {
|
|
|
9726
9725
|
xmlStream.closeNode();
|
|
9727
9726
|
}
|
|
9728
9727
|
parseOpen(node) {
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
return true;
|
|
9734
|
-
default: return false;
|
|
9728
|
+
if (node.name === "t") {
|
|
9729
|
+
this._text = [];
|
|
9730
|
+
this.model = "";
|
|
9731
|
+
return true;
|
|
9735
9732
|
}
|
|
9733
|
+
return false;
|
|
9736
9734
|
}
|
|
9737
9735
|
parseText(text) {
|
|
9738
9736
|
this._text.push(text);
|
|
@@ -9913,16 +9911,15 @@ var ExcelTS = (function(exports) {
|
|
|
9913
9911
|
xmlStream.closeNode();
|
|
9914
9912
|
}
|
|
9915
9913
|
parseOpen(node) {
|
|
9916
|
-
const { name } = node;
|
|
9917
9914
|
if (this.parser) {
|
|
9918
9915
|
this.parser.parseOpen(node);
|
|
9919
9916
|
return true;
|
|
9920
9917
|
}
|
|
9921
|
-
if (name === this.tag) {
|
|
9918
|
+
if (node.name === this.tag) {
|
|
9922
9919
|
this.model = {};
|
|
9923
9920
|
return true;
|
|
9924
9921
|
}
|
|
9925
|
-
this.parser = this.map[name];
|
|
9922
|
+
this.parser = this.map[node.name];
|
|
9926
9923
|
if (this.parser) {
|
|
9927
9924
|
this.parser.parseOpen(node);
|
|
9928
9925
|
return true;
|
|
@@ -10411,28 +10408,26 @@ var ExcelTS = (function(exports) {
|
|
|
10411
10408
|
ContentType: "application/vnd.openxmlformats-officedocument.drawing+xml"
|
|
10412
10409
|
});
|
|
10413
10410
|
});
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
});
|
|
10425
|
-
}
|
|
10426
|
-
if (model.formControlRefs) {
|
|
10427
|
-
if (!model.commentRefs) xmlStream.leafNode("Default", {
|
|
10428
|
-
Extension: "vml",
|
|
10429
|
-
ContentType: "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
10430
|
-
});
|
|
10431
|
-
for (const ctrlPropId of model.formControlRefs) xmlStream.leafNode("Override", {
|
|
10432
|
-
PartName: toContentTypesPartName(ctrlPropPath(ctrlPropId)),
|
|
10433
|
-
ContentType: "application/vnd.ms-excel.controlproperties+xml"
|
|
10411
|
+
const hasComments = model.commentRefs && model.commentRefs.length > 0;
|
|
10412
|
+
const hasFormControls = model.formControlRefs && model.formControlRefs.length > 0;
|
|
10413
|
+
if (hasComments || hasFormControls) xmlStream.leafNode("Default", {
|
|
10414
|
+
Extension: "vml",
|
|
10415
|
+
ContentType: "application/vnd.openxmlformats-officedocument.vmlDrawing"
|
|
10416
|
+
});
|
|
10417
|
+
if (hasComments) model.commentRefs.forEach(({ commentName }) => {
|
|
10418
|
+
xmlStream.leafNode("Override", {
|
|
10419
|
+
PartName: toContentTypesPartName(commentsPathFromName(commentName)),
|
|
10420
|
+
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
|
|
10434
10421
|
});
|
|
10435
|
-
}
|
|
10422
|
+
});
|
|
10423
|
+
if (hasFormControls) for (const ctrlPropId of model.formControlRefs) xmlStream.leafNode("Override", {
|
|
10424
|
+
PartName: toContentTypesPartName(ctrlPropPath(ctrlPropId)),
|
|
10425
|
+
ContentType: "application/vnd.ms-excel.controlproperties+xml"
|
|
10426
|
+
});
|
|
10427
|
+
if (model.passthroughContentTypes) for (const { partName, contentType } of model.passthroughContentTypes) xmlStream.leafNode("Override", {
|
|
10428
|
+
PartName: toContentTypesPartName(partName),
|
|
10429
|
+
ContentType: contentType
|
|
10430
|
+
});
|
|
10436
10431
|
xmlStream.leafNode("Override", {
|
|
10437
10432
|
PartName: toContentTypesPartName(OOXML_PATHS.docPropsCore),
|
|
10438
10433
|
ContentType: "application/vnd.openxmlformats-package.core-properties+xml"
|
|
@@ -10515,7 +10510,7 @@ var ExcelTS = (function(exports) {
|
|
|
10515
10510
|
Company: new StringXform({ tag: "Company" }),
|
|
10516
10511
|
Manager: new StringXform({ tag: "Manager" }),
|
|
10517
10512
|
HeadingPairs: new AppHeadingPairsXform(),
|
|
10518
|
-
|
|
10513
|
+
TitlesOfParts: new AppTitlesOfPartsXform()
|
|
10519
10514
|
};
|
|
10520
10515
|
}
|
|
10521
10516
|
render(xmlStream, model) {
|
|
@@ -10525,7 +10520,7 @@ var ExcelTS = (function(exports) {
|
|
|
10525
10520
|
xmlStream.leafNode("DocSecurity", void 0, "0");
|
|
10526
10521
|
xmlStream.leafNode("ScaleCrop", void 0, "false");
|
|
10527
10522
|
this.map.HeadingPairs.render(xmlStream, model.worksheets);
|
|
10528
|
-
this.map.
|
|
10523
|
+
this.map.TitlesOfParts.render(xmlStream, model.worksheets);
|
|
10529
10524
|
this.map.Company.render(xmlStream, model.company || "");
|
|
10530
10525
|
this.map.Manager.render(xmlStream, model.manager);
|
|
10531
10526
|
xmlStream.leafNode("LinksUpToDate", void 0, "false");
|
|
@@ -10561,7 +10556,7 @@ var ExcelTS = (function(exports) {
|
|
|
10561
10556
|
switch (name) {
|
|
10562
10557
|
case "Properties":
|
|
10563
10558
|
this.model = {
|
|
10564
|
-
worksheets: this.map.
|
|
10559
|
+
worksheets: this.map.TitlesOfParts.model,
|
|
10565
10560
|
company: this.map.Company.model,
|
|
10566
10561
|
manager: this.map.Manager.model
|
|
10567
10562
|
};
|
|
@@ -13867,6 +13862,17 @@ var ExcelTS = (function(exports) {
|
|
|
13867
13862
|
vmlDrawing: `vmlDrawing${model.id}`
|
|
13868
13863
|
});
|
|
13869
13864
|
}
|
|
13865
|
+
if (model.drawing && model.drawing.anchors) {
|
|
13866
|
+
const drawing = model.drawing;
|
|
13867
|
+
drawing.rId = nextRid(rels);
|
|
13868
|
+
if (!drawing.name) drawing.name = `drawing${++options.drawingsCount}`;
|
|
13869
|
+
options.drawings.push(drawing);
|
|
13870
|
+
rels.push({
|
|
13871
|
+
Id: drawing.rId,
|
|
13872
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
|
|
13873
|
+
Target: drawingRelTargetFromWorksheet(drawing.name)
|
|
13874
|
+
});
|
|
13875
|
+
}
|
|
13870
13876
|
const drawingRelsHash = [];
|
|
13871
13877
|
let bookImage;
|
|
13872
13878
|
model.media.forEach((medium) => {
|
|
@@ -14204,17 +14210,25 @@ var ExcelTS = (function(exports) {
|
|
|
14204
14210
|
const match = rels[model.drawing.rId].Target.match(/\/drawings\/([a-zA-Z0-9]+)[.][a-zA-Z]{3,4}$/);
|
|
14205
14211
|
if (match) {
|
|
14206
14212
|
const drawingName = match[1];
|
|
14207
|
-
options.drawings[drawingName]
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14213
|
+
const drawing = options.drawings[drawingName];
|
|
14214
|
+
if (drawing) {
|
|
14215
|
+
model.drawing = {
|
|
14216
|
+
...drawing,
|
|
14217
|
+
name: drawingName,
|
|
14218
|
+
rels: options.drawingRels?.[drawingName] || drawing.rels || []
|
|
14219
|
+
};
|
|
14220
|
+
drawing.anchors.forEach((anchor) => {
|
|
14221
|
+
if (anchor.medium) {
|
|
14222
|
+
const image = {
|
|
14223
|
+
type: "image",
|
|
14224
|
+
imageId: anchor.medium.index,
|
|
14225
|
+
range: anchor.range,
|
|
14226
|
+
hyperlinks: anchor.picture.hyperlinks
|
|
14227
|
+
};
|
|
14228
|
+
model.media.push(image);
|
|
14229
|
+
}
|
|
14230
|
+
});
|
|
14231
|
+
}
|
|
14218
14232
|
}
|
|
14219
14233
|
}
|
|
14220
14234
|
const backgroundRel = model.background && rels[model.background.rId];
|
|
@@ -15966,18 +15980,27 @@ var ExcelTS = (function(exports) {
|
|
|
15966
15980
|
var PivotTableXform = class PivotTableXform extends BaseXform {
|
|
15967
15981
|
constructor() {
|
|
15968
15982
|
super();
|
|
15983
|
+
this.state = {
|
|
15984
|
+
inPivotFields: false,
|
|
15985
|
+
inRowFields: false,
|
|
15986
|
+
inColFields: false,
|
|
15987
|
+
inDataFields: false,
|
|
15988
|
+
inRowItems: false,
|
|
15989
|
+
inColItems: false,
|
|
15990
|
+
inLocation: false,
|
|
15991
|
+
inItems: false,
|
|
15992
|
+
inPivotTableStyleInfo: false,
|
|
15993
|
+
inChartFormats: false,
|
|
15994
|
+
inPivotArea: false
|
|
15995
|
+
};
|
|
15996
|
+
this.currentPivotField = null;
|
|
15997
|
+
this.currentRowItem = null;
|
|
15998
|
+
this.currentColItem = null;
|
|
15999
|
+
this.currentChartFormat = null;
|
|
16000
|
+
this.pivotAreaXmlBuffer = [];
|
|
16001
|
+
this.pivotAreaDepth = 0;
|
|
15969
16002
|
this.map = {};
|
|
15970
16003
|
this.model = null;
|
|
15971
|
-
this.inPivotFields = false;
|
|
15972
|
-
this.inRowFields = false;
|
|
15973
|
-
this.inColFields = false;
|
|
15974
|
-
this.inDataFields = false;
|
|
15975
|
-
this.inRowItems = false;
|
|
15976
|
-
this.inColItems = false;
|
|
15977
|
-
this.inLocation = false;
|
|
15978
|
-
this.currentPivotField = null;
|
|
15979
|
-
this.inItems = false;
|
|
15980
|
-
this.inPivotTableStyleInfo = false;
|
|
15981
16004
|
}
|
|
15982
16005
|
prepare(_model) {}
|
|
15983
16006
|
get tag() {
|
|
@@ -15985,16 +16008,15 @@ var ExcelTS = (function(exports) {
|
|
|
15985
16008
|
}
|
|
15986
16009
|
reset() {
|
|
15987
16010
|
this.model = null;
|
|
15988
|
-
this.
|
|
15989
|
-
|
|
15990
|
-
|
|
15991
|
-
this.inDataFields = false;
|
|
15992
|
-
this.inRowItems = false;
|
|
15993
|
-
this.inColItems = false;
|
|
15994
|
-
this.inLocation = false;
|
|
16011
|
+
Object.keys(this.state).forEach((key) => {
|
|
16012
|
+
this.state[key] = false;
|
|
16013
|
+
});
|
|
15995
16014
|
this.currentPivotField = null;
|
|
15996
|
-
this.
|
|
15997
|
-
this.
|
|
16015
|
+
this.currentRowItem = null;
|
|
16016
|
+
this.currentColItem = null;
|
|
16017
|
+
this.currentChartFormat = null;
|
|
16018
|
+
this.pivotAreaXmlBuffer = [];
|
|
16019
|
+
this.pivotAreaDepth = 0;
|
|
15998
16020
|
}
|
|
15999
16021
|
/**
|
|
16000
16022
|
* Render pivot table XML.
|
|
@@ -16093,8 +16115,7 @@ var ExcelTS = (function(exports) {
|
|
|
16093
16115
|
* Render loaded pivot table (preserving original structure)
|
|
16094
16116
|
*/
|
|
16095
16117
|
renderLoaded(xmlStream, model) {
|
|
16096
|
-
|
|
16097
|
-
xmlStream.openNode(this.tag, {
|
|
16118
|
+
const attrs = {
|
|
16098
16119
|
...PivotTableXform.PIVOT_TABLE_ATTRIBUTES,
|
|
16099
16120
|
name: model.name || "PivotTable1",
|
|
16100
16121
|
cacheId: model.cacheId,
|
|
@@ -16103,7 +16124,7 @@ var ExcelTS = (function(exports) {
|
|
|
16103
16124
|
applyFontFormats: model.applyFontFormats || "0",
|
|
16104
16125
|
applyPatternFormats: model.applyPatternFormats || "0",
|
|
16105
16126
|
applyAlignmentFormats: model.applyAlignmentFormats || "0",
|
|
16106
|
-
applyWidthHeightFormats: model.applyWidthHeightFormats
|
|
16127
|
+
applyWidthHeightFormats: model.applyWidthHeightFormats ?? "0",
|
|
16107
16128
|
dataCaption: model.dataCaption || "Values",
|
|
16108
16129
|
updatedVersion: model.updatedVersion || "8",
|
|
16109
16130
|
minRefreshableVersion: model.minRefreshableVersion || "3",
|
|
@@ -16111,10 +16132,15 @@ var ExcelTS = (function(exports) {
|
|
|
16111
16132
|
itemPrintTitles: model.itemPrintTitles ? "1" : "0",
|
|
16112
16133
|
createdVersion: model.createdVersion || "8",
|
|
16113
16134
|
indent: model.indent !== void 0 ? String(model.indent) : "0",
|
|
16114
|
-
compact: model.compact ? "1" : "0",
|
|
16115
|
-
compactData: model.compactData ? "1" : "0",
|
|
16116
16135
|
multipleFieldFilters: model.multipleFieldFilters ? "1" : "0"
|
|
16117
|
-
}
|
|
16136
|
+
};
|
|
16137
|
+
if (model.outline) attrs.outline = "1";
|
|
16138
|
+
if (model.outlineData) attrs.outlineData = "1";
|
|
16139
|
+
if (model.chartFormat !== void 0) attrs.chartFormat = String(model.chartFormat);
|
|
16140
|
+
if (model.compact) attrs.compact = "1";
|
|
16141
|
+
if (model.compactData) attrs.compactData = "1";
|
|
16142
|
+
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
16143
|
+
xmlStream.openNode(this.tag, attrs);
|
|
16118
16144
|
if (model.location) xmlStream.leafNode("location", {
|
|
16119
16145
|
ref: model.location.ref,
|
|
16120
16146
|
firstHeaderRow: model.location.firstHeaderRow,
|
|
@@ -16131,30 +16157,46 @@ var ExcelTS = (function(exports) {
|
|
|
16131
16157
|
for (const fieldIndex of model.rowFields) xmlStream.leafNode("field", { x: fieldIndex });
|
|
16132
16158
|
xmlStream.closeNode();
|
|
16133
16159
|
}
|
|
16134
|
-
|
|
16135
|
-
|
|
16136
|
-
|
|
16137
|
-
|
|
16160
|
+
if (model.rowItems && model.rowItems.length > 0) {
|
|
16161
|
+
xmlStream.openNode("rowItems", { count: model.rowItems.length });
|
|
16162
|
+
for (const item of model.rowItems) this.renderRowColItem(xmlStream, item);
|
|
16163
|
+
xmlStream.closeNode();
|
|
16164
|
+
} else xmlStream.writeXml("<rowItems count=\"1\"><i t=\"grand\"><x/></i></rowItems>");
|
|
16138
16165
|
const colFieldCount = model.colFields.length === 0 ? 1 : model.colFields.length;
|
|
16139
16166
|
xmlStream.openNode("colFields", { count: colFieldCount });
|
|
16140
16167
|
if (model.colFields.length === 0) xmlStream.leafNode("field", { x: -2 });
|
|
16141
16168
|
else for (const fieldIndex of model.colFields) xmlStream.leafNode("field", { x: fieldIndex });
|
|
16142
16169
|
xmlStream.closeNode();
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16170
|
+
if (model.colItems && model.colItems.length > 0) {
|
|
16171
|
+
xmlStream.openNode("colItems", { count: model.colItems.length });
|
|
16172
|
+
for (const item of model.colItems) this.renderRowColItem(xmlStream, item);
|
|
16173
|
+
xmlStream.closeNode();
|
|
16174
|
+
} else xmlStream.writeXml("<colItems count=\"1\"><i t=\"grand\"><x/></i></colItems>");
|
|
16147
16175
|
if (model.dataFields.length > 0) {
|
|
16148
16176
|
xmlStream.openNode("dataFields", { count: model.dataFields.length });
|
|
16149
16177
|
for (const dataField of model.dataFields) {
|
|
16150
|
-
const
|
|
16178
|
+
const dfAttrs = {
|
|
16151
16179
|
name: dataField.name,
|
|
16152
16180
|
fld: dataField.fld,
|
|
16153
16181
|
baseField: dataField.baseField ?? 0,
|
|
16154
16182
|
baseItem: dataField.baseItem ?? 0
|
|
16155
16183
|
};
|
|
16156
|
-
if (dataField.subtotal && dataField.subtotal !== "sum")
|
|
16157
|
-
xmlStream.leafNode("dataField",
|
|
16184
|
+
if (dataField.subtotal && dataField.subtotal !== "sum") dfAttrs.subtotal = dataField.subtotal;
|
|
16185
|
+
xmlStream.leafNode("dataField", dfAttrs);
|
|
16186
|
+
}
|
|
16187
|
+
xmlStream.closeNode();
|
|
16188
|
+
}
|
|
16189
|
+
if (model.chartFormats && model.chartFormats.length > 0) {
|
|
16190
|
+
xmlStream.openNode("chartFormats", { count: model.chartFormats.length });
|
|
16191
|
+
for (const cf of model.chartFormats) {
|
|
16192
|
+
xmlStream.openNode("chartFormat", {
|
|
16193
|
+
chart: cf.chart,
|
|
16194
|
+
format: cf.format,
|
|
16195
|
+
series: cf.series ? "1" : void 0
|
|
16196
|
+
});
|
|
16197
|
+
if (cf.pivotAreaXml) xmlStream.writeXml(cf.pivotAreaXml);
|
|
16198
|
+
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>`);
|
|
16199
|
+
xmlStream.closeNode();
|
|
16158
16200
|
}
|
|
16159
16201
|
xmlStream.closeNode();
|
|
16160
16202
|
}
|
|
@@ -16166,47 +16208,35 @@ var ExcelTS = (function(exports) {
|
|
|
16166
16208
|
showColStripes: "0",
|
|
16167
16209
|
showLastColumn: "1"
|
|
16168
16210
|
});
|
|
16169
|
-
xmlStream.writeXml(
|
|
16170
|
-
<extLst>
|
|
16171
|
-
<ext
|
|
16172
|
-
uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}"
|
|
16173
|
-
xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
16174
|
-
>
|
|
16175
|
-
<x14:pivotTableDefinition
|
|
16176
|
-
hideValuesRow="1"
|
|
16177
|
-
xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main"
|
|
16178
|
-
/>
|
|
16179
|
-
</ext>
|
|
16180
|
-
<ext
|
|
16181
|
-
uri="{747A6164-185A-40DC-8AA5-F01512510D54}"
|
|
16182
|
-
xmlns:xpdl="http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout"
|
|
16183
|
-
>
|
|
16184
|
-
<xpdl:pivotTableDefinition16
|
|
16185
|
-
EnabledSubtotalsDefault="0"
|
|
16186
|
-
SubtotalsOnTopDefault="0"
|
|
16187
|
-
/>
|
|
16188
|
-
</ext>
|
|
16189
|
-
</extLst>
|
|
16190
|
-
`);
|
|
16211
|
+
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>`);
|
|
16191
16212
|
xmlStream.closeNode();
|
|
16192
16213
|
}
|
|
16193
16214
|
/**
|
|
16215
|
+
* Render a row or column item element
|
|
16216
|
+
*/
|
|
16217
|
+
renderRowColItem(xmlStream, item) {
|
|
16218
|
+
const attrs = {};
|
|
16219
|
+
if (item.t) attrs.t = item.t;
|
|
16220
|
+
if (item.x && item.x.length > 0) {
|
|
16221
|
+
xmlStream.openNode("i", attrs);
|
|
16222
|
+
for (const x of item.x) if (x.v && x.v !== 0) xmlStream.leafNode("x", { v: x.v });
|
|
16223
|
+
else xmlStream.leafNode("x");
|
|
16224
|
+
xmlStream.closeNode();
|
|
16225
|
+
} else xmlStream.leafNode("i", attrs);
|
|
16226
|
+
}
|
|
16227
|
+
/**
|
|
16194
16228
|
* Render a loaded pivot field
|
|
16195
16229
|
*/
|
|
16196
16230
|
renderPivotFieldLoaded(xmlStream, field) {
|
|
16197
|
-
const attrs = {
|
|
16198
|
-
compact: field.compact ? "1" : "0",
|
|
16199
|
-
outline: field.outline ? "1" : "0",
|
|
16200
|
-
showAll: field.showAll ? "1" : "0",
|
|
16201
|
-
defaultSubtotal: field.defaultSubtotal ? "1" : "0"
|
|
16202
|
-
};
|
|
16231
|
+
const attrs = {};
|
|
16203
16232
|
if (field.axis) attrs.axis = field.axis;
|
|
16204
16233
|
if (field.dataField) attrs.dataField = "1";
|
|
16234
|
+
attrs.showAll = field.showAll ? "1" : "0";
|
|
16205
16235
|
if (field.items && field.items.length > 0) {
|
|
16206
16236
|
xmlStream.openNode("pivotField", attrs);
|
|
16207
16237
|
xmlStream.openNode("items", { count: field.items.length + 1 });
|
|
16208
16238
|
for (const itemIndex of field.items) xmlStream.leafNode("item", { x: itemIndex });
|
|
16209
|
-
xmlStream.writeXml("<item t=\"default\"
|
|
16239
|
+
xmlStream.writeXml("<item t=\"default\"/>");
|
|
16210
16240
|
xmlStream.closeNode();
|
|
16211
16241
|
xmlStream.closeNode();
|
|
16212
16242
|
} else xmlStream.leafNode("pivotField", attrs);
|
|
@@ -16240,6 +16270,12 @@ var ExcelTS = (function(exports) {
|
|
|
16240
16270
|
compact: attributes.compact === "1",
|
|
16241
16271
|
compactData: attributes.compactData === "1",
|
|
16242
16272
|
multipleFieldFilters: attributes.multipleFieldFilters === "1",
|
|
16273
|
+
outline: attributes.outline === "1",
|
|
16274
|
+
outlineData: attributes.outlineData === "1",
|
|
16275
|
+
chartFormat: attributes.chartFormat ? parseInt(attributes.chartFormat, 10) : void 0,
|
|
16276
|
+
rowItems: [],
|
|
16277
|
+
colItems: [],
|
|
16278
|
+
chartFormats: [],
|
|
16243
16279
|
isLoaded: true
|
|
16244
16280
|
};
|
|
16245
16281
|
break;
|
|
@@ -16252,10 +16288,10 @@ var ExcelTS = (function(exports) {
|
|
|
16252
16288
|
};
|
|
16253
16289
|
break;
|
|
16254
16290
|
case "pivotFields":
|
|
16255
|
-
this.inPivotFields = true;
|
|
16291
|
+
this.state.inPivotFields = true;
|
|
16256
16292
|
break;
|
|
16257
16293
|
case "pivotField":
|
|
16258
|
-
if (this.inPivotFields) this.currentPivotField = {
|
|
16294
|
+
if (this.state.inPivotFields) this.currentPivotField = {
|
|
16259
16295
|
axis: attributes.axis,
|
|
16260
16296
|
dataField: attributes.dataField === "1",
|
|
16261
16297
|
items: [],
|
|
@@ -16266,35 +16302,77 @@ var ExcelTS = (function(exports) {
|
|
|
16266
16302
|
};
|
|
16267
16303
|
break;
|
|
16268
16304
|
case "items":
|
|
16269
|
-
if (this.currentPivotField) this.inItems = true;
|
|
16305
|
+
if (this.currentPivotField) this.state.inItems = true;
|
|
16270
16306
|
break;
|
|
16271
16307
|
case "item":
|
|
16272
|
-
if (this.inItems && this.currentPivotField && attributes.x !== void 0) this.currentPivotField.items.push(parseInt(attributes.x, 10));
|
|
16308
|
+
if (this.state.inItems && this.currentPivotField && attributes.x !== void 0) this.currentPivotField.items.push(parseInt(attributes.x, 10));
|
|
16273
16309
|
break;
|
|
16274
16310
|
case "rowFields":
|
|
16275
|
-
this.inRowFields = true;
|
|
16311
|
+
this.state.inRowFields = true;
|
|
16276
16312
|
break;
|
|
16277
16313
|
case "colFields":
|
|
16278
|
-
this.inColFields = true;
|
|
16314
|
+
this.state.inColFields = true;
|
|
16279
16315
|
break;
|
|
16280
16316
|
case "dataFields":
|
|
16281
|
-
this.inDataFields = true;
|
|
16317
|
+
this.state.inDataFields = true;
|
|
16282
16318
|
break;
|
|
16283
16319
|
case "rowItems":
|
|
16284
|
-
this.inRowItems = true;
|
|
16320
|
+
this.state.inRowItems = true;
|
|
16285
16321
|
break;
|
|
16286
16322
|
case "colItems":
|
|
16287
|
-
this.inColItems = true;
|
|
16323
|
+
this.state.inColItems = true;
|
|
16324
|
+
break;
|
|
16325
|
+
case "i":
|
|
16326
|
+
if (this.state.inRowItems && this.model) this.currentRowItem = {
|
|
16327
|
+
t: attributes.t,
|
|
16328
|
+
x: []
|
|
16329
|
+
};
|
|
16330
|
+
else if (this.state.inColItems && this.model) this.currentColItem = {
|
|
16331
|
+
t: attributes.t,
|
|
16332
|
+
x: []
|
|
16333
|
+
};
|
|
16334
|
+
break;
|
|
16335
|
+
case "x":
|
|
16336
|
+
if (this.state.inPivotArea) {
|
|
16337
|
+
const xAttrs = Object.entries(attributes).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
16338
|
+
this.pivotAreaXmlBuffer.push(xAttrs ? `<x ${xAttrs}/>` : "<x/>");
|
|
16339
|
+
} else if (this.currentRowItem) this.currentRowItem.x.push({ v: attributes.v ? parseInt(attributes.v, 10) : 0 });
|
|
16340
|
+
else if (this.currentColItem) this.currentColItem.x.push({ v: attributes.v ? parseInt(attributes.v, 10) : 0 });
|
|
16341
|
+
break;
|
|
16342
|
+
case "chartFormats":
|
|
16343
|
+
this.state.inChartFormats = true;
|
|
16344
|
+
break;
|
|
16345
|
+
case "chartFormat":
|
|
16346
|
+
if (this.state.inChartFormats && this.model) this.currentChartFormat = {
|
|
16347
|
+
chart: attributes.chart ? parseInt(attributes.chart, 10) : 0,
|
|
16348
|
+
format: attributes.format ? parseInt(attributes.format, 10) : 0,
|
|
16349
|
+
series: attributes.series === "1"
|
|
16350
|
+
};
|
|
16351
|
+
break;
|
|
16352
|
+
case "pivotArea":
|
|
16353
|
+
if (this.currentChartFormat) {
|
|
16354
|
+
this.state.inPivotArea = true;
|
|
16355
|
+
const attrsStr = Object.entries(attributes).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
16356
|
+
this.pivotAreaXmlBuffer = [attrsStr ? `<pivotArea ${attrsStr}>` : "<pivotArea>"];
|
|
16357
|
+
}
|
|
16358
|
+
break;
|
|
16359
|
+
case "references":
|
|
16360
|
+
case "reference":
|
|
16361
|
+
if (this.state.inPivotArea) {
|
|
16362
|
+
this.pivotAreaDepth++;
|
|
16363
|
+
const attrsStr = Object.entries(attributes).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
16364
|
+
this.pivotAreaXmlBuffer.push(`<${name}${attrsStr ? " " + attrsStr : ""}>`);
|
|
16365
|
+
}
|
|
16288
16366
|
break;
|
|
16289
16367
|
case "field":
|
|
16290
16368
|
if (this.model) {
|
|
16291
16369
|
const fieldIndex = parseInt(attributes.x || "0", 10);
|
|
16292
|
-
if (this.inRowFields) this.model.rowFields.push(fieldIndex);
|
|
16293
|
-
else if (this.inColFields) this.model.colFields.push(fieldIndex);
|
|
16370
|
+
if (this.state.inRowFields) this.model.rowFields.push(fieldIndex);
|
|
16371
|
+
else if (this.state.inColFields) this.model.colFields.push(fieldIndex);
|
|
16294
16372
|
}
|
|
16295
16373
|
break;
|
|
16296
16374
|
case "dataField":
|
|
16297
|
-
if (this.inDataFields && this.model) this.model.dataFields.push({
|
|
16375
|
+
if (this.state.inDataFields && this.model) this.model.dataFields.push({
|
|
16298
16376
|
name: xmlDecode(attributes.name || ""),
|
|
16299
16377
|
fld: parseInt(attributes.fld || "0", 10),
|
|
16300
16378
|
baseField: attributes.baseField ? parseInt(attributes.baseField, 10) : 0,
|
|
@@ -16310,10 +16388,25 @@ var ExcelTS = (function(exports) {
|
|
|
16310
16388
|
}
|
|
16311
16389
|
parseText(_text) {}
|
|
16312
16390
|
parseClose(name) {
|
|
16391
|
+
if (this.state.inPivotArea) {
|
|
16392
|
+
if (name === "pivotArea") {
|
|
16393
|
+
this.pivotAreaXmlBuffer.push("</pivotArea>");
|
|
16394
|
+
if (this.currentChartFormat) this.currentChartFormat.pivotAreaXml = this.pivotAreaXmlBuffer.join("");
|
|
16395
|
+
this.state.inPivotArea = false;
|
|
16396
|
+
this.pivotAreaXmlBuffer = [];
|
|
16397
|
+
this.pivotAreaDepth = 0;
|
|
16398
|
+
return true;
|
|
16399
|
+
} else if (name === "references" || name === "reference") {
|
|
16400
|
+
this.pivotAreaXmlBuffer.push(`</${name}>`);
|
|
16401
|
+
this.pivotAreaDepth--;
|
|
16402
|
+
return true;
|
|
16403
|
+
}
|
|
16404
|
+
return true;
|
|
16405
|
+
}
|
|
16313
16406
|
switch (name) {
|
|
16314
16407
|
case this.tag: return false;
|
|
16315
16408
|
case "pivotFields":
|
|
16316
|
-
this.inPivotFields = false;
|
|
16409
|
+
this.state.inPivotFields = false;
|
|
16317
16410
|
break;
|
|
16318
16411
|
case "pivotField":
|
|
16319
16412
|
if (this.currentPivotField && this.model) {
|
|
@@ -16322,22 +16415,40 @@ var ExcelTS = (function(exports) {
|
|
|
16322
16415
|
}
|
|
16323
16416
|
break;
|
|
16324
16417
|
case "items":
|
|
16325
|
-
this.inItems = false;
|
|
16418
|
+
this.state.inItems = false;
|
|
16326
16419
|
break;
|
|
16327
16420
|
case "rowFields":
|
|
16328
|
-
this.inRowFields = false;
|
|
16421
|
+
this.state.inRowFields = false;
|
|
16329
16422
|
break;
|
|
16330
16423
|
case "colFields":
|
|
16331
|
-
this.inColFields = false;
|
|
16424
|
+
this.state.inColFields = false;
|
|
16332
16425
|
break;
|
|
16333
16426
|
case "dataFields":
|
|
16334
|
-
this.inDataFields = false;
|
|
16427
|
+
this.state.inDataFields = false;
|
|
16335
16428
|
break;
|
|
16336
16429
|
case "rowItems":
|
|
16337
|
-
this.inRowItems = false;
|
|
16430
|
+
this.state.inRowItems = false;
|
|
16338
16431
|
break;
|
|
16339
16432
|
case "colItems":
|
|
16340
|
-
this.inColItems = false;
|
|
16433
|
+
this.state.inColItems = false;
|
|
16434
|
+
break;
|
|
16435
|
+
case "i":
|
|
16436
|
+
if (this.currentRowItem && this.model) {
|
|
16437
|
+
this.model.rowItems.push(this.currentRowItem);
|
|
16438
|
+
this.currentRowItem = null;
|
|
16439
|
+
} else if (this.currentColItem && this.model) {
|
|
16440
|
+
this.model.colItems.push(this.currentColItem);
|
|
16441
|
+
this.currentColItem = null;
|
|
16442
|
+
}
|
|
16443
|
+
break;
|
|
16444
|
+
case "chartFormats":
|
|
16445
|
+
this.state.inChartFormats = false;
|
|
16446
|
+
break;
|
|
16447
|
+
case "chartFormat":
|
|
16448
|
+
if (this.currentChartFormat && this.model) {
|
|
16449
|
+
this.model.chartFormats.push(this.currentChartFormat);
|
|
16450
|
+
this.currentChartFormat = null;
|
|
16451
|
+
}
|
|
16341
16452
|
break;
|
|
16342
16453
|
}
|
|
16343
16454
|
return true;
|
|
@@ -20210,6 +20321,115 @@ var ExcelTS = (function(exports) {
|
|
|
20210
20321
|
}
|
|
20211
20322
|
};
|
|
20212
20323
|
|
|
20324
|
+
//#endregion
|
|
20325
|
+
//#region src/modules/excel/utils/passthrough-manager.ts
|
|
20326
|
+
/**
|
|
20327
|
+
* Content type definitions for passthrough files
|
|
20328
|
+
*/
|
|
20329
|
+
const PASSTHROUGH_CONTENT_TYPES = new Map([
|
|
20330
|
+
[/^xl\/charts\/chart\d+\.xml$/, "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"],
|
|
20331
|
+
[/^xl\/charts\/style\d+\.xml$/, "application/vnd.ms-office.chartstyle+xml"],
|
|
20332
|
+
[/^xl\/charts\/colors\d+\.xml$/, "application/vnd.ms-office.chartcolorstyle+xml"]
|
|
20333
|
+
]);
|
|
20334
|
+
/**
|
|
20335
|
+
* Passthrough path prefixes that should be preserved
|
|
20336
|
+
*/
|
|
20337
|
+
const PASSTHROUGH_PREFIXES = ["xl/charts/"];
|
|
20338
|
+
/**
|
|
20339
|
+
* PassthroughManager handles storage and retrieval of passthrough files
|
|
20340
|
+
* that need to be preserved during Excel read/write cycles.
|
|
20341
|
+
*/
|
|
20342
|
+
var PassthroughManager = class PassthroughManager {
|
|
20343
|
+
constructor() {
|
|
20344
|
+
this.files = /* @__PURE__ */ new Map();
|
|
20345
|
+
}
|
|
20346
|
+
/**
|
|
20347
|
+
* Check if a path should be treated as passthrough
|
|
20348
|
+
*/
|
|
20349
|
+
static isPassthroughPath(path) {
|
|
20350
|
+
return PASSTHROUGH_PREFIXES.some((prefix) => path.startsWith(prefix));
|
|
20351
|
+
}
|
|
20352
|
+
/**
|
|
20353
|
+
* Get the content type for a passthrough file path
|
|
20354
|
+
* @returns Content type string or undefined if unknown
|
|
20355
|
+
*/
|
|
20356
|
+
static getContentType(path) {
|
|
20357
|
+
if (path.startsWith("xl/charts/_rels/")) return;
|
|
20358
|
+
for (const [regex, contentType] of PASSTHROUGH_CONTENT_TYPES) if (regex.test(path)) return contentType;
|
|
20359
|
+
}
|
|
20360
|
+
/**
|
|
20361
|
+
* Add a file to passthrough storage
|
|
20362
|
+
*/
|
|
20363
|
+
add(path, data) {
|
|
20364
|
+
this.files.set(path, data);
|
|
20365
|
+
}
|
|
20366
|
+
/**
|
|
20367
|
+
* Get a file from passthrough storage
|
|
20368
|
+
*/
|
|
20369
|
+
get(path) {
|
|
20370
|
+
return this.files.get(path);
|
|
20371
|
+
}
|
|
20372
|
+
/**
|
|
20373
|
+
* Check if a file exists in passthrough storage
|
|
20374
|
+
*/
|
|
20375
|
+
has(path) {
|
|
20376
|
+
return this.files.has(path);
|
|
20377
|
+
}
|
|
20378
|
+
/**
|
|
20379
|
+
* Get all stored paths
|
|
20380
|
+
*/
|
|
20381
|
+
getPaths() {
|
|
20382
|
+
return [...this.files.keys()];
|
|
20383
|
+
}
|
|
20384
|
+
/**
|
|
20385
|
+
* Get all files as a record (for serialization)
|
|
20386
|
+
*/
|
|
20387
|
+
toRecord() {
|
|
20388
|
+
const record = {};
|
|
20389
|
+
for (const [path, data] of this.files) record[path] = data;
|
|
20390
|
+
return record;
|
|
20391
|
+
}
|
|
20392
|
+
/**
|
|
20393
|
+
* Load files from a record (for deserialization)
|
|
20394
|
+
*/
|
|
20395
|
+
fromRecord(record) {
|
|
20396
|
+
this.files.clear();
|
|
20397
|
+
for (const [path, data] of Object.entries(record)) this.files.set(path, data);
|
|
20398
|
+
}
|
|
20399
|
+
/**
|
|
20400
|
+
* Get content types for all stored files that have known types
|
|
20401
|
+
*/
|
|
20402
|
+
getContentTypes() {
|
|
20403
|
+
const contentTypes = [];
|
|
20404
|
+
for (const path of this.files.keys()) {
|
|
20405
|
+
const contentType = PassthroughManager.getContentType(path);
|
|
20406
|
+
if (contentType) contentTypes.push({
|
|
20407
|
+
partName: path,
|
|
20408
|
+
contentType
|
|
20409
|
+
});
|
|
20410
|
+
}
|
|
20411
|
+
return contentTypes;
|
|
20412
|
+
}
|
|
20413
|
+
/**
|
|
20414
|
+
* Write all passthrough files to a ZIP writer
|
|
20415
|
+
*/
|
|
20416
|
+
writeToZip(zip$1) {
|
|
20417
|
+
for (const [path, data] of this.files) zip$1.append(data, { name: path });
|
|
20418
|
+
}
|
|
20419
|
+
/**
|
|
20420
|
+
* Clear all stored files
|
|
20421
|
+
*/
|
|
20422
|
+
clear() {
|
|
20423
|
+
this.files.clear();
|
|
20424
|
+
}
|
|
20425
|
+
/**
|
|
20426
|
+
* Get the number of stored files
|
|
20427
|
+
*/
|
|
20428
|
+
get size() {
|
|
20429
|
+
return this.files.size;
|
|
20430
|
+
}
|
|
20431
|
+
};
|
|
20432
|
+
|
|
20213
20433
|
//#endregion
|
|
20214
20434
|
//#region src/modules/excel/xlsx/xlsx.browser.ts
|
|
20215
20435
|
/**
|
|
@@ -20360,6 +20580,7 @@ var ExcelTS = (function(exports) {
|
|
|
20360
20580
|
this.addDrawings(zip$1, model);
|
|
20361
20581
|
this.addTables(zip$1, model);
|
|
20362
20582
|
this.addPivotTables(zip$1, model);
|
|
20583
|
+
this.addPassthrough(zip$1, model);
|
|
20363
20584
|
await Promise.all([this.addThemes(zip$1, model), this.addStyles(zip$1, model)]);
|
|
20364
20585
|
await this.addFeaturePropertyBag(zip$1, model);
|
|
20365
20586
|
await this.addMedia(zip$1, model);
|
|
@@ -20433,8 +20654,12 @@ var ExcelTS = (function(exports) {
|
|
|
20433
20654
|
* This is the foundation for TRUE streaming reads on platforms that have a
|
|
20434
20655
|
* streaming ZIP parser (e.g. Node.js `modules/archive` Parse).
|
|
20435
20656
|
*/
|
|
20436
|
-
|
|
20437
|
-
|
|
20657
|
+
/**
|
|
20658
|
+
* Create an empty model for parsing XLSX files.
|
|
20659
|
+
* Shared by loadFromZipEntries and loadFromFiles.
|
|
20660
|
+
*/
|
|
20661
|
+
createEmptyModel() {
|
|
20662
|
+
return {
|
|
20438
20663
|
worksheets: [],
|
|
20439
20664
|
worksheetHash: {},
|
|
20440
20665
|
worksheetRels: [],
|
|
@@ -20443,6 +20668,7 @@ var ExcelTS = (function(exports) {
|
|
|
20443
20668
|
mediaIndex: {},
|
|
20444
20669
|
drawings: {},
|
|
20445
20670
|
drawingRels: {},
|
|
20671
|
+
rawDrawings: {},
|
|
20446
20672
|
comments: {},
|
|
20447
20673
|
tables: {},
|
|
20448
20674
|
vmlDrawings: {},
|
|
@@ -20450,8 +20676,93 @@ var ExcelTS = (function(exports) {
|
|
|
20450
20676
|
pivotTableRels: {},
|
|
20451
20677
|
pivotCacheDefinitions: {},
|
|
20452
20678
|
pivotCacheDefinitionRels: {},
|
|
20453
|
-
pivotCacheRecords: {}
|
|
20679
|
+
pivotCacheRecords: {},
|
|
20680
|
+
passthrough: {}
|
|
20454
20681
|
};
|
|
20682
|
+
}
|
|
20683
|
+
/**
|
|
20684
|
+
* Collect all data from a stream into a single Uint8Array.
|
|
20685
|
+
* Reusable helper for passthrough and drawing processing.
|
|
20686
|
+
*/
|
|
20687
|
+
async collectStreamData(stream) {
|
|
20688
|
+
const chunks = [];
|
|
20689
|
+
await new Promise((resolve, reject) => {
|
|
20690
|
+
stream.on("data", (chunk) => {
|
|
20691
|
+
if (typeof chunk === "string") chunks.push(new TextEncoder().encode(chunk));
|
|
20692
|
+
else if (chunk instanceof Uint8Array) chunks.push(chunk);
|
|
20693
|
+
else chunks.push(new Uint8Array(chunk));
|
|
20694
|
+
});
|
|
20695
|
+
stream.on("end", () => resolve());
|
|
20696
|
+
stream.on("error", reject);
|
|
20697
|
+
});
|
|
20698
|
+
return concatUint8Arrays$2(chunks);
|
|
20699
|
+
}
|
|
20700
|
+
/**
|
|
20701
|
+
* Check if a drawing has chart references in its relationships
|
|
20702
|
+
*/
|
|
20703
|
+
drawingHasChartReference(drawing) {
|
|
20704
|
+
return drawing.rels && drawing.rels.some((rel) => rel.Target && rel.Target.includes("/charts/"));
|
|
20705
|
+
}
|
|
20706
|
+
/**
|
|
20707
|
+
* Check if a drawing rels list references charts.
|
|
20708
|
+
* Used to decide whether we need to keep raw drawing XML for passthrough.
|
|
20709
|
+
*/
|
|
20710
|
+
drawingRelsHasChartReference(drawingRels) {
|
|
20711
|
+
return Array.isArray(drawingRels) && drawingRels.some((rel) => typeof rel?.Target === "string" && rel.Target.includes("/charts/"));
|
|
20712
|
+
}
|
|
20713
|
+
/**
|
|
20714
|
+
* Process a known OOXML entry (workbook, styles, shared strings, etc.)
|
|
20715
|
+
* Returns true if handled, false if should be passed to _processDefaultEntry
|
|
20716
|
+
*/
|
|
20717
|
+
async _processKnownEntry(stream, model, entryName, options) {
|
|
20718
|
+
const sheetNo = getWorksheetNoFromWorksheetPath(entryName);
|
|
20719
|
+
if (sheetNo !== void 0) {
|
|
20720
|
+
await this._processWorksheetEntry(stream, model, sheetNo, options, entryName);
|
|
20721
|
+
return true;
|
|
20722
|
+
}
|
|
20723
|
+
switch (entryName) {
|
|
20724
|
+
case OOXML_PATHS.rootRels:
|
|
20725
|
+
model.globalRels = await this.parseRels(stream);
|
|
20726
|
+
return true;
|
|
20727
|
+
case OOXML_PATHS.xlWorkbook: {
|
|
20728
|
+
const workbook = await this.parseWorkbook(stream);
|
|
20729
|
+
model.sheets = workbook.sheets;
|
|
20730
|
+
model.definedNames = workbook.definedNames;
|
|
20731
|
+
model.views = workbook.views;
|
|
20732
|
+
model.properties = workbook.properties;
|
|
20733
|
+
model.calcProperties = workbook.calcProperties;
|
|
20734
|
+
model.pivotCaches = workbook.pivotCaches;
|
|
20735
|
+
return true;
|
|
20736
|
+
}
|
|
20737
|
+
case OOXML_PATHS.xlSharedStrings:
|
|
20738
|
+
model.sharedStrings = new SharedStringsXform();
|
|
20739
|
+
await model.sharedStrings.parseStream(stream);
|
|
20740
|
+
return true;
|
|
20741
|
+
case OOXML_PATHS.xlWorkbookRels:
|
|
20742
|
+
model.workbookRels = await this.parseRels(stream);
|
|
20743
|
+
return true;
|
|
20744
|
+
case OOXML_PATHS.docPropsApp: {
|
|
20745
|
+
const appProperties = await new AppXform().parseStream(stream);
|
|
20746
|
+
if (appProperties) {
|
|
20747
|
+
model.company = appProperties.company;
|
|
20748
|
+
model.manager = appProperties.manager;
|
|
20749
|
+
}
|
|
20750
|
+
return true;
|
|
20751
|
+
}
|
|
20752
|
+
case OOXML_PATHS.docPropsCore: {
|
|
20753
|
+
const coreProperties = await new CoreXform().parseStream(stream);
|
|
20754
|
+
Object.assign(model, coreProperties);
|
|
20755
|
+
return true;
|
|
20756
|
+
}
|
|
20757
|
+
case OOXML_PATHS.xlStyles:
|
|
20758
|
+
model.styles = new StylesXform();
|
|
20759
|
+
await model.styles.parseStream(stream);
|
|
20760
|
+
return true;
|
|
20761
|
+
default: return false;
|
|
20762
|
+
}
|
|
20763
|
+
}
|
|
20764
|
+
async loadFromZipEntries(entries, options) {
|
|
20765
|
+
const model = this.createEmptyModel();
|
|
20455
20766
|
for await (const entry of entries) {
|
|
20456
20767
|
let drained = false;
|
|
20457
20768
|
const drainEntry = async () => {
|
|
@@ -20466,50 +20777,8 @@ var ExcelTS = (function(exports) {
|
|
|
20466
20777
|
const entryName = normalizeZipPath(entry.name);
|
|
20467
20778
|
const stream = entry.stream;
|
|
20468
20779
|
try {
|
|
20469
|
-
|
|
20470
|
-
|
|
20471
|
-
await this._processWorksheetEntry(stream, model, sheetNo, options, entryName);
|
|
20472
|
-
continue;
|
|
20473
|
-
}
|
|
20474
|
-
switch (entryName) {
|
|
20475
|
-
case OOXML_PATHS.rootRels:
|
|
20476
|
-
model.globalRels = await this.parseRels(stream);
|
|
20477
|
-
break;
|
|
20478
|
-
case OOXML_PATHS.xlWorkbook: {
|
|
20479
|
-
const workbook = await this.parseWorkbook(stream);
|
|
20480
|
-
model.sheets = workbook.sheets;
|
|
20481
|
-
model.definedNames = workbook.definedNames;
|
|
20482
|
-
model.views = workbook.views;
|
|
20483
|
-
model.properties = workbook.properties;
|
|
20484
|
-
model.calcProperties = workbook.calcProperties;
|
|
20485
|
-
model.pivotCaches = workbook.pivotCaches;
|
|
20486
|
-
break;
|
|
20487
|
-
}
|
|
20488
|
-
case OOXML_PATHS.xlSharedStrings:
|
|
20489
|
-
model.sharedStrings = new SharedStringsXform();
|
|
20490
|
-
await model.sharedStrings.parseStream(stream);
|
|
20491
|
-
break;
|
|
20492
|
-
case OOXML_PATHS.xlWorkbookRels:
|
|
20493
|
-
model.workbookRels = await this.parseRels(stream);
|
|
20494
|
-
break;
|
|
20495
|
-
case OOXML_PATHS.docPropsApp: {
|
|
20496
|
-
const appProperties = await new AppXform().parseStream(stream);
|
|
20497
|
-
model.company = appProperties.company;
|
|
20498
|
-
model.manager = appProperties.manager;
|
|
20499
|
-
break;
|
|
20500
|
-
}
|
|
20501
|
-
case OOXML_PATHS.docPropsCore: {
|
|
20502
|
-
const coreProperties = await new CoreXform().parseStream(stream);
|
|
20503
|
-
Object.assign(model, coreProperties);
|
|
20504
|
-
break;
|
|
20505
|
-
}
|
|
20506
|
-
case OOXML_PATHS.xlStyles:
|
|
20507
|
-
model.styles = new StylesXform();
|
|
20508
|
-
await model.styles.parseStream(stream);
|
|
20509
|
-
break;
|
|
20510
|
-
default:
|
|
20511
|
-
if (!await this._processDefaultEntry(stream, model, entryName)) await drainEntry();
|
|
20512
|
-
break;
|
|
20780
|
+
if (!await this._processKnownEntry(stream, model, entryName, options)) {
|
|
20781
|
+
if (!await this._processDefaultEntry(stream, model, entryName)) await drainEntry();
|
|
20513
20782
|
}
|
|
20514
20783
|
} finally {
|
|
20515
20784
|
try {
|
|
@@ -20598,6 +20867,10 @@ var ExcelTS = (function(exports) {
|
|
|
20598
20867
|
drawingXform.reconcile(drawing, drawingOptions);
|
|
20599
20868
|
}
|
|
20600
20869
|
});
|
|
20870
|
+
if (model.rawDrawings && model.drawingRels) for (const name of Object.keys(model.rawDrawings)) {
|
|
20871
|
+
const drawingRel = model.drawingRels[name];
|
|
20872
|
+
if (drawingRel && !this.drawingRelsHasChartReference(drawingRel)) delete model.rawDrawings[name];
|
|
20873
|
+
}
|
|
20601
20874
|
const tableOptions = { styles: model.styles };
|
|
20602
20875
|
Object.values(model.tables).forEach((table) => {
|
|
20603
20876
|
tableXform.reconcile(table, tableOptions);
|
|
@@ -20610,6 +20883,7 @@ var ExcelTS = (function(exports) {
|
|
|
20610
20883
|
mediaIndex: model.mediaIndex,
|
|
20611
20884
|
date1904: model.properties && model.properties.date1904,
|
|
20612
20885
|
drawings: model.drawings,
|
|
20886
|
+
drawingRels: model.drawingRels,
|
|
20613
20887
|
comments: model.comments,
|
|
20614
20888
|
tables: model.tables,
|
|
20615
20889
|
vmlDrawings: model.vmlDrawings,
|
|
@@ -20766,8 +21040,12 @@ var ExcelTS = (function(exports) {
|
|
|
20766
21040
|
}
|
|
20767
21041
|
}
|
|
20768
21042
|
async _processDrawingEntry(entry, model, name) {
|
|
20769
|
-
const
|
|
21043
|
+
const rawData = await this.collectStreamData(entry);
|
|
21044
|
+
const xform$1 = new DrawingXform();
|
|
21045
|
+
const xmlString = this.bufferToString(rawData);
|
|
21046
|
+
const drawing = await xform$1.parseStream(this.createTextStream(xmlString));
|
|
20770
21047
|
model.drawings[name] = drawing;
|
|
21048
|
+
model.rawDrawings[name] = rawData;
|
|
20771
21049
|
}
|
|
20772
21050
|
async _processDrawingRelsEntry(entry, model, name) {
|
|
20773
21051
|
const relationships = await new RelationshipsXform().parseStream(entry);
|
|
@@ -20822,24 +21100,7 @@ var ExcelTS = (function(exports) {
|
|
|
20822
21100
|
if (cacheRecords) model.pivotCacheRecords[name] = cacheRecords;
|
|
20823
21101
|
}
|
|
20824
21102
|
async loadFromFiles(zipData, options) {
|
|
20825
|
-
const model =
|
|
20826
|
-
worksheets: [],
|
|
20827
|
-
worksheetHash: {},
|
|
20828
|
-
worksheetRels: [],
|
|
20829
|
-
themes: {},
|
|
20830
|
-
media: [],
|
|
20831
|
-
mediaIndex: {},
|
|
20832
|
-
drawings: {},
|
|
20833
|
-
drawingRels: {},
|
|
20834
|
-
comments: {},
|
|
20835
|
-
tables: {},
|
|
20836
|
-
vmlDrawings: {},
|
|
20837
|
-
pivotTables: {},
|
|
20838
|
-
pivotTableRels: {},
|
|
20839
|
-
pivotCacheDefinitions: {},
|
|
20840
|
-
pivotCacheDefinitionRels: {},
|
|
20841
|
-
pivotCacheRecords: {}
|
|
20842
|
-
};
|
|
21103
|
+
const model = this.createEmptyModel();
|
|
20843
21104
|
const entries = Object.keys(zipData).map((name) => ({
|
|
20844
21105
|
name,
|
|
20845
21106
|
dir: name.endsWith("/"),
|
|
@@ -20848,46 +21109,7 @@ var ExcelTS = (function(exports) {
|
|
|
20848
21109
|
for (const entry of entries) if (!entry.dir) {
|
|
20849
21110
|
const entryName = normalizeZipPath(entry.name);
|
|
20850
21111
|
const stream = isBinaryEntryPath(entryName) ? this.createBinaryStream(entry.data) : this.createTextStream(this.bufferToString(entry.data));
|
|
20851
|
-
|
|
20852
|
-
if (sheetNo !== void 0) await this._processWorksheetEntry(stream, model, sheetNo, options, entryName);
|
|
20853
|
-
else switch (entryName) {
|
|
20854
|
-
case OOXML_PATHS.rootRels:
|
|
20855
|
-
model.globalRels = await this.parseRels(stream);
|
|
20856
|
-
break;
|
|
20857
|
-
case OOXML_PATHS.xlWorkbook: {
|
|
20858
|
-
const workbook = await this.parseWorkbook(stream);
|
|
20859
|
-
model.sheets = workbook.sheets;
|
|
20860
|
-
model.definedNames = workbook.definedNames;
|
|
20861
|
-
model.views = workbook.views;
|
|
20862
|
-
model.properties = workbook.properties;
|
|
20863
|
-
model.calcProperties = workbook.calcProperties;
|
|
20864
|
-
model.pivotCaches = workbook.pivotCaches;
|
|
20865
|
-
break;
|
|
20866
|
-
}
|
|
20867
|
-
case OOXML_PATHS.xlSharedStrings:
|
|
20868
|
-
model.sharedStrings = new SharedStringsXform();
|
|
20869
|
-
await model.sharedStrings.parseStream(stream);
|
|
20870
|
-
break;
|
|
20871
|
-
case OOXML_PATHS.xlWorkbookRels:
|
|
20872
|
-
model.workbookRels = await this.parseRels(stream);
|
|
20873
|
-
break;
|
|
20874
|
-
case OOXML_PATHS.docPropsApp: {
|
|
20875
|
-
const appProperties = await new AppXform().parseStream(stream);
|
|
20876
|
-
model.company = appProperties.company;
|
|
20877
|
-
model.manager = appProperties.manager;
|
|
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
|
-
}
|
|
21112
|
+
if (!await this._processKnownEntry(stream, model, entryName, options)) await this._processDefaultEntry(stream, model, entryName, entry.data);
|
|
20891
21113
|
}
|
|
20892
21114
|
this.reconcile(model, options);
|
|
20893
21115
|
this.workbook.model = model;
|
|
@@ -20895,11 +21117,11 @@ var ExcelTS = (function(exports) {
|
|
|
20895
21117
|
}
|
|
20896
21118
|
/**
|
|
20897
21119
|
* Process default entries (drawings, comments, tables, etc.)
|
|
21120
|
+
* @param rawData Optional raw entry data for passthrough preservation (used by loadFromFiles)
|
|
20898
21121
|
*/
|
|
20899
|
-
async _processDefaultEntry(stream, model, entryName) {
|
|
20900
|
-
const
|
|
20901
|
-
if (
|
|
20902
|
-
const sheetNo = worksheetRelsSheetNo;
|
|
21122
|
+
async _processDefaultEntry(stream, model, entryName, rawData) {
|
|
21123
|
+
const sheetNo = getWorksheetNoFromWorksheetRelsPath(entryName);
|
|
21124
|
+
if (sheetNo !== void 0) {
|
|
20903
21125
|
await this._processWorksheetRelsEntry(stream, model, sheetNo);
|
|
20904
21126
|
return true;
|
|
20905
21127
|
}
|
|
@@ -20911,6 +21133,7 @@ var ExcelTS = (function(exports) {
|
|
|
20911
21133
|
const drawingName = getDrawingNameFromPath(entryName);
|
|
20912
21134
|
if (drawingName) {
|
|
20913
21135
|
await this._processDrawingEntry(stream, model, drawingName);
|
|
21136
|
+
if (rawData) model.rawDrawings[drawingName] = rawData;
|
|
20914
21137
|
return true;
|
|
20915
21138
|
}
|
|
20916
21139
|
const drawingRelsName = getDrawingNameFromRelsPath(entryName);
|
|
@@ -20963,8 +21186,21 @@ var ExcelTS = (function(exports) {
|
|
|
20963
21186
|
await this._processPivotCacheRecordsEntry(stream, model, pivotCacheRecordsName);
|
|
20964
21187
|
return true;
|
|
20965
21188
|
}
|
|
21189
|
+
if (PassthroughManager.isPassthroughPath(entryName)) {
|
|
21190
|
+
if (rawData) model.passthrough[entryName] = rawData;
|
|
21191
|
+
else await this._processPassthroughEntry(stream, model, entryName);
|
|
21192
|
+
return true;
|
|
21193
|
+
}
|
|
20966
21194
|
return false;
|
|
20967
21195
|
}
|
|
21196
|
+
/**
|
|
21197
|
+
* Store a passthrough file for preservation during read/write cycles.
|
|
21198
|
+
* These files are not parsed but stored as raw bytes to be written back unchanged.
|
|
21199
|
+
*/
|
|
21200
|
+
async _processPassthroughEntry(stream, model, entryName) {
|
|
21201
|
+
const data = await this.collectStreamData(stream);
|
|
21202
|
+
model.passthrough[entryName] = data;
|
|
21203
|
+
}
|
|
20968
21204
|
async addContentTypes(zip$1, model) {
|
|
20969
21205
|
const xml = new ContentTypesXform().toXml(model);
|
|
20970
21206
|
zip$1.append(xml, { name: OOXML_PATHS.contentTypes });
|
|
@@ -21101,14 +21337,29 @@ var ExcelTS = (function(exports) {
|
|
|
21101
21337
|
addDrawings(zip$1, model) {
|
|
21102
21338
|
const drawingXform = new DrawingXform();
|
|
21103
21339
|
const relsXform = new RelationshipsXform();
|
|
21340
|
+
const rawDrawings = model.rawDrawings || {};
|
|
21104
21341
|
model.worksheets.forEach((worksheet) => {
|
|
21105
21342
|
const { drawing } = worksheet;
|
|
21106
21343
|
if (drawing) {
|
|
21107
|
-
|
|
21108
|
-
|
|
21109
|
-
|
|
21110
|
-
|
|
21111
|
-
|
|
21344
|
+
if (this.drawingHasChartReference(drawing) && rawDrawings[drawing.name]) zip$1.append(rawDrawings[drawing.name], { name: drawingPath(drawing.name) });
|
|
21345
|
+
else {
|
|
21346
|
+
const filteredAnchors = (drawing.anchors || []).filter((a) => {
|
|
21347
|
+
if (a == null) return false;
|
|
21348
|
+
if (a.range?.br && a.shape) return true;
|
|
21349
|
+
if (!a.br && !a.picture) return false;
|
|
21350
|
+
if (a.br && !a.picture && !a.shape) return false;
|
|
21351
|
+
return true;
|
|
21352
|
+
});
|
|
21353
|
+
const drawingForWrite = drawing.anchors ? {
|
|
21354
|
+
...drawing,
|
|
21355
|
+
anchors: filteredAnchors
|
|
21356
|
+
} : drawing;
|
|
21357
|
+
drawingXform.prepare(drawingForWrite);
|
|
21358
|
+
const xml = drawingXform.toXml(drawingForWrite);
|
|
21359
|
+
zip$1.append(xml, { name: drawingPath(drawing.name) });
|
|
21360
|
+
}
|
|
21361
|
+
const relsXml = relsXform.toXml(drawing.rels);
|
|
21362
|
+
zip$1.append(relsXml, { name: drawingRelsPath(drawing.name) });
|
|
21112
21363
|
}
|
|
21113
21364
|
});
|
|
21114
21365
|
}
|
|
@@ -21123,6 +21374,15 @@ var ExcelTS = (function(exports) {
|
|
|
21123
21374
|
});
|
|
21124
21375
|
});
|
|
21125
21376
|
}
|
|
21377
|
+
/**
|
|
21378
|
+
* Write passthrough files (charts, etc.) that were preserved during read.
|
|
21379
|
+
* These files are written back unchanged to preserve unsupported features.
|
|
21380
|
+
*/
|
|
21381
|
+
addPassthrough(zip$1, model) {
|
|
21382
|
+
const passthroughManager = new PassthroughManager();
|
|
21383
|
+
passthroughManager.fromRecord(model.passthrough || {});
|
|
21384
|
+
passthroughManager.writeToZip(zip$1);
|
|
21385
|
+
}
|
|
21126
21386
|
addPivotTables(zip$1, model) {
|
|
21127
21387
|
if (!model.pivotTables.length) return;
|
|
21128
21388
|
const pivotCacheRecordsXform = new PivotCacheRecordsXform();
|
|
@@ -21205,6 +21465,10 @@ var ExcelTS = (function(exports) {
|
|
|
21205
21465
|
worksheetXform.prepare(worksheet, worksheetOptions);
|
|
21206
21466
|
});
|
|
21207
21467
|
model.hasCheckboxes = model.styles.hasCheckboxes;
|
|
21468
|
+
const passthrough = model.passthrough || {};
|
|
21469
|
+
const passthroughManager = new PassthroughManager();
|
|
21470
|
+
passthroughManager.fromRecord(passthrough);
|
|
21471
|
+
model.passthroughContentTypes = passthroughManager.getContentTypes();
|
|
21208
21472
|
}
|
|
21209
21473
|
};
|
|
21210
21474
|
|
|
@@ -22406,7 +22670,7 @@ var ExcelTS = (function(exports) {
|
|
|
22406
22670
|
else str = String(content);
|
|
22407
22671
|
const worksheet = this.workbook.addWorksheet(options?.sheetName);
|
|
22408
22672
|
const dateFormats = options?.dateFormats ?? DEFAULT_DATE_FORMATS;
|
|
22409
|
-
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator
|
|
22673
|
+
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator });
|
|
22410
22674
|
const rows = parseCsv(str, options?.parserOptions);
|
|
22411
22675
|
for (const row of rows) worksheet.addRow(row.map(map));
|
|
22412
22676
|
return worksheet;
|
|
@@ -22434,7 +22698,7 @@ var ExcelTS = (function(exports) {
|
|
|
22434
22698
|
async read(stream, options) {
|
|
22435
22699
|
const worksheet = this.workbook.addWorksheet(options?.sheetName);
|
|
22436
22700
|
const dateFormats = options?.dateFormats ?? DEFAULT_DATE_FORMATS;
|
|
22437
|
-
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator
|
|
22701
|
+
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator });
|
|
22438
22702
|
const parser = new CsvParserStream(options?.parserOptions);
|
|
22439
22703
|
return new Promise((resolve, reject) => {
|
|
22440
22704
|
parser.on("data", (row) => worksheet.addRow(row.map(map)));
|
|
@@ -22486,7 +22750,7 @@ var ExcelTS = (function(exports) {
|
|
|
22486
22750
|
createWriteStream(options) {
|
|
22487
22751
|
const worksheet = this.workbook.addWorksheet(options?.sheetName);
|
|
22488
22752
|
const dateFormats = options?.dateFormats ?? DEFAULT_DATE_FORMATS;
|
|
22489
|
-
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator
|
|
22753
|
+
const map = options?.map || createDefaultValueMapper(dateFormats, { decimalSeparator: options?.valueMapperOptions?.decimalSeparator });
|
|
22490
22754
|
const parser = new CsvParserStream(options?.parserOptions);
|
|
22491
22755
|
parser.on("data", (row) => worksheet.addRow(row.map(map)));
|
|
22492
22756
|
return parser;
|
|
@@ -25487,6 +25751,8 @@ onmessage = async (ev) => {
|
|
|
25487
25751
|
this.views = [];
|
|
25488
25752
|
this.media = [];
|
|
25489
25753
|
this.pivotTables = [];
|
|
25754
|
+
this._passthrough = {};
|
|
25755
|
+
this._rawDrawings = {};
|
|
25490
25756
|
this._definedNames = new DefinedNames();
|
|
25491
25757
|
}
|
|
25492
25758
|
/**
|
|
@@ -25659,7 +25925,9 @@ onmessage = async (ev) => {
|
|
|
25659
25925
|
themes: this._themes,
|
|
25660
25926
|
media: this.media,
|
|
25661
25927
|
pivotTables: this.pivotTables,
|
|
25662
|
-
calcProperties: this.calcProperties
|
|
25928
|
+
calcProperties: this.calcProperties,
|
|
25929
|
+
passthrough: this._passthrough,
|
|
25930
|
+
rawDrawings: this._rawDrawings
|
|
25663
25931
|
};
|
|
25664
25932
|
}
|
|
25665
25933
|
set model(value) {
|
|
@@ -25698,6 +25966,8 @@ onmessage = async (ev) => {
|
|
|
25698
25966
|
this._themes = value.themes;
|
|
25699
25967
|
this.media = value.media || [];
|
|
25700
25968
|
this.pivotTables = value.pivotTables || value.loadedPivotTables || [];
|
|
25969
|
+
this._passthrough = value.passthrough || {};
|
|
25970
|
+
this._rawDrawings = value.rawDrawings || {};
|
|
25701
25971
|
}
|
|
25702
25972
|
};
|
|
25703
25973
|
|