@cj-tech-master/excelts 4.2.2 → 4.2.3-canary.20260115111903.b80904d

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.
Files changed (30) hide show
  1. package/dist/browser/modules/excel/utils/parse-sax.d.ts +3 -0
  2. package/dist/browser/modules/excel/utils/parse-sax.js +32 -13
  3. package/dist/browser/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  4. package/dist/browser/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  5. package/dist/browser/modules/excel/xlsx/xform/list-xform.js +8 -10
  6. package/dist/browser/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  7. package/dist/browser/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  8. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +8 -4
  9. package/dist/browser/modules/stream/streams.browser.js +0 -3
  10. package/dist/cjs/modules/excel/utils/parse-sax.js +32 -13
  11. package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  12. package/dist/cjs/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  13. package/dist/cjs/modules/excel/xlsx/xform/list-xform.js +8 -10
  14. package/dist/cjs/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  15. package/dist/cjs/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  16. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +8 -4
  17. package/dist/cjs/modules/stream/streams.browser.js +0 -3
  18. package/dist/esm/modules/excel/utils/parse-sax.js +32 -13
  19. package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  20. package/dist/esm/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  21. package/dist/esm/modules/excel/xlsx/xform/list-xform.js +8 -10
  22. package/dist/esm/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  23. package/dist/esm/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  24. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +8 -4
  25. package/dist/esm/modules/stream/streams.browser.js +0 -3
  26. package/dist/iife/excelts.iife.js +100 -101
  27. package/dist/iife/excelts.iife.js.map +1 -1
  28. package/dist/iife/excelts.iife.min.js +25 -25
  29. package/dist/types/modules/excel/utils/parse-sax.d.ts +3 -0
  30. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v4.2.2
