xlsx-template-browser 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -148,6 +148,13 @@ To use the library, you need the code like this:
148
148
 
149
149
  ## Changelog History
150
150
 
151
+ ### Version 0.3.1
152
+
153
+ * Bugfix in types
154
+ * Proper extensions of rows and columns for tables, pivot tables, data validations,
155
+ and conitional formatting un case of multiple extensions
156
+ * Proper handling of undefined ${table:} values
157
+
151
158
  ### Version 0.3.0
152
159
 
153
160
  * Performance is optimized
package/dist/index.cjs CHANGED
@@ -580,6 +580,10 @@ var getReplacements = (oldValues, dataStore) => {
580
580
  }
581
581
  const isTable = typeof match.groups.table === "string";
582
582
  const value = dataStore.get(match.groups.accessor);
583
+ if (typeof value !== "object") {
584
+ replacements.set(String(index), "");
585
+ continue;
586
+ }
583
587
  const cloned = structuredClone(value);
584
588
  if (isTable) Object.defineProperty(cloned, "$isTable", { value: true, enumerable: false });
585
589
  replacements.set(String(index), cloned);
@@ -1222,13 +1226,23 @@ var getConditionalFormatting = (xml) => {
1222
1226
  rows: 0,
1223
1227
  cols: 0
1224
1228
  };
1229
+ let columnExtension = 0;
1230
+ let rowExtension = 0;
1231
+ let currentRow = 0;
1225
1232
  const extend = (cell) => {
1226
1233
  if (Array.isArray(cell.newValue)) {
1234
+ if (cell.row !== currentRow) {
1235
+ currentRow = cell.row;
1236
+ columnExtension = 0;
1237
+ rowExtension = 0;
1238
+ }
1227
1239
  const length = cell.newValue.length - 1;
1228
1240
  if ("$isTable" in cell.newValue) {
1229
- extension.rows = Math.max(length, extension.rows);
1241
+ rowExtension = Math.max(length, rowExtension) - Math.min(length, rowExtension);
1242
+ extension.rows = extension.rows + rowExtension;
1230
1243
  } else {
1231
- extension.cols = Math.max(length, extension.cols);
1244
+ columnExtension = columnExtension + length;
1245
+ extension.cols = Math.max(columnExtension, extension.cols);
1232
1246
  }
1233
1247
  }
1234
1248
  };
@@ -1314,6 +1328,9 @@ var getTables = async ({
1314
1328
  return h;
1315
1329
  });
1316
1330
  };
1331
+ let columnExtension = 0;
1332
+ let rowExtension = 0;
1333
+ let currentRow = 0;
1317
1334
  const extend = (cell) => {
1318
1335
  const t = tables.get(file);
1319
1336
  if (t === void 0) return;
@@ -1329,11 +1346,18 @@ var getTables = async ({
1329
1346
  }
1330
1347
  }
1331
1348
  if (Array.isArray(cell.newValue)) {
1349
+ if (cell.row !== currentRow) {
1350
+ currentRow = cell.row;
1351
+ columnExtension = 0;
1352
+ rowExtension = 0;
1353
+ }
1332
1354
  const length = cell.newValue.length - 1;
1333
1355
  if ("$isTable" in cell.newValue) {
1334
- t.extension.rows = t.extension.rows + length;
1356
+ rowExtension = Math.max(length, rowExtension) - Math.min(length, rowExtension);
1357
+ t.extension.rows = t.extension.rows + rowExtension;
1335
1358
  } else {
1336
- t.extension.cols = t.extension.cols + length;
1359
+ columnExtension = columnExtension + length;
1360
+ t.extension.cols = Math.max(columnExtension, t.extension.cols);
1337
1361
  }
1338
1362
  }
1339
1363
  t.isDirty = true;
@@ -1786,13 +1810,23 @@ var getPivotTables = async (xlsx) => {
1786
1810
  rows: 0,
1787
1811
  cols: 0
1788
1812
  };
1813
+ let columnExtension = 0;
1814
+ let rowExtension = 0;
1815
+ let currentRow = 0;
1789
1816
  const extend = (cell) => {
1790
1817
  if (Array.isArray(cell.newValue)) {
1818
+ if (cell.row !== currentRow) {
1819
+ currentRow = cell.row;
1820
+ columnExtension = 0;
1821
+ rowExtension = 0;
1822
+ }
1791
1823
  const length = cell.newValue.length - 1;
1792
1824
  if ("$isTable" in cell.newValue) {
1793
- extension.rows = Math.max(length, extension.rows);
1825
+ rowExtension = Math.max(length, rowExtension) - Math.min(length, rowExtension);
1826
+ extension.rows = extension.rows + rowExtension;
1794
1827
  } else {
1795
- extension.cols = Math.max(length, extension.cols);
1828
+ columnExtension = columnExtension + length;
1829
+ extension.cols = Math.max(columnExtension, extension.cols);
1796
1830
  }
1797
1831
  }
1798
1832
  };
@@ -1910,13 +1944,23 @@ var getDataValidations = (sheets) => {
1910
1944
  validation.listRange.range = parseCellRange(reference.ref);
1911
1945
  }
1912
1946
  }
1947
+ let columnExtension = 0;
1948
+ let rowExtension = 0;
1949
+ let currentRow = 0;
1913
1950
  const extend = (cell) => {
1914
1951
  if (Array.isArray(cell.newValue)) {
1952
+ if (cell.row !== currentRow) {
1953
+ currentRow = cell.row;
1954
+ columnExtension = 0;
1955
+ rowExtension = 0;
1956
+ }
1915
1957
  const length = cell.newValue.length - 1;
1916
1958
  if ("$isTable" in cell.newValue) {
1917
- extension.rows = Math.max(length, extension.rows);
1959
+ rowExtension = Math.max(length, rowExtension) - Math.min(length, rowExtension);
1960
+ extension.rows = extension.rows + rowExtension;
1918
1961
  } else {
1919
- extension.cols = Math.max(length, extension.cols);
1962
+ columnExtension = columnExtension + length;
1963
+ extension.cols = Math.max(columnExtension, extension.cols);
1920
1964
  }
1921
1965
  }
1922
1966
  };