@cj-tech-master/excelts 4.0.1 → 4.0.2-canary.20260104092100.3972145

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.
@@ -8,6 +8,7 @@ interface TableModel {
8
8
  rows: CellValue[][];
9
9
  headerRow?: boolean;
10
10
  totalsRow?: boolean;
11
+ qualifyImplicitStructuredReferences?: boolean;
11
12
  style?: TableStyleProperties;
12
13
  tl?: Address;
13
14
  autoFilterRef?: string;
@@ -173,7 +173,19 @@ class Table {
173
173
  const r = worksheet.getRow(row + count++);
174
174
  data.forEach((value, j) => {
175
175
  const cell = r.getCell(col + j);
176
- cell.value = value;
176
+ const formula = value?.formula;
177
+ if (typeof formula === "string") {
178
+ const shouldQualify = table.qualifyImplicitStructuredReferences === true;
179
+ cell.value = {
180
+ ...value,
181
+ formula: shouldQualify
182
+ ? formula.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g, `$1${table.name}[[#This Row],[$2]]`)
183
+ : formula
184
+ };
185
+ }
186
+ else {
187
+ cell.value = value;
188
+ }
177
189
  assignStyle(cell, table.columns[j].style);
178
190
  });
179
191
  });
@@ -476,6 +476,13 @@ export interface TableProperties {
476
476
  ref: string;
477
477
  headerRow?: boolean;
478
478
  totalsRow?: boolean;
479
+ /**
480
+ * When true, expands implicit structured references like [@A] to
481
+ * TableName[[#This Row],[A]] when storing table row formulas.
482
+ *
483
+ * Default: false (keeps formulas as provided, e.g. [@A]).
484
+ */
485
+ qualifyImplicitStructuredReferences?: boolean;
479
486
  style?: TableStyleProperties;
480
487
  columns: TableColumnProperties[];
481
488
  rows: any[][];
@@ -176,7 +176,19 @@ class Table {
176
176
  const r = worksheet.getRow(row + count++);
177
177
  data.forEach((value, j) => {
178
178
  const cell = r.getCell(col + j);
179
- cell.value = value;
179
+ const formula = value?.formula;
180
+ if (typeof formula === "string") {
181
+ const shouldQualify = table.qualifyImplicitStructuredReferences === true;
182
+ cell.value = {
183
+ ...value,
184
+ formula: shouldQualify
185
+ ? formula.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g, `$1${table.name}[[#This Row],[$2]]`)
186
+ : formula
187
+ };
188
+ }
189
+ else {
190
+ cell.value = value;
191
+ }
180
192
  assignStyle(cell, table.columns[j].style);
181
193
  });
182
194
  });
@@ -173,7 +173,19 @@ class Table {
173
173
  const r = worksheet.getRow(row + count++);
174
174
  data.forEach((value, j) => {
175
175
  const cell = r.getCell(col + j);
176
- cell.value = value;
176
+ const formula = value?.formula;
177
+ if (typeof formula === "string") {
178
+ const shouldQualify = table.qualifyImplicitStructuredReferences === true;
179
+ cell.value = {
180
+ ...value,
181
+ formula: shouldQualify
182
+ ? formula.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g, `$1${table.name}[[#This Row],[$2]]`)
183
+ : formula
184
+ };
185
+ }
186
+ else {
187
+ cell.value = value;
188
+ }
177
189
  assignStyle(cell, table.columns[j].style);
178
190
  });
179
191
  });
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v4.0.1
2
+ * @cj-tech-master/excelts v4.0.2-canary.20260104092100.3972145
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
@@ -2395,7 +2395,14 @@ var ExcelTS = (function(exports) {
2395
2395
  const r = worksheet.getRow(row + count++);
2396
2396
  data.forEach((value, j) => {
2397
2397
  const cell = r.getCell(col + j);
2398
- cell.value = value;
2398
+ const formula = value?.formula;
2399
+ if (typeof formula === "string") {
2400
+ const shouldQualify = table.qualifyImplicitStructuredReferences === true;
2401
+ cell.value = {
2402
+ ...value,
2403
+ formula: shouldQualify ? formula.replace(/(^|[^A-Za-z0-9_])\[@\[?([^\[\]]+?)\]?\]/g, `$1${table.name}[[#This Row],[$2]]`) : formula
2404
+ };
2405
+ } else cell.value = value;
2399
2406
  assignStyle(cell, table.columns[j].style);
2400
2407
  });
2401
2408
  });