2
+ * @cj-tech-master/excelts v4.2.3-canary.20260115111903.b80904d
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);
@@ -6764,6 +6763,8 @@ var ExcelTS = (function(exports) {
6764
6763
  quot: "\"",
6765
6764
  apos: "'"
6766
6765
  };
6766
+ const HAN_CELL_PREFIXES = /^(ep|cp|dc|dcterms|dcmitype|vt):/;
6767
+ const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
6767
6768
  const S_TEXT = 0;
6768
6769
  const S_OPEN_WAKA = 1;
6769
6770
  const S_OPEN_WAKA_BANG = 2;
@@ -6815,6 +6816,7 @@ var ExcelTS = (function(exports) {
6815
6816
  this.positionAtNewLine = 0;
6816
6817
  this.chunkPosition = 0;
6817
6818
  this.ENTITIES = { ...XML_ENTITIES };
6819
+ this.nsPrefix = null;
6818
6820
  this.trackPosition = opt?.position !== false;
6819
6821
  this.fileName = opt?.fileName;
6820
6822
  this.fragment = opt?.fragment ?? false;
@@ -6849,6 +6851,11 @@ var ExcelTS = (function(exports) {
6849
6851
  this.chunk = "";
6850
6852
  this.i = 0;
6851
6853
  this.prevI = 0;
6854
+ this.nsPrefix = null;
6855
+ }
6856
+ stripNsPrefix(name) {
6857
+ const n = name.replace(HAN_CELL_PREFIXES, "");
6858
+ return this.nsPrefix && n.startsWith(this.nsPrefix + ":") ? n.slice(this.nsPrefix.length + 1) : n;
6852
6859
  }
6853
6860
  on(name, handler) {
6854
6861
  switch (name) {
@@ -7188,7 +7195,7 @@ var ExcelTS = (function(exports) {
7188
7195
  return;
7189
7196
  }
7190
7197
  this.tag = {
7191
- name: this.name,
7198
+ name: this.stripNsPrefix(this.name),
7192
7199
  attributes: Object.create(null),
7193
7200
  isSelfClosing: false
7194
7201
  };
@@ -7484,8 +7491,7 @@ var ExcelTS = (function(exports) {
7484
7491
  openTag() {
7485
7492
  const tag = this.tag;
7486
7493
  tag.isSelfClosing = false;
7487
- for (const { name, value } of this.attribList) tag.attributes[name] = value;
7488
- this.attribList = [];
7494
+ this.processAttributes(tag);
7489
7495
  this.openTagHandler?.(tag);
7490
7496
  this.tags.push(tag);
7491
7497
  this.name = "";
@@ -7494,16 +7500,26 @@ var ExcelTS = (function(exports) {
7494
7500
  openSelfClosingTag() {
7495
7501
  const tag = this.tag;
7496
7502
  tag.isSelfClosing = true;
7497
- for (const { name, value } of this.attribList) tag.attributes[name] = value;
7498
- this.attribList = [];
7503
+ this.processAttributes(tag);
7499
7504
  this.openTagHandler?.(tag);
7500
7505
  this.closeTagHandler?.(tag);
7501
7506
  if (this.tags.length === 0) this.closedRoot = true;
7502
7507
  this.name = "";
7503
7508
  this.state = S_TEXT;
7504
7509
  }
7510
+ processAttributes(tag) {
7511
+ for (const { name, value } of this.attribList) {
7512
+ tag.attributes[name] = value;
7513
+ if (name.startsWith("xmlns:") && value === SPREADSHEETML_NS) {
7514
+ this.nsPrefix = name.slice(6);
7515
+ tag.name = this.stripNsPrefix(tag.name);
7516
+ }
7517
+ }
7518
+ this.attribList = [];
7519
+ }
7505
7520
  closeTag() {
7506
- const { tags, name } = this;
7521
+ const { tags } = this;
7522
+ const name = this.stripNsPrefix(this.name);
7507
7523
  this.state = S_TEXT;
7508
7524
  this.name = "";
7509
7525
  if (name === "") {
@@ -7730,17 +7746,15 @@ var ExcelTS = (function(exports) {
7730
7746
  this.parser.parseOpen(node);
7731
7747
  return true;
7732
7748
  }
7733
- switch (node.name) {
7734
- case this.tag:
7735
- this.model = [];
7736
- return true;
7737
- default:
7738
- if (this.childXform.parseOpen(node)) {
7739
- this.parser = this.childXform;
7740
- return true;
7741
- }
7742
- return false;
7749
+ if (node.name === this.tag) {
7750
+ this.model = [];
7751
+ return true;
7743
7752
  }
7753
+ if (this.childXform.parseOpen(node)) {
7754
+ this.parser = this.childXform;
7755
+ return true;
7756
+ }
7757
+ return false;
7744
7758
  }
7745
7759
  parseText(text) {
7746
7760
  if (this.parser) this.parser.parseText(text);
@@ -9591,34 +9605,52 @@ var ExcelTS = (function(exports) {
9591
9605
 
9592
9606
  //#endregion
9593
9607
  //#region src/modules/excel/xlsx/xform/core/core-xform.ts
9608
+ const PROPS = {
9609
+ creator: "dc:creator",
9610
+ title: "dc:title",
9611
+ subject: "dc:subject",
9612
+ description: "dc:description",
9613
+ identifier: "dc:identifier",
9614
+ language: "dc:language",
9615
+ keywords: "cp:keywords",
9616
+ category: "cp:category",
9617
+ lastModifiedBy: "cp:lastModifiedBy",
9618
+ lastPrinted: "cp:lastPrinted",
9619
+ revision: "cp:revision",
9620
+ version: "cp:version",
9621
+ contentStatus: "cp:contentStatus",
9622
+ contentType: "cp:contentType",
9623
+ created: "dcterms:created",
9624
+ modified: "dcterms:modified"
9625
+ };
9594
9626
  var CoreXform = class CoreXform extends BaseXform {
9595
9627
  constructor() {
9596
9628
  super();
9597
9629
  this.map = {
9598
- "dc:creator": new StringXform({ tag: "dc:creator" }),
9599
- "dc:title": new StringXform({ tag: "dc:title" }),
9600
- "dc:subject": new StringXform({ tag: "dc:subject" }),
9601
- "dc:description": new StringXform({ tag: "dc:description" }),
9602
- "dc:identifier": new StringXform({ tag: "dc:identifier" }),
9603
- "dc:language": new StringXform({ tag: "dc:language" }),
9604
- "cp:keywords": new StringXform({ tag: "cp:keywords" }),
9605
- "cp:category": new StringXform({ tag: "cp:category" }),
9606
- "cp:lastModifiedBy": new StringXform({ tag: "cp:lastModifiedBy" }),
9607
- "cp:lastPrinted": new DateXform({
9608
- tag: "cp:lastPrinted",
9630
+ creator: new StringXform({ tag: PROPS.creator }),
9631
+ title: new StringXform({ tag: PROPS.title }),
9632
+ subject: new StringXform({ tag: PROPS.subject }),
9633
+ description: new StringXform({ tag: PROPS.description }),
9634
+ identifier: new StringXform({ tag: PROPS.identifier }),
9635
+ language: new StringXform({ tag: PROPS.language }),
9636
+ keywords: new StringXform({ tag: PROPS.keywords }),
9637
+ category: new StringXform({ tag: PROPS.category }),
9638
+ lastModifiedBy: new StringXform({ tag: PROPS.lastModifiedBy }),
9639
+ lastPrinted: new DateXform({
9640
+ tag: PROPS.lastPrinted,
9609
9641
  format: CoreXform.DateFormat
9610
9642
  }),
9611
- "cp:revision": new IntegerXform({ tag: "cp:revision" }),
9612
- "cp:version": new StringXform({ tag: "cp:version" }),
9613
- "cp:contentStatus": new StringXform({ tag: "cp:contentStatus" }),
9614
- "cp:contentType": new StringXform({ tag: "cp:contentType" }),
9615
- "dcterms:created": new DateXform({
9616
- tag: "dcterms:created",
9643
+ revision: new IntegerXform({ tag: PROPS.revision }),
9644
+ version: new StringXform({ tag: PROPS.version }),
9645
+ contentStatus: new StringXform({ tag: PROPS.contentStatus }),
9646
+ contentType: new StringXform({ tag: PROPS.contentType }),
9647
+ created: new DateXform({
9648
+ tag: PROPS.created,
9617
9649
  attrs: CoreXform.DateAttrs,
9618
9650
  format: CoreXform.DateFormat
9619
9651
  }),
9620
- "dcterms:modified": new DateXform({
9621
- tag: "dcterms:modified",
9652
+ modified: new DateXform({
9653
+ tag: PROPS.modified,
9622
9654
  attrs: CoreXform.DateAttrs,
9623
9655
  format: CoreXform.DateFormat
9624
9656
  })
@@ -9627,22 +9659,7 @@ var ExcelTS = (function(exports) {
9627
9659
  render(xmlStream, model) {
9628
9660
  xmlStream.openXml(XmlStream.StdDocAttributes);
9629
9661
  xmlStream.openNode("cp:coreProperties", CoreXform.CORE_PROPERTY_ATTRIBUTES);
9630
- this.map["dc:creator"].render(xmlStream, model.creator);
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);
9662
+ for (const key of Object.keys(PROPS)) this.map[key].render(xmlStream, model[key]);
9646
9663
  xmlStream.closeNode();
9647
9664
  }
9648
9665
  parseOpen(node) {
@@ -9650,17 +9667,11 @@ var ExcelTS = (function(exports) {
9650
9667
  this.parser.parseOpen(node);
9651
9668
  return true;
9652
9669
  }
9653
- switch (node.name) {
9654
- case "cp:coreProperties":
9655
- case "coreProperties": return true;
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)}`);
9670
+ if (node.name !== "coreProperties") {
9671
+ this.parser = this.map[node.name];
9672
+ if (this.parser) this.parser.parseOpen(node);
9663
9673
  }
9674
+ return true;
9664
9675
  }
9665
9676
  parseText(text) {
9666
9677
  if (this.parser) this.parser.parseText(text);
@@ -9670,29 +9681,15 @@ var ExcelTS = (function(exports) {
9670
9681
  if (!this.parser.parseClose(name)) this.parser = void 0;
9671
9682
  return true;
9672
9683
  }
9673
- switch (name) {
9674
- case "cp:coreProperties":
9675
- case "coreProperties":
9676
- this.model = {
9677
- creator: this.map["dc:creator"].model,
9678
- title: this.map["dc:title"].model,
9679
- subject: this.map["dc:subject"].model,
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}`);
9684
+ if (name === "coreProperties") {
9685
+ this.model = {};
9686
+ for (const key of Object.keys(PROPS)) {
9687
+ const val = this.map[key].model;
9688
+ if (val !== void 0 && val !== "") this.model[key] = val;
9689
+ }
9690
+ return false;
9695
9691
  }
9692
+ return true;
9696
9693
  }
9697
9694
  static {
9698
9695
  this.DateFormat = function(dt) {
@@ -9726,13 +9723,12 @@ var ExcelTS = (function(exports) {
9726
9723
  xmlStream.closeNode();
9727
9724
  }
9728
9725
  parseOpen(node) {
9729
- switch (node.name) {
9730
- case "t":
9731
- this._text = [];
9732
- this.model = "";
9733
- return true;
9734
- default: return false;
9726
+ if (node.name === "t") {
9727
+ this._text = [];
9728
+ this.model = "";
9729
+ return true;
9735
9730
  }
9731
+ return false;
9736
9732
  }
9737
9733
  parseText(text) {
9738
9734
  this._text.push(text);
@@ -9913,16 +9909,15 @@ var ExcelTS = (function(exports) {
9913
9909
  xmlStream.closeNode();
9914
9910
  }
9915
9911
  parseOpen(node) {
9916
- const { name } = node;
9917
9912
  if (this.parser) {
9918
9913
  this.parser.parseOpen(node);
9919
9914
  return true;
9920
9915
  }
9921
- if (name === this.tag) {
9916
+ if (node.name === this.tag) {
9922
9917
  this.model = {};
9923
9918
  return true;
9924
9919
  }
9925
- this.parser = this.map[name];
9920
+ this.parser = this.map[node.name];
9926
9921
  if (this.parser) {
9927
9922
  this.parser.parseOpen(node);
9928
9923
  return true;
@@ -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
- TitleOfParts: new AppTitlesOfPartsXform()
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.TitleOfParts.render(xmlStream, model.worksheets);
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.TitleOfParts.model,
10559
+ worksheets: this.map.TitlesOfParts.model,
10565
10560
  company: this.map.Company.model,
10566
10561
  manager: this.map.Manager.model
10567
10562
  };
@@ -20494,8 +20489,10 @@ var ExcelTS = (function(exports) {
20494
20489
  break;
20495
20490
  case OOXML_PATHS.docPropsApp: {
20496
20491
  const appProperties = await new AppXform().parseStream(stream);
20497
- model.company = appProperties.company;
20498
- model.manager = appProperties.manager;
20492
+ if (appProperties) {
20493
+ model.company = appProperties.company;
20494
+ model.manager = appProperties.manager;
20495
+ }
20499
20496
  break;
20500
20497
  }
20501
20498
  case OOXML_PATHS.docPropsCore: {
@@ -20873,8 +20870,10 @@ var ExcelTS = (function(exports) {
20873
20870
  break;
20874
20871
  case OOXML_PATHS.docPropsApp: {
20875
20872
  const appProperties = await new AppXform().parseStream(stream);
20876
- model.company = appProperties.company;
20877
- model.manager = appProperties.manager;
20873
+ if (appProperties) {
20874
+ model.company = appProperties.company;
20875
+ model.manager = appProperties.manager;
20876
+ }
20878
20877
  break;
20879
20878
  }
20880
20879
  case OOXML_PATHS.docPropsCore: {