@cj-tech-master/excelts 4.0.4-canary.20260109045014.00b0344 → 4.0.4-canary.20260109050555.4f97ebb
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/table.d.ts +6 -2
- package/dist/browser/modules/excel/table.js +33 -5
- package/dist/cjs/modules/excel/table.js +33 -5
- package/dist/esm/modules/excel/table.js +33 -5
- package/dist/iife/excelts.iife.js +21 -5
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +2 -2
- package/dist/types/modules/excel/table.d.ts +6 -2
- package/package.json +1 -1
|
@@ -52,8 +52,12 @@ declare class Table {
|
|
|
52
52
|
set model(value: TableModel);
|
|
53
53
|
cacheState(): void;
|
|
54
54
|
commit(): void;
|
|
55
|
-
addRow(values: CellValue[], rowNumber?: number
|
|
56
|
-
|
|
55
|
+
addRow(values: CellValue[], rowNumber?: number, options?: {
|
|
56
|
+
commit?: boolean;
|
|
57
|
+
}): void;
|
|
58
|
+
removeRows(rowIndex: number, count?: number, options?: {
|
|
59
|
+
commit?: boolean;
|
|
60
|
+
}): void;
|
|
57
61
|
getColumn(colIndex: number): Column;
|
|
58
62
|
addColumn(column: TableColumnProperties, values: CellValue[], colIndex?: number): void;
|
|
59
63
|
removeColumns(colIndex: number, count?: number): void;
|
|
@@ -57,6 +57,26 @@ class Table {
|
|
|
57
57
|
this.worksheet = worksheet;
|
|
58
58
|
if (table) {
|
|
59
59
|
this.table = table;
|
|
60
|
+
// When loading tables from xlsx, Excel stores table ranges and cell values in the worksheet,
|
|
61
|
+
// but may not embed row data into the table definition. Hydrate rows from the worksheet so
|
|
62
|
+
// table mutations (e.g. addRow) can correctly expand table ranges and serialize.
|
|
63
|
+
if (Array.isArray(table.rows) && table.rows.length === 0 && table.tableRef) {
|
|
64
|
+
const decoded = colCache.decode(table.tableRef);
|
|
65
|
+
if ("dimensions" in decoded) {
|
|
66
|
+
const startRow = decoded.top + (table.headerRow === false ? 0 : 1);
|
|
67
|
+
const endRow = decoded.bottom - (table.totalsRow === true ? 1 : 0);
|
|
68
|
+
if (endRow >= startRow) {
|
|
69
|
+
for (let r = startRow; r <= endRow; r++) {
|
|
70
|
+
const row = worksheet.getRow(r);
|
|
71
|
+
const values = [];
|
|
72
|
+
for (let c = decoded.left; c <= decoded.right; c++) {
|
|
73
|
+
values.push(row.getCell(c).value);
|
|
74
|
+
}
|
|
75
|
+
table.rows.push(values);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
60
80
|
// check things are ok first
|
|
61
81
|
this.validate();
|
|
62
82
|
this.store();
|
|
@@ -133,9 +153,10 @@ class Table {
|
|
|
133
153
|
const { row, col } = table.tl;
|
|
134
154
|
assert(row > 0, "Table must be on valid row");
|
|
135
155
|
assert(col > 0, "Table must be on valid col");
|
|
136
|
-
const { width,
|
|
137
|
-
// autoFilterRef is a range that
|
|
138
|
-
|
|
156
|
+
const { width, tableHeight } = this;
|
|
157
|
+
// autoFilterRef is a single-row range that targets the header row only.
|
|
158
|
+
// Excel uses this for filter buttons; including data rows can break filter rendering.
|
|
159
|
+
table.autoFilterRef = colCache.encode(row, col, row, col + width - 1);
|
|
139
160
|
// tableRef is a range that includes optional headers and totals
|
|
140
161
|
table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
|
|
141
162
|
table.columns.forEach((column, i) => {
|
|
@@ -304,8 +325,9 @@ class Table {
|
|
|
304
325
|
}
|
|
305
326
|
}
|
|
306
327
|
this.store();
|
|
328
|
+
this._cache = undefined;
|
|
307
329
|
}
|
|
308
|
-
addRow(values, rowNumber) {
|
|
330
|
+
addRow(values, rowNumber, options) {
|
|
309
331
|
// Add a row of data, either insert at rowNumber or append
|
|
310
332
|
this.cacheState();
|
|
311
333
|
if (rowNumber === undefined) {
|
|
@@ -314,11 +336,17 @@ class Table {
|
|
|
314
336
|
else {
|
|
315
337
|
this.table.rows.splice(rowNumber, 0, values);
|
|
316
338
|
}
|
|
339
|
+
if (options?.commit !== false) {
|
|
340
|
+
this.commit();
|
|
341
|
+
}
|
|
317
342
|
}
|
|
318
|
-
removeRows(rowIndex, count = 1) {
|
|
343
|
+
removeRows(rowIndex, count = 1, options) {
|
|
319
344
|
// Remove a rows of data
|
|
320
345
|
this.cacheState();
|
|
321
346
|
this.table.rows.splice(rowIndex, count);
|
|
347
|
+
if (options?.commit !== false) {
|
|
348
|
+
this.commit();
|
|
349
|
+
}
|
|
322
350
|
}
|
|
323
351
|
getColumn(colIndex) {
|
|
324
352
|
const column = this.table.columns[colIndex];
|
|
@@ -60,6 +60,26 @@ class Table {
|
|
|
60
60
|
this.worksheet = worksheet;
|
|
61
61
|
if (table) {
|
|
62
62
|
this.table = table;
|
|
63
|
+
// When loading tables from xlsx, Excel stores table ranges and cell values in the worksheet,
|
|
64
|
+
// but may not embed row data into the table definition. Hydrate rows from the worksheet so
|
|
65
|
+
// table mutations (e.g. addRow) can correctly expand table ranges and serialize.
|
|
66
|
+
if (Array.isArray(table.rows) && table.rows.length === 0 && table.tableRef) {
|
|
67
|
+
const decoded = col_cache_1.colCache.decode(table.tableRef);
|
|
68
|
+
if ("dimensions" in decoded) {
|
|
69
|
+
const startRow = decoded.top + (table.headerRow === false ? 0 : 1);
|
|
70
|
+
const endRow = decoded.bottom - (table.totalsRow === true ? 1 : 0);
|
|
71
|
+
if (endRow >= startRow) {
|
|
72
|
+
for (let r = startRow; r <= endRow; r++) {
|
|
73
|
+
const row = worksheet.getRow(r);
|
|
74
|
+
const values = [];
|
|
75
|
+
for (let c = decoded.left; c <= decoded.right; c++) {
|
|
76
|
+
values.push(row.getCell(c).value);
|
|
77
|
+
}
|
|
78
|
+
table.rows.push(values);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
63
83
|
// check things are ok first
|
|
64
84
|
this.validate();
|
|
65
85
|
this.store();
|
|
@@ -136,9 +156,10 @@ class Table {
|
|
|
136
156
|
const { row, col } = table.tl;
|
|
137
157
|
assert(row > 0, "Table must be on valid row");
|
|
138
158
|
assert(col > 0, "Table must be on valid col");
|
|
139
|
-
const { width,
|
|
140
|
-
// autoFilterRef is a range that
|
|
141
|
-
|
|
159
|
+
const { width, tableHeight } = this;
|
|
160
|
+
// autoFilterRef is a single-row range that targets the header row only.
|
|
161
|
+
// Excel uses this for filter buttons; including data rows can break filter rendering.
|
|
162
|
+
table.autoFilterRef = col_cache_1.colCache.encode(row, col, row, col + width - 1);
|
|
142
163
|
// tableRef is a range that includes optional headers and totals
|
|
143
164
|
table.tableRef = col_cache_1.colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
|
|
144
165
|
table.columns.forEach((column, i) => {
|
|
@@ -307,8 +328,9 @@ class Table {
|
|
|
307
328
|
}
|
|
308
329
|
}
|
|
309
330
|
this.store();
|
|
331
|
+
this._cache = undefined;
|
|
310
332
|
}
|
|
311
|
-
addRow(values, rowNumber) {
|
|
333
|
+
addRow(values, rowNumber, options) {
|
|
312
334
|
// Add a row of data, either insert at rowNumber or append
|
|
313
335
|
this.cacheState();
|
|
314
336
|
if (rowNumber === undefined) {
|
|
@@ -317,11 +339,17 @@ class Table {
|
|
|
317
339
|
else {
|
|
318
340
|
this.table.rows.splice(rowNumber, 0, values);
|
|
319
341
|
}
|
|
342
|
+
if (options?.commit !== false) {
|
|
343
|
+
this.commit();
|
|
344
|
+
}
|
|
320
345
|
}
|
|
321
|
-
removeRows(rowIndex, count = 1) {
|
|
346
|
+
removeRows(rowIndex, count = 1, options) {
|
|
322
347
|
// Remove a rows of data
|
|
323
348
|
this.cacheState();
|
|
324
349
|
this.table.rows.splice(rowIndex, count);
|
|
350
|
+
if (options?.commit !== false) {
|
|
351
|
+
this.commit();
|
|
352
|
+
}
|
|
325
353
|
}
|
|
326
354
|
getColumn(colIndex) {
|
|
327
355
|
const column = this.table.columns[colIndex];
|
|
@@ -57,6 +57,26 @@ class Table {
|
|
|
57
57
|
this.worksheet = worksheet;
|
|
58
58
|
if (table) {
|
|
59
59
|
this.table = table;
|
|
60
|
+
// When loading tables from xlsx, Excel stores table ranges and cell values in the worksheet,
|
|
61
|
+
// but may not embed row data into the table definition. Hydrate rows from the worksheet so
|
|
62
|
+
// table mutations (e.g. addRow) can correctly expand table ranges and serialize.
|
|
63
|
+
if (Array.isArray(table.rows) && table.rows.length === 0 && table.tableRef) {
|
|
64
|
+
const decoded = colCache.decode(table.tableRef);
|
|
65
|
+
if ("dimensions" in decoded) {
|
|
66
|
+
const startRow = decoded.top + (table.headerRow === false ? 0 : 1);
|
|
67
|
+
const endRow = decoded.bottom - (table.totalsRow === true ? 1 : 0);
|
|
68
|
+
if (endRow >= startRow) {
|
|
69
|
+
for (let r = startRow; r <= endRow; r++) {
|
|
70
|
+
const row = worksheet.getRow(r);
|
|
71
|
+
const values = [];
|
|
72
|
+
for (let c = decoded.left; c <= decoded.right; c++) {
|
|
73
|
+
values.push(row.getCell(c).value);
|
|
74
|
+
}
|
|
75
|
+
table.rows.push(values);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
60
80
|
// check things are ok first
|
|
61
81
|
this.validate();
|
|
62
82
|
this.store();
|
|
@@ -133,9 +153,10 @@ class Table {
|
|
|
133
153
|
const { row, col } = table.tl;
|
|
134
154
|
assert(row > 0, "Table must be on valid row");
|
|
135
155
|
assert(col > 0, "Table must be on valid col");
|
|
136
|
-
const { width,
|
|
137
|
-
// autoFilterRef is a range that
|
|
138
|
-
|
|
156
|
+
const { width, tableHeight } = this;
|
|
157
|
+
// autoFilterRef is a single-row range that targets the header row only.
|
|
158
|
+
// Excel uses this for filter buttons; including data rows can break filter rendering.
|
|
159
|
+
table.autoFilterRef = colCache.encode(row, col, row, col + width - 1);
|
|
139
160
|
// tableRef is a range that includes optional headers and totals
|
|
140
161
|
table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
|
|
141
162
|
table.columns.forEach((column, i) => {
|
|
@@ -304,8 +325,9 @@ class Table {
|
|
|
304
325
|
}
|
|
305
326
|
}
|
|
306
327
|
this.store();
|
|
328
|
+
this._cache = undefined;
|
|
307
329
|
}
|
|
308
|
-
addRow(values, rowNumber) {
|
|
330
|
+
addRow(values, rowNumber, options) {
|
|
309
331
|
// Add a row of data, either insert at rowNumber or append
|
|
310
332
|
this.cacheState();
|
|
311
333
|
if (rowNumber === undefined) {
|
|
@@ -314,11 +336,17 @@ class Table {
|
|
|
314
336
|
else {
|
|
315
337
|
this.table.rows.splice(rowNumber, 0, values);
|
|
316
338
|
}
|
|
339
|
+
if (options?.commit !== false) {
|
|
340
|
+
this.commit();
|
|
341
|
+
}
|
|
317
342
|
}
|
|
318
|
-
removeRows(rowIndex, count = 1) {
|
|
343
|
+
removeRows(rowIndex, count = 1, options) {
|
|
319
344
|
// Remove a rows of data
|
|
320
345
|
this.cacheState();
|
|
321
346
|
this.table.rows.splice(rowIndex, count);
|
|
347
|
+
if (options?.commit !== false) {
|
|
348
|
+
this.commit();
|
|
349
|
+
}
|
|
322
350
|
}
|
|
323
351
|
getColumn(colIndex) {
|
|
324
352
|
const column = this.table.columns[colIndex];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v4.0.4-canary.
|
|
2
|
+
* @cj-tech-master/excelts v4.0.4-canary.20260109050555.4f97ebb
|
|
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
|
|
@@ -2309,6 +2309,19 @@ var ExcelTS = (function(exports) {
|
|
|
2309
2309
|
this.worksheet = worksheet;
|
|
2310
2310
|
if (table) {
|
|
2311
2311
|
this.table = table;
|
|
2312
|
+
if (Array.isArray(table.rows) && table.rows.length === 0 && table.tableRef) {
|
|
2313
|
+
const decoded = colCache.decode(table.tableRef);
|
|
2314
|
+
if ("dimensions" in decoded) {
|
|
2315
|
+
const startRow = decoded.top + (table.headerRow === false ? 0 : 1);
|
|
2316
|
+
const endRow = decoded.bottom - (table.totalsRow === true ? 1 : 0);
|
|
2317
|
+
if (endRow >= startRow) for (let r = startRow; r <= endRow; r++) {
|
|
2318
|
+
const row = worksheet.getRow(r);
|
|
2319
|
+
const values = [];
|
|
2320
|
+
for (let c = decoded.left; c <= decoded.right; c++) values.push(row.getCell(c).value);
|
|
2321
|
+
table.rows.push(values);
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2312
2325
|
this.validate();
|
|
2313
2326
|
this.store();
|
|
2314
2327
|
}
|
|
@@ -2363,8 +2376,8 @@ var ExcelTS = (function(exports) {
|
|
|
2363
2376
|
const { row, col } = table.tl;
|
|
2364
2377
|
assert(row > 0, "Table must be on valid row");
|
|
2365
2378
|
assert(col > 0, "Table must be on valid col");
|
|
2366
|
-
const { width,
|
|
2367
|
-
table.autoFilterRef = colCache.encode(row, col, row
|
|
2379
|
+
const { width, tableHeight } = this;
|
|
2380
|
+
table.autoFilterRef = colCache.encode(row, col, row, col + width - 1);
|
|
2368
2381
|
table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);
|
|
2369
2382
|
table.columns.forEach((column, i) => {
|
|
2370
2383
|
assert(!!column.name, `Column ${i} must have a name`);
|
|
@@ -2491,15 +2504,18 @@ var ExcelTS = (function(exports) {
|
|
|
2491
2504
|
}
|
|
2492
2505
|
}
|
|
2493
2506
|
this.store();
|
|
2507
|
+
this._cache = void 0;
|
|
2494
2508
|
}
|
|
2495
|
-
addRow(values, rowNumber) {
|
|
2509
|
+
addRow(values, rowNumber, options) {
|
|
2496
2510
|
this.cacheState();
|
|
2497
2511
|
if (rowNumber === void 0) this.table.rows.push(values);
|
|
2498
2512
|
else this.table.rows.splice(rowNumber, 0, values);
|
|
2513
|
+
if (options?.commit !== false) this.commit();
|
|
2499
2514
|
}
|
|
2500
|
-
removeRows(rowIndex, count = 1) {
|
|
2515
|
+
removeRows(rowIndex, count = 1, options) {
|
|
2501
2516
|
this.cacheState();
|
|
2502
2517
|
this.table.rows.splice(rowIndex, count);
|
|
2518
|
+
if (options?.commit !== false) this.commit();
|
|
2503
2519
|
}
|
|
2504
2520
|
getColumn(colIndex) {
|
|
2505
2521
|
const column = this.table.columns[colIndex];
|