@cj-tech-master/excelts 5.0.2 → 5.0.3-canary.20260125224944.ef1722b

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.
@@ -7,6 +7,7 @@ import type { PivotTableSource } from "@excel/pivot-table";
7
7
  interface ParsedCacheDefinitionModel {
8
8
  sourceRef?: string;
9
9
  sourceSheet?: string;
10
+ sourceTableName?: string;
10
11
  cacheFields: CacheFieldModel[];
11
12
  recordCount?: number;
12
13
  rId?: string;
@@ -71,7 +71,7 @@ class PivotCacheDefinitionXform extends BaseXform {
71
71
  * Render loaded pivot cache definition (preserving original structure)
72
72
  */
73
73
  renderLoaded(xmlStream, model) {
74
- const { cacheFields, sourceRef, sourceSheet, recordCount } = model;
74
+ const { cacheFields, sourceRef, sourceSheet, sourceTableName, recordCount } = model;
75
75
  xmlStream.openXml(XmlStream.StdDocAttributes);
76
76
  xmlStream.openNode(this.tag, {
77
77
  ...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
@@ -83,10 +83,13 @@ class PivotCacheDefinitionXform extends BaseXform {
83
83
  recordCount: recordCount || cacheFields.length + 1
84
84
  });
85
85
  xmlStream.openNode("cacheSource", { type: "worksheet" });
86
- xmlStream.leafNode("worksheetSource", {
87
- ref: sourceRef,
88
- sheet: sourceSheet
89
- });
86
+ // worksheetSource supports two reference styles:
87
+ // 1. name: references a named Table
88
+ // 2. ref + sheet: references a cell range on a worksheet
89
+ const worksheetSourceAttrs = sourceTableName
90
+ ? { name: sourceTableName }
91
+ : { ref: sourceRef, sheet: sourceSheet };
92
+ xmlStream.leafNode("worksheetSource", worksheetSourceAttrs);
90
93
  xmlStream.closeNode();
91
94
  xmlStream.openNode("cacheFields", { count: cacheFields.length });
92
95
  xmlStream.writeXml(cacheFields
@@ -124,6 +127,7 @@ class PivotCacheDefinitionXform extends BaseXform {
124
127
  if (this.inCacheSource && this.model) {
125
128
  this.model.sourceRef = attributes.ref;
126
129
  this.model.sourceSheet = attributes.sheet;
130
+ this.model.sourceTableName = attributes.name;
127
131
  }
128
132
  break;
129
133
  case "cacheFields":
@@ -22,6 +22,16 @@ class ConditionalFormattingsXform extends BaseXform {
22
22
  if (rule.style) {
23
23
  rule.dxfId = options.styles.addDxfStyle(rule.style);
24
24
  }
25
+ // Ensure dataBar rules have required cfvo and color properties
26
+ if (rule.type === "dataBar") {
27
+ if (!rule.cfvo || rule.cfvo.length < 2) {
28
+ rule.cfvo = [{ type: "min" }, { type: "max" }];
29
+ }
30
+ if (!rule.color) {
31
+ // Default blue color for data bars (same as Excel's default)
32
+ rule.color = { argb: "FF638EC6" };
33
+ }
34
+ }
25
35
  });
26
36
  });
27
37
  }
@@ -74,7 +74,7 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
74
74
  * Render loaded pivot cache definition (preserving original structure)
75
75
  */
76
76
  renderLoaded(xmlStream, model) {
77
- const { cacheFields, sourceRef, sourceSheet, recordCount } = model;
77
+ const { cacheFields, sourceRef, sourceSheet, sourceTableName, recordCount } = model;
78
78
  xmlStream.openXml(xml_stream_1.XmlStream.StdDocAttributes);
79
79
  xmlStream.openNode(this.tag, {
80
80
  ...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
@@ -86,10 +86,13 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
86
86
  recordCount: recordCount || cacheFields.length + 1
87
87
  });
88
88
  xmlStream.openNode("cacheSource", { type: "worksheet" });
89
- xmlStream.leafNode("worksheetSource", {
90
- ref: sourceRef,
91
- sheet: sourceSheet
92
- });
89
+ // worksheetSource supports two reference styles:
90
+ // 1. name: references a named Table
91
+ // 2. ref + sheet: references a cell range on a worksheet
92
+ const worksheetSourceAttrs = sourceTableName
93
+ ? { name: sourceTableName }
94
+ : { ref: sourceRef, sheet: sourceSheet };
95
+ xmlStream.leafNode("worksheetSource", worksheetSourceAttrs);
93
96
  xmlStream.closeNode();
94
97
  xmlStream.openNode("cacheFields", { count: cacheFields.length });
95
98
  xmlStream.writeXml(cacheFields
@@ -127,6 +130,7 @@ class PivotCacheDefinitionXform extends base_xform_1.BaseXform {
127
130
  if (this.inCacheSource && this.model) {
128
131
  this.model.sourceRef = attributes.ref;
129
132
  this.model.sourceSheet = attributes.sheet;
133
+ this.model.sourceTableName = attributes.name;
130
134
  }
131
135
  break;
132
136
  case "cacheFields":
@@ -25,6 +25,16 @@ class ConditionalFormattingsXform extends base_xform_1.BaseXform {
25
25
  if (rule.style) {
26
26
  rule.dxfId = options.styles.addDxfStyle(rule.style);
27
27
  }
28
+ // Ensure dataBar rules have required cfvo and color properties
29
+ if (rule.type === "dataBar") {
30
+ if (!rule.cfvo || rule.cfvo.length < 2) {
31
+ rule.cfvo = [{ type: "min" }, { type: "max" }];
32
+ }
33
+ if (!rule.color) {
34
+ // Default blue color for data bars (same as Excel's default)
35
+ rule.color = { argb: "FF638EC6" };
36
+ }
37
+ }
28
38
  });
29
39
  });
30
40
  }
@@ -71,7 +71,7 @@ class PivotCacheDefinitionXform extends BaseXform {
71
71
  * Render loaded pivot cache definition (preserving original structure)
72
72
  */
73
73
  renderLoaded(xmlStream, model) {
74
- const { cacheFields, sourceRef, sourceSheet, recordCount } = model;
74
+ const { cacheFields, sourceRef, sourceSheet, sourceTableName, recordCount } = model;
75
75
  xmlStream.openXml(XmlStream.StdDocAttributes);
76
76
  xmlStream.openNode(this.tag, {
77
77
  ...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
@@ -83,10 +83,13 @@ class PivotCacheDefinitionXform extends BaseXform {
83
83
  recordCount: recordCount || cacheFields.length + 1
84
84
  });
85
85
  xmlStream.openNode("cacheSource", { type: "worksheet" });
86
- xmlStream.leafNode("worksheetSource", {
87
- ref: sourceRef,
88
- sheet: sourceSheet
89
- });
86
+ // worksheetSource supports two reference styles:
87
+ // 1. name: references a named Table
88
+ // 2. ref + sheet: references a cell range on a worksheet
89
+ const worksheetSourceAttrs = sourceTableName
90
+ ? { name: sourceTableName }
91
+ : { ref: sourceRef, sheet: sourceSheet };
92
+ xmlStream.leafNode("worksheetSource", worksheetSourceAttrs);
90
93
  xmlStream.closeNode();
91
94
  xmlStream.openNode("cacheFields", { count: cacheFields.length });
92
95
  xmlStream.writeXml(cacheFields
@@ -124,6 +127,7 @@ class PivotCacheDefinitionXform extends BaseXform {
124
127
  if (this.inCacheSource && this.model) {
125
128
  this.model.sourceRef = attributes.ref;
126
129
  this.model.sourceSheet = attributes.sheet;
130
+ this.model.sourceTableName = attributes.name;
127
131
  }
128
132
  break;
129
133
  case "cacheFields":
@@ -22,6 +22,16 @@ class ConditionalFormattingsXform extends BaseXform {
22
22
  if (rule.style) {
23
23
  rule.dxfId = options.styles.addDxfStyle(rule.style);
24
24
  }
25
+ // Ensure dataBar rules have required cfvo and color properties
26
+ if (rule.type === "dataBar") {
27
+ if (!rule.cfvo || rule.cfvo.length < 2) {
28
+ rule.cfvo = [{ type: "min" }, { type: "max" }];
29
+ }
30
+ if (!rule.color) {
31
+ // Default blue color for data bars (same as Excel's default)
32
+ rule.color = { argb: "FF638EC6" };
33
+ }
34
+ }
25
35
  });
26
36
  });
27
37
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v5.0.2
2
+ * @cj-tech-master/excelts v5.0.3-canary.20260125224944.ef1722b
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
@@ -13306,6 +13306,10 @@ var ExcelTS = (function(exports) {
13306
13306
  cf.rules.forEach((rule) => {
13307
13307
  if (!rule.priority) rule.priority = nextPriority++;
13308
13308
  if (rule.style) rule.dxfId = options.styles.addDxfStyle(rule.style);
13309
+ if (rule.type === "dataBar") {
13310
+ if (!rule.cfvo || rule.cfvo.length < 2) rule.cfvo = [{ type: "min" }, { type: "max" }];
13311
+ if (!rule.color) rule.color = { argb: "FF638EC6" };
13312
+ }
13309
13313
  });
13310
13314
  });
13311
13315
  }
@@ -15963,7 +15967,7 @@ var ExcelTS = (function(exports) {
15963
15967
  * Render loaded pivot cache definition (preserving original structure)
15964
15968
  */
15965
15969
  renderLoaded(xmlStream, model) {
15966
- const { cacheFields, sourceRef, sourceSheet, recordCount } = model;
15970
+ const { cacheFields, sourceRef, sourceSheet, sourceTableName, recordCount } = model;
15967
15971
  xmlStream.openXml(XmlStream.StdDocAttributes);
15968
15972
  xmlStream.openNode(this.tag, {
15969
15973
  ...PivotCacheDefinitionXform.PIVOT_CACHE_DEFINITION_ATTRIBUTES,
@@ -15975,10 +15979,11 @@ var ExcelTS = (function(exports) {
15975
15979
  recordCount: recordCount || cacheFields.length + 1
15976
15980
  });
15977
15981
  xmlStream.openNode("cacheSource", { type: "worksheet" });
15978
- xmlStream.leafNode("worksheetSource", {
15982
+ const worksheetSourceAttrs = sourceTableName ? { name: sourceTableName } : {
15979
15983
  ref: sourceRef,
15980
15984
  sheet: sourceSheet
15981
- });
15985
+ };
15986
+ xmlStream.leafNode("worksheetSource", worksheetSourceAttrs);
15982
15987
  xmlStream.closeNode();
15983
15988
  xmlStream.openNode("cacheFields", { count: cacheFields.length });
15984
15989
  xmlStream.writeXml(cacheFields.map((cacheField) => new CacheField(cacheField).render()).join("\n "));
@@ -16012,6 +16017,7 @@ var ExcelTS = (function(exports) {
16012
16017
  if (this.inCacheSource && this.model) {
16013
16018
  this.model.sourceRef = attributes.ref;
16014
16019
  this.model.sourceSheet = attributes.sheet;
16020
+ this.model.sourceTableName = attributes.name;
16015
16021
  }
16016
16022
  break;
16017
16023
  case "cacheFields":