@cj-tech-master/excelts 4.0.3 → 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.
Files changed (181) hide show
  1. package/dist/browser/modules/excel/table.d.ts +6 -2
  2. package/dist/browser/modules/excel/table.js +33 -5
  3. package/dist/cjs/modules/excel/table.js +33 -5
  4. package/dist/esm/modules/excel/table.js +33 -5
  5. package/dist/iife/excelts.iife.js +21 -5
  6. package/dist/iife/excelts.iife.js.map +1 -1
  7. package/dist/iife/excelts.iife.min.js +2 -2
  8. package/dist/types/index.browser.d.ts +20 -20
  9. package/dist/types/index.d.ts +23 -23
  10. package/dist/types/modules/archive/compress.browser.d.ts +1 -1
  11. package/dist/types/modules/archive/compress.d.ts +2 -2
  12. package/dist/types/modules/archive/crc32.browser.d.ts +1 -1
  13. package/dist/types/modules/archive/crc32.d.ts +1 -1
  14. package/dist/types/modules/archive/defaults.d.ts +1 -1
  15. package/dist/types/modules/archive/extract.d.ts +6 -6
  16. package/dist/types/modules/archive/index.base.d.ts +4 -4
  17. package/dist/types/modules/archive/index.browser.d.ts +5 -5
  18. package/dist/types/modules/archive/index.d.ts +5 -5
  19. package/dist/types/modules/archive/parse.base.d.ts +3 -3
  20. package/dist/types/modules/archive/parse.browser.d.ts +2 -2
  21. package/dist/types/modules/archive/parse.d.ts +3 -3
  22. package/dist/types/modules/archive/streaming-compress.browser.d.ts +2 -2
  23. package/dist/types/modules/archive/streaming-compress.d.ts +2 -2
  24. package/dist/types/modules/archive/streaming-zip.d.ts +2 -2
  25. package/dist/types/modules/archive/zip-builder.d.ts +2 -2
  26. package/dist/types/modules/archive/zip-entry-metadata.d.ts +1 -1
  27. package/dist/types/modules/archive/zip-parser.d.ts +1 -1
  28. package/dist/types/modules/csv/csv-stream.d.ts +3 -3
  29. package/dist/types/modules/csv/csv.browser.d.ts +9 -9
  30. package/dist/types/modules/csv/csv.d.ts +4 -4
  31. package/dist/types/modules/excel/anchor.d.ts +1 -1
  32. package/dist/types/modules/excel/cell.d.ts +7 -7
  33. package/dist/types/modules/excel/column.d.ts +3 -3
  34. package/dist/types/modules/excel/defined-names.d.ts +4 -4
  35. package/dist/types/modules/excel/image.d.ts +2 -2
  36. package/dist/types/modules/excel/pivot-table.d.ts +1 -1
  37. package/dist/types/modules/excel/range.d.ts +1 -1
  38. package/dist/types/modules/excel/row.d.ts +3 -3
  39. package/dist/types/modules/excel/stream/hyperlink-reader.d.ts +2 -2
  40. package/dist/types/modules/excel/stream/workbook-reader.browser.d.ts +6 -6
  41. package/dist/types/modules/excel/stream/workbook-reader.d.ts +5 -5
  42. package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +8 -8
  43. package/dist/types/modules/excel/stream/workbook-writer.d.ts +2 -2
  44. package/dist/types/modules/excel/stream/worksheet-reader.d.ts +6 -6
  45. package/dist/types/modules/excel/stream/worksheet-writer.d.ts +9 -9
  46. package/dist/types/modules/excel/table.d.ts +8 -4
  47. package/dist/types/modules/excel/utils/col-cache.d.ts +1 -1
  48. package/dist/types/modules/excel/utils/sheet-utils.d.ts +3 -3
  49. package/dist/types/modules/excel/utils/stream-buf.d.ts +2 -2
  50. package/dist/types/modules/excel/workbook.d.ts +9 -9
  51. package/dist/types/modules/excel/worksheet.d.ts +10 -10
  52. package/dist/types/modules/excel/xlsx/xform/base-xform.d.ts +1 -1
  53. package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -1
  54. package/dist/types/modules/excel/xlsx/xform/book/sheet-xform.d.ts +1 -1
  55. package/dist/types/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.d.ts +1 -1
  56. package/dist/types/modules/excel/xlsx/xform/book/workbook-pivot-cache-xform.d.ts +1 -1
  57. package/dist/types/modules/excel/xlsx/xform/book/workbook-properties-xform.d.ts +1 -1
  58. package/dist/types/modules/excel/xlsx/xform/book/workbook-view-xform.d.ts +1 -1
  59. package/dist/types/modules/excel/xlsx/xform/book/workbook-xform.d.ts +2 -2
  60. package/dist/types/modules/excel/xlsx/xform/comment/comment-xform.d.ts +2 -2
  61. package/dist/types/modules/excel/xlsx/xform/comment/comments-xform.d.ts +2 -2
  62. package/dist/types/modules/excel/xlsx/xform/comment/style/vml-position-xform.d.ts +1 -1
  63. package/dist/types/modules/excel/xlsx/xform/comment/style/vml-protection-xform.d.ts +1 -1
  64. package/dist/types/modules/excel/xlsx/xform/comment/vml-anchor-xform.d.ts +1 -1
  65. package/dist/types/modules/excel/xlsx/xform/comment/vml-client-data-xform.d.ts +1 -1
  66. package/dist/types/modules/excel/xlsx/xform/comment/vml-notes-xform.d.ts +1 -1
  67. package/dist/types/modules/excel/xlsx/xform/comment/vml-shape-xform.d.ts +1 -1
  68. package/dist/types/modules/excel/xlsx/xform/comment/vml-textbox-xform.d.ts +1 -1
  69. package/dist/types/modules/excel/xlsx/xform/composite-xform.d.ts +1 -1
  70. package/dist/types/modules/excel/xlsx/xform/core/app-heading-pairs-xform.d.ts +1 -1
  71. package/dist/types/modules/excel/xlsx/xform/core/app-titles-of-parts-xform.d.ts +1 -1
  72. package/dist/types/modules/excel/xlsx/xform/core/app-xform.d.ts +1 -1
  73. package/dist/types/modules/excel/xlsx/xform/core/content-types-xform.d.ts +1 -1
  74. package/dist/types/modules/excel/xlsx/xform/core/core-xform.d.ts +1 -1
  75. package/dist/types/modules/excel/xlsx/xform/core/relationship-xform.d.ts +1 -1
  76. package/dist/types/modules/excel/xlsx/xform/core/relationships-xform.d.ts +1 -1
  77. package/dist/types/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.d.ts +1 -1
  78. package/dist/types/modules/excel/xlsx/xform/drawing/blip-fill-xform.d.ts +2 -2
  79. package/dist/types/modules/excel/xlsx/xform/drawing/blip-xform.d.ts +1 -1
  80. package/dist/types/modules/excel/xlsx/xform/drawing/c-nv-pic-pr-xform.d.ts +1 -1
  81. package/dist/types/modules/excel/xlsx/xform/drawing/c-nv-pr-xform.d.ts +1 -1
  82. package/dist/types/modules/excel/xlsx/xform/drawing/cell-position-xform.d.ts +2 -2
  83. package/dist/types/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +1 -1
  84. package/dist/types/modules/excel/xlsx/xform/drawing/ext-lst-xform.d.ts +1 -1
  85. package/dist/types/modules/excel/xlsx/xform/drawing/ext-xform.d.ts +1 -1
  86. package/dist/types/modules/excel/xlsx/xform/drawing/hlink-click-xform.d.ts +1 -1
  87. package/dist/types/modules/excel/xlsx/xform/drawing/nv-pic-pr-xform.d.ts +1 -1
  88. package/dist/types/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +1 -1
  89. package/dist/types/modules/excel/xlsx/xform/drawing/pic-xform.d.ts +1 -1
  90. package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +1 -1
  91. package/dist/types/modules/excel/xlsx/xform/list-xform.d.ts +1 -1
  92. package/dist/types/modules/excel/xlsx/xform/pivot-table/cache-field-xform.d.ts +1 -1
  93. package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-cache-definition-xform.d.ts +3 -3
  94. package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-cache-records-xform.d.ts +2 -2
  95. package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +1 -1
  96. package/dist/types/modules/excel/xlsx/xform/sheet/auto-filter-xform.d.ts +1 -1
  97. package/dist/types/modules/excel/xlsx/xform/sheet/cell-xform.d.ts +1 -1
  98. package/dist/types/modules/excel/xlsx/xform/sheet/cf/cf-rule-xform.d.ts +6 -6
  99. package/dist/types/modules/excel/xlsx/xform/sheet/cf/cfvo-xform.d.ts +1 -1
  100. package/dist/types/modules/excel/xlsx/xform/sheet/cf/color-scale-xform.d.ts +3 -3
  101. package/dist/types/modules/excel/xlsx/xform/sheet/cf/conditional-formatting-xform.d.ts +1 -1
  102. package/dist/types/modules/excel/xlsx/xform/sheet/cf/conditional-formattings-xform.d.ts +2 -2
  103. package/dist/types/modules/excel/xlsx/xform/sheet/cf/databar-xform.d.ts +3 -3
  104. package/dist/types/modules/excel/xlsx/xform/sheet/cf/ext-lst-ref-xform.d.ts +1 -1
  105. package/dist/types/modules/excel/xlsx/xform/sheet/cf/formula-xform.d.ts +1 -1
  106. package/dist/types/modules/excel/xlsx/xform/sheet/cf/icon-set-xform.d.ts +2 -2
  107. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/cf-icon-ext-xform.d.ts +1 -1
  108. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.d.ts +3 -3
  109. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/cfvo-ext-xform.d.ts +2 -2
  110. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.d.ts +3 -3
  111. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.d.ts +2 -2
  112. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/databar-ext-xform.d.ts +3 -3
  113. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/f-ext-xform.d.ts +1 -1
  114. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.d.ts +3 -3
  115. package/dist/types/modules/excel/xlsx/xform/sheet/cf-ext/sqref-ext-xform.d.ts +1 -1
  116. package/dist/types/modules/excel/xlsx/xform/sheet/col-breaks-xform.d.ts +1 -1
  117. package/dist/types/modules/excel/xlsx/xform/sheet/col-xform.d.ts +1 -1
  118. package/dist/types/modules/excel/xlsx/xform/sheet/data-validations-xform.d.ts +1 -1
  119. package/dist/types/modules/excel/xlsx/xform/sheet/dimension-xform.d.ts +1 -1
  120. package/dist/types/modules/excel/xlsx/xform/sheet/drawing-xform.d.ts +1 -1
  121. package/dist/types/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -1
  122. package/dist/types/modules/excel/xlsx/xform/sheet/header-footer-xform.d.ts +1 -1
  123. package/dist/types/modules/excel/xlsx/xform/sheet/hyperlink-xform.d.ts +1 -1
  124. package/dist/types/modules/excel/xlsx/xform/sheet/merge-cell-xform.d.ts +1 -1
  125. package/dist/types/modules/excel/xlsx/xform/sheet/outline-properties-xform.d.ts +1 -1
  126. package/dist/types/modules/excel/xlsx/xform/sheet/page-breaks-xform.d.ts +1 -1
  127. package/dist/types/modules/excel/xlsx/xform/sheet/page-margins-xform.d.ts +1 -1
  128. package/dist/types/modules/excel/xlsx/xform/sheet/page-setup-properties-xform.d.ts +1 -1
  129. package/dist/types/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -1
  130. package/dist/types/modules/excel/xlsx/xform/sheet/picture-xform.d.ts +1 -1
  131. package/dist/types/modules/excel/xlsx/xform/sheet/print-options-xform.d.ts +1 -1
  132. package/dist/types/modules/excel/xlsx/xform/sheet/row-breaks-xform.d.ts +1 -1
  133. package/dist/types/modules/excel/xlsx/xform/sheet/row-xform.d.ts +1 -1
  134. package/dist/types/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.d.ts +1 -1
  135. package/dist/types/modules/excel/xlsx/xform/sheet/sheet-properties-xform.d.ts +1 -1
  136. package/dist/types/modules/excel/xlsx/xform/sheet/sheet-protection-xform.d.ts +1 -1
  137. package/dist/types/modules/excel/xlsx/xform/sheet/sheet-view-xform.d.ts +1 -1
  138. package/dist/types/modules/excel/xlsx/xform/sheet/table-part-xform.d.ts +1 -1
  139. package/dist/types/modules/excel/xlsx/xform/sheet/worksheet-xform.d.ts +1 -1
  140. package/dist/types/modules/excel/xlsx/xform/simple/boolean-xform.d.ts +1 -1
  141. package/dist/types/modules/excel/xlsx/xform/simple/date-xform.d.ts +1 -1
  142. package/dist/types/modules/excel/xlsx/xform/simple/float-xform.d.ts +1 -1
  143. package/dist/types/modules/excel/xlsx/xform/simple/integer-xform.d.ts +1 -1
  144. package/dist/types/modules/excel/xlsx/xform/simple/string-xform.d.ts +1 -1
  145. package/dist/types/modules/excel/xlsx/xform/static-xform.d.ts +1 -1
  146. package/dist/types/modules/excel/xlsx/xform/strings/phonetic-text-xform.d.ts +1 -1
  147. package/dist/types/modules/excel/xlsx/xform/strings/rich-text-xform.d.ts +3 -3
  148. package/dist/types/modules/excel/xlsx/xform/strings/shared-string-xform.d.ts +1 -1
  149. package/dist/types/modules/excel/xlsx/xform/strings/shared-strings-xform.d.ts +2 -2
  150. package/dist/types/modules/excel/xlsx/xform/strings/text-xform.d.ts +1 -1
  151. package/dist/types/modules/excel/xlsx/xform/style/alignment-xform.d.ts +1 -1
  152. package/dist/types/modules/excel/xlsx/xform/style/border-xform.d.ts +2 -2
  153. package/dist/types/modules/excel/xlsx/xform/style/color-xform.d.ts +1 -1
  154. package/dist/types/modules/excel/xlsx/xform/style/dxf-xform.d.ts +1 -1
  155. package/dist/types/modules/excel/xlsx/xform/style/fill-xform.d.ts +2 -2
  156. package/dist/types/modules/excel/xlsx/xform/style/font-xform.d.ts +1 -1
  157. package/dist/types/modules/excel/xlsx/xform/style/numfmt-xform.d.ts +1 -1
  158. package/dist/types/modules/excel/xlsx/xform/style/protection-xform.d.ts +1 -1
  159. package/dist/types/modules/excel/xlsx/xform/style/style-xform.d.ts +3 -3
  160. package/dist/types/modules/excel/xlsx/xform/style/styles-xform.d.ts +2 -2
  161. package/dist/types/modules/excel/xlsx/xform/style/underline-xform.d.ts +1 -1
  162. package/dist/types/modules/excel/xlsx/xform/table/auto-filter-xform.d.ts +2 -2
  163. package/dist/types/modules/excel/xlsx/xform/table/custom-filter-xform.d.ts +1 -1
  164. package/dist/types/modules/excel/xlsx/xform/table/filter-column-xform.d.ts +2 -2
  165. package/dist/types/modules/excel/xlsx/xform/table/filter-xform.d.ts +1 -1
  166. package/dist/types/modules/excel/xlsx/xform/table/table-column-xform.d.ts +1 -1
  167. package/dist/types/modules/excel/xlsx/xform/table/table-style-info-xform.d.ts +1 -1
  168. package/dist/types/modules/excel/xlsx/xform/table/table-xform.d.ts +1 -1
  169. package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +3 -3
  170. package/dist/types/modules/excel/xlsx/xlsx.d.ts +1 -1
  171. package/dist/types/modules/stream/base-transform.d.ts +1 -1
  172. package/dist/types/modules/stream/buffered-stream.d.ts +1 -1
  173. package/dist/types/modules/stream/index.browser.d.ts +8 -8
  174. package/dist/types/modules/stream/index.d.ts +9 -9
  175. package/dist/types/modules/stream/pull-stream.d.ts +1 -1
  176. package/dist/types/modules/stream/streams.browser.d.ts +4 -4
  177. package/dist/types/modules/stream/streams.d.ts +3 -3
  178. package/dist/types/modules/stream/utils.d.ts +1 -1
  179. package/dist/types/utils/utils.browser.d.ts +1 -1
  180. package/dist/types/utils/utils.d.ts +1 -1
  181. package/package.json +10 -9
@@ -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): void;
56
- removeRows(rowIndex: number, count?: number): void;
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, filterHeight, tableHeight } = this;
137
- // autoFilterRef is a range that includes optional headers only
138
- table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1);
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, filterHeight, tableHeight } = this;
140
- // autoFilterRef is a range that includes optional headers only
141
- table.autoFilterRef = col_cache_1.colCache.encode(row, col, row + filterHeight - 1, col + width - 1);
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, filterHeight, tableHeight } = this;
137
- // autoFilterRef is a range that includes optional headers only
138
- table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1);
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.3
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, filterHeight, tableHeight } = this;
2367
- table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1);
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];