@cj-tech-master/excelts 5.1.10 → 5.1.11

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.
@@ -207,7 +207,7 @@ class Table {
207
207
  else {
208
208
  cell.value = value;
209
209
  }
210
- assignStyle(cell, table.columns[j].style);
210
+ assignStyle(cell, table.columns[j]?.style);
211
211
  });
212
212
  });
213
213
  if (table.totalsRow) {
@@ -468,6 +468,11 @@ export interface TableColumnProperties {
468
468
  totalsRowFunction?: "none" | "average" | "countNums" | "count" | "max" | "min" | "stdDev" | "var" | "sum" | "custom";
469
469
  totalsRowFormula?: string;
470
470
  totalsRowResult?: CellFormulaValue["result"];
471
+ /**
472
+ * Formula applied to every data row in this column.
473
+ * Corresponds to the OOXML `<calculatedColumnFormula>` element.
474
+ */
475
+ calculatedColumnFormula?: string;
471
476
  style?: Partial<Style>;
472
477
  }
473
478
  export interface TableProperties {
@@ -4,17 +4,22 @@ interface TableColumnModel {
4
4
  name: string;
5
5
  totalsRowLabel?: string;
6
6
  totalsRowFunction?: string;
7
+ totalsRowFormula?: string;
8
+ calculatedColumnFormula?: string;
7
9
  dxfId?: string;
8
10
  }
9
11
  declare class TableColumnXform extends BaseXform<TableColumnModel> {
12
+ private _childTag;
13
+ private _childText;
10
14
  constructor();
11
15
  get tag(): string;
12
16
  prepare(model: TableColumnModel, options: {
13
17
  index: number;
14
18
  }): void;
19
+ private _renderAttributes;
15
20
  render(xmlStream: any, model: TableColumnModel): void;
16
21
  parseOpen(node: any): boolean;
17
- parseText(): void;
18
- parseClose(): boolean;
22
+ parseText(text: string): void;
23
+ parseClose(name: string): boolean;
19
24
  }
20
25
  export { TableColumnXform };
@@ -2,6 +2,7 @@ import { BaseXform } from "../base-xform.js";
2
2
  class TableColumnXform extends BaseXform {
3
3
  constructor() {
4
4
  super();
5
+ this._childText = "";
5
6
  this.model = { name: "" };
6
7
  }
7
8
  get tag() {
@@ -10,15 +11,30 @@ class TableColumnXform extends BaseXform {
10
11
  prepare(model, options) {
11
12
  model.id = options.index + 1;
12
13
  }
13
- render(xmlStream, model) {
14
- xmlStream.leafNode(this.tag, {
14
+ _renderAttributes(model) {
15
+ return {
15
16
  id: model.id.toString(),
16
17
  name: model.name,
17
18
  totalsRowLabel: model.totalsRowLabel,
18
19
  // Excel doesn't output totalsRowFunction when value is 'none'
19
20
  totalsRowFunction: model.totalsRowFunction === "none" ? undefined : model.totalsRowFunction,
20
21
  dxfId: model.dxfId
21
- });
22
+ };
23
+ }
24
+ render(xmlStream, model) {
25
+ if (model.calculatedColumnFormula || model.totalsRowFormula) {
26
+ xmlStream.openNode(this.tag, this._renderAttributes(model));
27
+ if (model.calculatedColumnFormula) {
28
+ xmlStream.leafNode("calculatedColumnFormula", undefined, model.calculatedColumnFormula);
29
+ }
30
+ if (model.totalsRowFormula) {
31
+ xmlStream.leafNode("totalsRowFormula", undefined, model.totalsRowFormula);
32
+ }
33
+ xmlStream.closeNode();
34
+ }
35
+ else {
36
+ xmlStream.leafNode(this.tag, this._renderAttributes(model));
37
+ }
22
38
  }
23
39
  parseOpen(node) {
24
40
  if (node.name === this.tag) {
@@ -31,11 +47,28 @@ class TableColumnXform extends BaseXform {
31
47
  };
32
48
  return true;
33
49
  }
34
- return false;
50
+ // Recognise child elements whose text content we want to capture
51
+ if (node.name === "calculatedColumnFormula" || node.name === "totalsRowFormula") {
52
+ this._childTag = node.name;
53
+ this._childText = "";
54
+ }
55
+ return true;
56
+ }
57
+ parseText(text) {
58
+ if (this._childTag) {
59
+ this._childText += text;
60
+ }
35
61
  }
36
- parseText() { }
37
- parseClose() {
38
- return false;
62
+ parseClose(name) {
63
+ if (name === this.tag) {
64
+ return false;
65
+ }
66
+ // Closing a recognised child element — store captured text
67
+ if (this._childTag && name === this._childTag) {
68
+ this.model[this._childTag] = this._childText;
69
+ this._childTag = undefined;
70
+ }
71
+ return true;
39
72
  }
40
73
  }
41
74
  export { TableColumnXform };
@@ -210,7 +210,7 @@ class Table {
210
210
  else {
211
211
  cell.value = value;
212
212
  }
213
- assignStyle(cell, table.columns[j].style);
213
+ assignStyle(cell, table.columns[j]?.style);
214
214
  });
215
215
  });
216
216
  if (table.totalsRow) {
@@ -5,6 +5,7 @@ const base_xform_1 = require("../base-xform.js");
5
5
  class TableColumnXform extends base_xform_1.BaseXform {
6
6
  constructor() {
7
7
  super();
8
+ this._childText = "";
8
9
  this.model = { name: "" };
9
10
  }
10
11
  get tag() {
@@ -13,15 +14,30 @@ class TableColumnXform extends base_xform_1.BaseXform {
13
14
  prepare(model, options) {
14
15
  model.id = options.index + 1;
15
16
  }
16
- render(xmlStream, model) {
17
- xmlStream.leafNode(this.tag, {
17
+ _renderAttributes(model) {
18
+ return {
18
19
  id: model.id.toString(),
19
20
  name: model.name,
20
21
  totalsRowLabel: model.totalsRowLabel,
21
22
  // Excel doesn't output totalsRowFunction when value is 'none'
22
23
  totalsRowFunction: model.totalsRowFunction === "none" ? undefined : model.totalsRowFunction,
23
24
  dxfId: model.dxfId
24
- });
25
+ };
26
+ }
27
+ render(xmlStream, model) {
28
+ if (model.calculatedColumnFormula || model.totalsRowFormula) {
29
+ xmlStream.openNode(this.tag, this._renderAttributes(model));
30
+ if (model.calculatedColumnFormula) {
31
+ xmlStream.leafNode("calculatedColumnFormula", undefined, model.calculatedColumnFormula);
32
+ }
33
+ if (model.totalsRowFormula) {
34
+ xmlStream.leafNode("totalsRowFormula", undefined, model.totalsRowFormula);
35
+ }
36
+ xmlStream.closeNode();
37
+ }
38
+ else {
39
+ xmlStream.leafNode(this.tag, this._renderAttributes(model));
40
+ }
25
41
  }
26
42
  parseOpen(node) {
27
43
  if (node.name === this.tag) {
@@ -34,11 +50,28 @@ class TableColumnXform extends base_xform_1.BaseXform {
34
50
  };
35
51
  return true;
36
52
  }
37
- return false;
53
+ // Recognise child elements whose text content we want to capture
54
+ if (node.name === "calculatedColumnFormula" || node.name === "totalsRowFormula") {
55
+ this._childTag = node.name;
56
+ this._childText = "";
57
+ }
58
+ return true;
59
+ }
60
+ parseText(text) {
61
+ if (this._childTag) {
62
+ this._childText += text;
63
+ }
38
64
  }
39
- parseText() { }
40
- parseClose() {
41
- return false;
65
+ parseClose(name) {
66
+ if (name === this.tag) {
67
+ return false;
68
+ }
69
+ // Closing a recognised child element — store captured text
70
+ if (this._childTag && name === this._childTag) {
71
+ this.model[this._childTag] = this._childText;
72
+ this._childTag = undefined;
73
+ }
74
+ return true;
42
75
  }
43
76
  }
44
77
  exports.TableColumnXform = TableColumnXform;
@@ -207,7 +207,7 @@ class Table {
207
207
  else {
208
208
  cell.value = value;
209
209
  }
210
- assignStyle(cell, table.columns[j].style);
210
+ assignStyle(cell, table.columns[j]?.style);
211
211
  });
212
212
  });
213
213
  if (table.totalsRow) {
@@ -2,6 +2,7 @@ import { BaseXform } from "../base-xform.js";
2
2
  class TableColumnXform extends BaseXform {
3
3
  constructor() {
4
4
  super();
5
+ this._childText = "";
5
6
  this.model = { name: "" };
6
7
  }
7
8
  get tag() {
@@ -10,15 +11,30 @@ class TableColumnXform extends BaseXform {
10
11
  prepare(model, options) {
11
12
  model.id = options.index + 1;
12
13
  }
13
- render(xmlStream, model) {
14
- xmlStream.leafNode(this.tag, {
14
+ _renderAttributes(model) {
15
+ return {
15
16
  id: model.id.toString(),
16
17
  name: model.name,
17
18
  totalsRowLabel: model.totalsRowLabel,
18
19
  // Excel doesn't output totalsRowFunction when value is 'none'
19
20
  totalsRowFunction: model.totalsRowFunction === "none" ? undefined : model.totalsRowFunction,
20
21
  dxfId: model.dxfId
21
- });
22
+ };
23
+ }
24
+ render(xmlStream, model) {
25
+ if (model.calculatedColumnFormula || model.totalsRowFormula) {
26
+ xmlStream.openNode(this.tag, this._renderAttributes(model));
27
+ if (model.calculatedColumnFormula) {
28
+ xmlStream.leafNode("calculatedColumnFormula", undefined, model.calculatedColumnFormula);
29
+ }
30
+ if (model.totalsRowFormula) {
31
+ xmlStream.leafNode("totalsRowFormula", undefined, model.totalsRowFormula);
32
+ }
33
+ xmlStream.closeNode();
34
+ }
35
+ else {
36
+ xmlStream.leafNode(this.tag, this._renderAttributes(model));
37
+ }
22
38
  }
23
39
  parseOpen(node) {
24
40
  if (node.name === this.tag) {
@@ -31,11 +47,28 @@ class TableColumnXform extends BaseXform {
31
47
  };
32
48
  return true;
33
49
  }
34
- return false;
50
+ // Recognise child elements whose text content we want to capture
51
+ if (node.name === "calculatedColumnFormula" || node.name === "totalsRowFormula") {
52
+ this._childTag = node.name;
53
+ this._childText = "";
54
+ }
55
+ return true;
56
+ }
57
+ parseText(text) {
58
+ if (this._childTag) {
59
+ this._childText += text;
60
+ }
35
61
  }
36
- parseText() { }
37
- parseClose() {
38
- return false;
62
+ parseClose(name) {
63
+ if (name === this.tag) {
64
+ return false;
65
+ }
66
+ // Closing a recognised child element — store captured text
67
+ if (this._childTag && name === this._childTag) {
68
+ this.model[this._childTag] = this._childText;
69
+ this._childTag = undefined;
70
+ }
71
+ return true;
39
72
  }
40
73
  }
41
74
  export { TableColumnXform };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v5.1.10
2
+ * @cj-tech-master/excelts v5.1.11
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
@@ -2521,7 +2521,7 @@ var ExcelTS = (function(exports) {
2521
2521
  formula: shouldQualify ? formula.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g, `$1${table.name}[[#This Row],[$2]]`) : formula
2522
2522
  };
2523
2523
  } else cell.value = value;
2524
- assignStyle(cell, table.columns[j].style);
2524
+ assignStyle(cell, table.columns[j]?.style);
2525
2525
  });
2526
2526
  });
2527
2527
  if (table.totalsRow) {
@@ -15725,6 +15725,7 @@ var ExcelTS = (function(exports) {
15725
15725
  var TableColumnXform = class extends BaseXform {
15726
15726
  constructor() {
15727
15727
  super();
15728
+ this._childText = "";
15728
15729
  this.model = { name: "" };
15729
15730
  }
15730
15731
  get tag() {
@@ -15733,14 +15734,22 @@ var ExcelTS = (function(exports) {
15733
15734
  prepare(model, options) {
15734
15735
  model.id = options.index + 1;
15735
15736
  }
15736
- render(xmlStream, model) {
15737
- xmlStream.leafNode(this.tag, {
15737
+ _renderAttributes(model) {
15738
+ return {
15738
15739
  id: model.id.toString(),
15739
15740
  name: model.name,
15740
15741
  totalsRowLabel: model.totalsRowLabel,
15741
15742
  totalsRowFunction: model.totalsRowFunction === "none" ? void 0 : model.totalsRowFunction,
15742
15743
  dxfId: model.dxfId
15743
- });
15744
+ };
15745
+ }
15746
+ render(xmlStream, model) {
15747
+ if (model.calculatedColumnFormula || model.totalsRowFormula) {
15748
+ xmlStream.openNode(this.tag, this._renderAttributes(model));
15749
+ if (model.calculatedColumnFormula) xmlStream.leafNode("calculatedColumnFormula", void 0, model.calculatedColumnFormula);
15750
+ if (model.totalsRowFormula) xmlStream.leafNode("totalsRowFormula", void 0, model.totalsRowFormula);
15751
+ xmlStream.closeNode();
15752
+ } else xmlStream.leafNode(this.tag, this._renderAttributes(model));
15744
15753
  }
15745
15754
  parseOpen(node) {
15746
15755
  if (node.name === this.tag) {
@@ -15753,11 +15762,22 @@ var ExcelTS = (function(exports) {
15753
15762
  };
15754
15763
  return true;
15755
15764
  }
15756
- return false;
15765
+ if (node.name === "calculatedColumnFormula" || node.name === "totalsRowFormula") {
15766
+ this._childTag = node.name;
15767
+ this._childText = "";
15768
+ }
15769
+ return true;
15757
15770
  }
15758
- parseText() {}
15759
- parseClose() {
15760
- return false;
15771
+ parseText(text) {
15772
+ if (this._childTag) this._childText += text;
15773
+ }
15774
+ parseClose(name) {
15775
+ if (name === this.tag) return false;
15776
+ if (this._childTag && name === this._childTag) {
15777
+ this.model[this._childTag] = this._childText;
15778
+ this._childTag = void 0;
15779
+ }
15780
+ return true;
15761
15781
  }
15762
15782
  };
15763
15783