@cj-tech-master/excelts 4.2.2 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/xlsx/xform/core/app-xform.js +3 -3
- 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/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.js +8 -4
- package/dist/cjs/modules/excel/utils/parse-sax.js +32 -13
- package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- 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/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 +8 -4
- package/dist/esm/modules/excel/utils/parse-sax.js +32 -13
- package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- 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/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 +8 -4
- package/dist/iife/excelts.iife.js +100 -100
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +24 -24
- package/dist/types/modules/excel/utils/parse-sax.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v4.2.
|
|
2
|
+
* @cj-tech-master/excelts v4.2.3
|
|
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
|
|
@@ -6764,6 +6764,8 @@ var ExcelTS = (function(exports) {
|
|
|
6764
6764
|
quot: "\"",
|
|
6765
6765
|
apos: "'"
|
|
6766
6766
|
};
|
|
6767
|
+
const HAN_CELL_PREFIXES = /^(ep|cp|dc|dcterms|dcmitype|vt):/;
|
|
6768
|
+
const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
6767
6769
|
const S_TEXT = 0;
|
|
6768
6770
|
const S_OPEN_WAKA = 1;
|
|
6769
6771
|
const S_OPEN_WAKA_BANG = 2;
|
|
@@ -6815,6 +6817,7 @@ var ExcelTS = (function(exports) {
|
|
|
6815
6817
|
this.positionAtNewLine = 0;
|
|
6816
6818
|
this.chunkPosition = 0;
|
|
6817
6819
|
this.ENTITIES = { ...XML_ENTITIES };
|
|
6820
|
+
this.nsPrefix = null;
|
|
6818
6821
|
this.trackPosition = opt?.position !== false;
|
|
6819
6822
|
this.fileName = opt?.fileName;
|
|
6820
6823
|
this.fragment = opt?.fragment ?? false;
|
|
@@ -6849,6 +6852,11 @@ var ExcelTS = (function(exports) {
|
|
|
6849
6852
|
this.chunk = "";
|
|
6850
6853
|
this.i = 0;
|
|
6851
6854
|
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;
|
|
6852
6860
|
}
|
|
6853
6861
|
on(name, handler) {
|
|
6854
6862
|
switch (name) {
|
|
@@ -7188,7 +7196,7 @@ var ExcelTS = (function(exports) {
|
|
|
7188
7196
|
return;
|
|
7189
7197
|
}
|
|
7190
7198
|
this.tag = {
|
|
7191
|
-
name: this.name,
|
|
7199
|
+
name: this.stripNsPrefix(this.name),
|
|
7192
7200
|
attributes: Object.create(null),
|
|
7193
7201
|
isSelfClosing: false
|
|
7194
7202
|
};
|
|
@@ -7484,8 +7492,7 @@ var ExcelTS = (function(exports) {
|
|
|
7484
7492
|
openTag() {
|
|
7485
7493
|
const tag = this.tag;
|
|
7486
7494
|
tag.isSelfClosing = false;
|
|
7487
|
-
|
|
7488
|
-
this.attribList = [];
|
|
7495
|
+
this.processAttributes(tag);
|
|
7489
7496
|
this.openTagHandler?.(tag);
|
|
7490
7497
|
this.tags.push(tag);
|
|
7491
7498
|
this.name = "";
|
|
@@ -7494,16 +7501,26 @@ var ExcelTS = (function(exports) {
|
|
|
7494
7501
|
openSelfClosingTag() {
|
|
7495
7502
|
const tag = this.tag;
|
|
7496
7503
|
tag.isSelfClosing = true;
|
|
7497
|
-
|
|
7498
|
-
this.attribList = [];
|
|
7504
|
+
this.processAttributes(tag);
|
|
7499
7505
|
this.openTagHandler?.(tag);
|
|
7500
7506
|
this.closeTagHandler?.(tag);
|
|
7501
7507
|
if (this.tags.length === 0) this.closedRoot = true;
|
|
7502
7508
|
this.name = "";
|
|
7503
7509
|
this.state = S_TEXT;
|
|
7504
7510
|
}
|
|
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
|
+
}
|
|
7505
7521
|
closeTag() {
|
|
7506
|
-
const { tags
|
|
7522
|
+
const { tags } = this;
|
|
7523
|
+
const name = this.stripNsPrefix(this.name);
|
|
7507
7524
|
this.state = S_TEXT;
|
|
7508
7525
|
this.name = "";
|
|
7509
7526
|
if (name === "") {
|
|
@@ -7730,17 +7747,15 @@ var ExcelTS = (function(exports) {
|
|
|
7730
7747
|
this.parser.parseOpen(node);
|
|
7731
7748
|
return true;
|
|
7732
7749
|
}
|
|
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;
|
|
7750
|
+
if (node.name === this.tag) {
|
|
7751
|
+
this.model = [];
|
|
7752
|
+
return true;
|
|
7743
7753
|
}
|
|
7754
|
+
if (this.childXform.parseOpen(node)) {
|
|
7755
|
+
this.parser = this.childXform;
|
|
7756
|
+
return true;
|
|
7757
|
+
}
|
|
7758
|
+
return false;
|
|
7744
7759
|
}
|
|
7745
7760
|
parseText(text) {
|
|
7746
7761
|
if (this.parser) this.parser.parseText(text);
|
|
@@ -9591,34 +9606,52 @@ var ExcelTS = (function(exports) {
|
|
|
9591
9606
|
|
|
9592
9607
|
//#endregion
|
|
9593
9608
|
//#region src/modules/excel/xlsx/xform/core/core-xform.ts
|
|
9609
|
+
const PROPS = {
|
|
9610
|
+
creator: "dc:creator",
|
|
9611
|
+
title: "dc:title",
|
|
9612
|
+
subject: "dc:subject",
|
|
9613
|
+
description: "dc:description",
|
|
9614
|
+
identifier: "dc:identifier",
|
|
9615
|
+
language: "dc:language",
|
|
9616
|
+
keywords: "cp:keywords",
|
|
9617
|
+
category: "cp:category",
|
|
9618
|
+
lastModifiedBy: "cp:lastModifiedBy",
|
|
9619
|
+
lastPrinted: "cp:lastPrinted",
|
|
9620
|
+
revision: "cp:revision",
|
|
9621
|
+
version: "cp:version",
|
|
9622
|
+
contentStatus: "cp:contentStatus",
|
|
9623
|
+
contentType: "cp:contentType",
|
|
9624
|
+
created: "dcterms:created",
|
|
9625
|
+
modified: "dcterms:modified"
|
|
9626
|
+
};
|
|
9594
9627
|
var CoreXform = class CoreXform extends BaseXform {
|
|
9595
9628
|
constructor() {
|
|
9596
9629
|
super();
|
|
9597
9630
|
this.map = {
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
tag:
|
|
9631
|
+
creator: new StringXform({ tag: PROPS.creator }),
|
|
9632
|
+
title: new StringXform({ tag: PROPS.title }),
|
|
9633
|
+
subject: new StringXform({ tag: PROPS.subject }),
|
|
9634
|
+
description: new StringXform({ tag: PROPS.description }),
|
|
9635
|
+
identifier: new StringXform({ tag: PROPS.identifier }),
|
|
9636
|
+
language: new StringXform({ tag: PROPS.language }),
|
|
9637
|
+
keywords: new StringXform({ tag: PROPS.keywords }),
|
|
9638
|
+
category: new StringXform({ tag: PROPS.category }),
|
|
9639
|
+
lastModifiedBy: new StringXform({ tag: PROPS.lastModifiedBy }),
|
|
9640
|
+
lastPrinted: new DateXform({
|
|
9641
|
+
tag: PROPS.lastPrinted,
|
|
9609
9642
|
format: CoreXform.DateFormat
|
|
9610
9643
|
}),
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
tag:
|
|
9644
|
+
revision: new IntegerXform({ tag: PROPS.revision }),
|
|
9645
|
+
version: new StringXform({ tag: PROPS.version }),
|
|
9646
|
+
contentStatus: new StringXform({ tag: PROPS.contentStatus }),
|
|
9647
|
+
contentType: new StringXform({ tag: PROPS.contentType }),
|
|
9648
|
+
created: new DateXform({
|
|
9649
|
+
tag: PROPS.created,
|
|
9617
9650
|
attrs: CoreXform.DateAttrs,
|
|
9618
9651
|
format: CoreXform.DateFormat
|
|
9619
9652
|
}),
|
|
9620
|
-
|
|
9621
|
-
tag:
|
|
9653
|
+
modified: new DateXform({
|
|
9654
|
+
tag: PROPS.modified,
|
|
9622
9655
|
attrs: CoreXform.DateAttrs,
|
|
9623
9656
|
format: CoreXform.DateFormat
|
|
9624
9657
|
})
|
|
@@ -9627,22 +9660,7 @@ var ExcelTS = (function(exports) {
|
|
|
9627
9660
|
render(xmlStream, model) {
|
|
9628
9661
|
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
9629
9662
|
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);
|
|
9663
|
+
for (const key of Object.keys(PROPS)) this.map[key].render(xmlStream, model[key]);
|
|
9646
9664
|
xmlStream.closeNode();
|
|
9647
9665
|
}
|
|
9648
9666
|
parseOpen(node) {
|
|
@@ -9650,17 +9668,11 @@ var ExcelTS = (function(exports) {
|
|
|
9650
9668
|
this.parser.parseOpen(node);
|
|
9651
9669
|
return true;
|
|
9652
9670
|
}
|
|
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)}`);
|
|
9671
|
+
if (node.name !== "coreProperties") {
|
|
9672
|
+
this.parser = this.map[node.name];
|
|
9673
|
+
if (this.parser) this.parser.parseOpen(node);
|
|
9663
9674
|
}
|
|
9675
|
+
return true;
|
|
9664
9676
|
}
|
|
9665
9677
|
parseText(text) {
|
|
9666
9678
|
if (this.parser) this.parser.parseText(text);
|
|
@@ -9670,29 +9682,15 @@ var ExcelTS = (function(exports) {
|
|
|
9670
9682
|
if (!this.parser.parseClose(name)) this.parser = void 0;
|
|
9671
9683
|
return true;
|
|
9672
9684
|
}
|
|
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}`);
|
|
9685
|
+
if (name === "coreProperties") {
|
|
9686
|
+
this.model = {};
|
|
9687
|
+
for (const key of Object.keys(PROPS)) {
|
|
9688
|
+
const val = this.map[key].model;
|
|
9689
|
+
if (val !== void 0 && val !== "") this.model[key] = val;
|
|
9690
|
+
}
|
|
9691
|
+
return false;
|
|
9695
9692
|
}
|
|
9693
|
+
return true;
|
|
9696
9694
|
}
|
|
9697
9695
|
static {
|
|
9698
9696
|
this.DateFormat = function(dt) {
|
|
@@ -9726,13 +9724,12 @@ var ExcelTS = (function(exports) {
|
|
|
9726
9724
|
xmlStream.closeNode();
|
|
9727
9725
|
}
|
|
9728
9726
|
parseOpen(node) {
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
return true;
|
|
9734
|
-
default: return false;
|
|
9727
|
+
if (node.name === "t") {
|
|
9728
|
+
this._text = [];
|
|
9729
|
+
this.model = "";
|
|
9730
|
+
return true;
|
|
9735
9731
|
}
|
|
9732
|
+
return false;
|
|
9736
9733
|
}
|
|
9737
9734
|
parseText(text) {
|
|
9738
9735
|
this._text.push(text);
|
|
@@ -9913,16 +9910,15 @@ var ExcelTS = (function(exports) {
|
|
|
9913
9910
|
xmlStream.closeNode();
|
|
9914
9911
|
}
|
|
9915
9912
|
parseOpen(node) {
|
|
9916
|
-
const { name } = node;
|
|
9917
9913
|
if (this.parser) {
|
|
9918
9914
|
this.parser.parseOpen(node);
|
|
9919
9915
|
return true;
|
|
9920
9916
|
}
|
|
9921
|
-
if (name === this.tag) {
|
|
9917
|
+
if (node.name === this.tag) {
|
|
9922
9918
|
this.model = {};
|
|
9923
9919
|
return true;
|
|
9924
9920
|
}
|
|
9925
|
-
this.parser = this.map[name];
|
|
9921
|
+
this.parser = this.map[node.name];
|
|
9926
9922
|
if (this.parser) {
|
|
9927
9923
|
this.parser.parseOpen(node);
|
|
9928
9924
|
return true;
|
|
@@ -10515,7 +10511,7 @@ var ExcelTS = (function(exports) {
|
|
|
10515
10511
|
Company: new StringXform({ tag: "Company" }),
|
|
10516
10512
|
Manager: new StringXform({ tag: "Manager" }),
|
|
10517
10513
|
HeadingPairs: new AppHeadingPairsXform(),
|
|
10518
|
-
|
|
10514
|
+
TitlesOfParts: new AppTitlesOfPartsXform()
|
|
10519
10515
|
};
|
|
10520
10516
|
}
|
|
10521
10517
|
render(xmlStream, model) {
|
|
@@ -10525,7 +10521,7 @@ var ExcelTS = (function(exports) {
|
|
|
10525
10521
|
xmlStream.leafNode("DocSecurity", void 0, "0");
|
|
10526
10522
|
xmlStream.leafNode("ScaleCrop", void 0, "false");
|
|
10527
10523
|
this.map.HeadingPairs.render(xmlStream, model.worksheets);
|
|
10528
|
-
this.map.
|
|
10524
|
+
this.map.TitlesOfParts.render(xmlStream, model.worksheets);
|
|
10529
10525
|
this.map.Company.render(xmlStream, model.company || "");
|
|
10530
10526
|
this.map.Manager.render(xmlStream, model.manager);
|
|
10531
10527
|
xmlStream.leafNode("LinksUpToDate", void 0, "false");
|
|
@@ -10561,7 +10557,7 @@ var ExcelTS = (function(exports) {
|
|
|
10561
10557
|
switch (name) {
|
|
10562
10558
|
case "Properties":
|
|
10563
10559
|
this.model = {
|
|
10564
|
-
worksheets: this.map.
|
|
10560
|
+
worksheets: this.map.TitlesOfParts.model,
|
|
10565
10561
|
company: this.map.Company.model,
|
|
10566
10562
|
manager: this.map.Manager.model
|
|
10567
10563
|
};
|
|
@@ -20494,8 +20490,10 @@ var ExcelTS = (function(exports) {
|
|
|
20494
20490
|
break;
|
|
20495
20491
|
case OOXML_PATHS.docPropsApp: {
|
|
20496
20492
|
const appProperties = await new AppXform().parseStream(stream);
|
|
20497
|
-
|
|
20498
|
-
|
|
20493
|
+
if (appProperties) {
|
|
20494
|
+
model.company = appProperties.company;
|
|
20495
|
+
model.manager = appProperties.manager;
|
|
20496
|
+
}
|
|
20499
20497
|
break;
|
|
20500
20498
|
}
|
|
20501
20499
|
case OOXML_PATHS.docPropsCore: {
|
|
@@ -20873,8 +20871,10 @@ var ExcelTS = (function(exports) {
|
|
|
20873
20871
|
break;
|
|
20874
20872
|
case OOXML_PATHS.docPropsApp: {
|
|
20875
20873
|
const appProperties = await new AppXform().parseStream(stream);
|
|
20876
|
-
|
|
20877
|
-
|
|
20874
|
+
if (appProperties) {
|
|
20875
|
+
model.company = appProperties.company;
|
|
20876
|
+
model.manager = appProperties.manager;
|
|
20877
|
+
}
|
|
20878
20878
|
break;
|
|
20879
20879
|
}
|
|
20880
20880
|
case OOXML_PATHS.docPropsCore: {
|