ooxml-core 1.8.0 → 1.8.2

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.
@@ -163,6 +163,7 @@ function deleteCell(sheet, row2, col) {
163
163
  cells.delete(col);
164
164
  if (cells.size === 0) sheet.rows.delete(row2);
165
165
  }
166
+ var isEmptyCell = (cell) => !cell || cell.value === null && !cell.formula && !cell.styleId && !cell.richText;
166
167
  function forEachCell(sheet, visit2) {
167
168
  for (const row2 of [...sheet.rows.keys()].sort((a, b) => a - b)) {
168
169
  const cells = sheet.rows.get(row2);
@@ -3493,7 +3494,7 @@ function stack(ctx, args, vertical2) {
3493
3494
  function flatten(ctx, args) {
3494
3495
  const m = ctx.toMatrix(args[0] ?? null);
3495
3496
  const ignore = intAt(ctx, args, 1) ?? 0;
3496
- const byCol = intAt(ctx, args, 2) ? true : false;
3497
+ const byCol = Boolean(intAt(ctx, args, 2));
3497
3498
  const values2 = [];
3498
3499
  const rows2 = byCol ? m.cols : m.rows;
3499
3500
  const cols = byCol ? m.rows : m.cols;
@@ -6727,7 +6728,7 @@ function ifFn(args, ctx) {
6727
6728
  const branch = (truthy) => {
6728
6729
  const arg = args[truthy ? 1 : 2];
6729
6730
  if (arg) return arg.get();
6730
- return truthy ? true : false;
6731
+ return truthy;
6731
6732
  };
6732
6733
  if (cond instanceof Matrix) return elementwise(cond, branch, ctx);
6733
6734
  if (isError(cond)) return cond;
@@ -14391,6 +14392,29 @@ function pruneCell(sheet, row2, col) {
14391
14392
 
14392
14393
  // xlsx/edit/shift-preserved.ts
14393
14394
  var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
14395
+ function hasPreservedOverflow(sheet, shift2, clipped, banded) {
14396
+ const keys = banded ? ["extLst"] : [shift2.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
14397
+ for (const key of keys)
14398
+ for (const xml of sheet.preserved.get(key) ?? []) {
14399
+ if (!xml.includes(key === "extLst" ? "sqref" : "brk")) continue;
14400
+ let root;
14401
+ try {
14402
+ root = parseXml(xml).documentElement;
14403
+ } catch {
14404
+ continue;
14405
+ }
14406
+ if (key === "extLst") {
14407
+ if (descendants2(root, XM3, "sqref").some(
14408
+ (node) => parseSqref(node.textContent ?? "").some(clipped)
14409
+ ))
14410
+ return true;
14411
+ } else if (elements(root).some(
14412
+ (node) => node.localName === "brk" && shiftIndex(Number(node.getAttribute("id") ?? "0"), shift2) === void 0
14413
+ ))
14414
+ return true;
14415
+ }
14416
+ return false;
14417
+ }
14394
14418
  function descendants2(root, ns, local) {
14395
14419
  return Array.from(root.getElementsByTagNameNS(ns, local));
14396
14420
  }
@@ -15625,6 +15649,39 @@ function setBorders(ctx, s, range2, preset, edge = { style: "thin" }) {
15625
15649
  );
15626
15650
  }
15627
15651
 
15652
+ // xlsx/edit/insert-guard.ts
15653
+ function assertInsertFits(sheet, shift2, band) {
15654
+ if (shift2.count <= 0) return;
15655
+ const max = shift2.axis === "row" ? MAX_ROW : MAX_COL;
15656
+ if (shift2.at + shift2.count > max + 1)
15657
+ throw new RangeError("The insert area extends beyond the sheet.");
15658
+ const first2 = max - shift2.count + 1;
15659
+ const lost = shift2.axis === "row" ? cellRange(first2, band?.lo ?? 0, MAX_ROW, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, first2, band?.hi ?? MAX_ROW, MAX_COL);
15660
+ const other = shift2.axis === "row" ? "col" : "row";
15661
+ const clipped = (range2) => (!band || range2.start[other] >= band.lo && range2.end[other] <= band.hi) && rangesIntersect(range2, lost);
15662
+ const fail2 = () => {
15663
+ throw new Error("Cannot insert cells: non-empty cells would be pushed off the sheet.");
15664
+ };
15665
+ for (const [row2, cells] of sheet.rows) {
15666
+ if (row2 < lost.start.row || row2 > lost.end.row) continue;
15667
+ for (const [col, cell] of cells)
15668
+ if (col >= lost.start.col && col <= lost.end.col && (!isEmptyCell(cell) || cell.cellMetadata !== void 0 || cell.valueMetadata !== void 0))
15669
+ fail2();
15670
+ }
15671
+ if (sheet.comments.some((c) => rangesIntersect(cellRange(c.address.row, c.address.col), lost)) || sheet.hyperlinks.some((h2) => rangesIntersect(h2.range, lost)) || sheet.merges.some((m) => rangesIntersect(m, lost)) || sheet.tables.some((t) => rangesIntersect(t.range, lost)) || sheet.dataValidations.some((rule) => rule.ranges.some(clipped)) || sheet.conditionalFormats.some((format) => format.ranges.some(clipped)) || sheet.autoFilter !== void 0 && clipped(sheet.autoFilter.range) || sheet.pageSetup?.printArea !== void 0 && clipped(sheet.pageSetup.printArea) || hasPreservedOverflow(sheet, shift2, clipped, !!band))
15672
+ fail2();
15673
+ for (const { anchor } of sheet.drawings) {
15674
+ if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) continue;
15675
+ if (anchor.from[shift2.axis] >= first2 || anchor.to && anchor.to[shift2.axis] >= first2) fail2();
15676
+ }
15677
+ if (band) return;
15678
+ if (shift2.axis === "row") {
15679
+ for (const [row2, info] of sheet.rowInfo) if (row2 >= first2 && Object.keys(info).length) fail2();
15680
+ } else {
15681
+ if (normalizeColumns(sheet.columns).some((c) => c.min >= first2)) fail2();
15682
+ }
15683
+ }
15684
+
15628
15685
  // xlsx/edit/shift-rule-anchors.ts
15629
15686
  function rebaseRulesForDeletion(sheet, shift2, band) {
15630
15687
  if (shift2.count >= 0) return;
@@ -15646,6 +15703,7 @@ function rebaseRulesForDeletion(sheet, shift2, band) {
15646
15703
 
15647
15704
  // xlsx/edit/shift-sheet.ts
15648
15705
  function shiftSheetContent(sheet, shift2, band) {
15706
+ assertInsertFits(sheet, shift2, band);
15649
15707
  const moveRange = (range2) => band ? shiftRangeInBand(range2, shift2, band.lo, band.hi) : shiftRange(range2, shift2);
15650
15708
  shiftCells(sheet, shift2, band, moveRange);
15651
15709
  sheet.merges = sheet.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
@@ -15783,10 +15841,11 @@ function shiftFreeze(sheet, shift2) {
15783
15841
  // xlsx/edit/structure.ts
15784
15842
  function checkSpan(axis, at, count2) {
15785
15843
  const max = axis === "row" ? MAX_ROW : MAX_COL;
15786
- if (!Number.isInteger(at) || !Number.isInteger(count2) || at < 0 || at > max || count2 < 1)
15844
+ if (!Number.isInteger(at) || !Number.isInteger(count2) || at < 0 || at > max || count2 < 1 || at + count2 > max + 1)
15787
15845
  throw new RangeError(`Invalid ${axis} span ${at} + ${count2}`);
15788
15846
  }
15789
15847
  function applyAxisShift(ctx, sheet, shift2) {
15848
+ assertInsertFits(sheet, shift2);
15790
15849
  rebaseRulesForDeletion(sheet, shift2);
15791
15850
  const spec2 = { sheet: sheet.name, axis: shift2.axis, at: shift2.at, count: shift2.count };
15792
15851
  rewriteFormulas(
@@ -15820,6 +15879,7 @@ function shiftAxis(ctx, s, axis, at, count2, insert) {
15820
15879
  const sheet = sheetAt(ctx.workbook, s);
15821
15880
  const noun = axis === "row" ? count2 === 1 ? "row" : "rows" : count2 === 1 ? "column" : "columns";
15822
15881
  const shift2 = { axis, at, count: insert ? count2 : -count2 };
15882
+ assertInsertFits(sheet, shift2);
15823
15883
  const info = { sheet: s, structural: true };
15824
15884
  if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift2))
15825
15885
  info.calc = { kind: "shift", sheet: s, shift: shift2 };
@@ -15862,6 +15922,7 @@ function shiftBand(ctx, s, range2, direction) {
15862
15922
  };
15863
15923
  const band = vertical2 ? { lo: r.start.col, hi: r.end.col } : { lo: r.start.row, hi: r.end.row };
15864
15924
  assertBandIntact(sheet, shift2, band);
15925
+ assertInsertFits(sheet, shift2, band);
15865
15926
  ctx.run(
15866
15927
  `${insert ? "Insert" : "Delete"} cells`,
15867
15928
  "structure",
@@ -18133,6 +18194,7 @@ var byId = (sheet, id) => {
18133
18194
  function insertBandRow(workbook, sheet, table2, row2) {
18134
18195
  const shift2 = { axis: "row", at: row2, count: 1 };
18135
18196
  const band = { lo: table2.range.start.col, hi: table2.range.end.col };
18197
+ assertInsertFits(sheet, shift2, band);
18136
18198
  rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
18137
18199
  shiftSheetContent(sheet, shift2, band);
18138
18200
  }
@@ -18171,6 +18233,7 @@ function setTotalsRow(workbook, sheet, id, on) {
18171
18233
  table2.totalsRow = false;
18172
18234
  return;
18173
18235
  }
18236
+ if (end.row === MAX_ROW) throw new RangeError("The insert area extends beyond the sheet.");
18174
18237
  if (!rowIsEmpty(sheet, end.row + 1, start.col, end.col)) {
18175
18238
  insertBandRow(workbook, sheet, table2, end.row + 1);
18176
18239
  table2 = byId(sheet, id);
@@ -27059,6 +27122,7 @@ var grid = {
27059
27122
  "A sheet name cannot be blank.": "Ein Blattname darf nicht leer sein.",
27060
27123
  "A sheet name cannot contain \\ / ? * [ ] or :": "Ein Blattname darf \\ / ? * [ ] oder : nicht enthalten",
27061
27124
  "A sheet name cannot start or end with an apostrophe.": "Ein Blattname darf nicht mit einem Apostroph beginnen oder enden.",
27125
+ "Cannot insert cells: non-empty cells would be pushed off the sheet.": "Zellen k\xF6nnen nicht eingef\xFCgt werden: Nicht leere Zellen w\xFCrden \xFCber den Blattrand hinaus verschoben.",
27062
27126
  Cancel: "Abbrechen",
27063
27127
  "Cell editor": "Zelleneditor",
27064
27128
  Chart: "Diagramm",
@@ -27124,6 +27188,7 @@ var grid = {
27124
27188
  "Tab Color": "Registerfarbe",
27125
27189
  "That name is already taken.": "Dieser Name ist bereits vergeben.",
27126
27190
  "The browser didn't allow access to the clipboard. Use Ctrl+V to paste.": "Der Browser hat den Zugriff auf die Zwischenablage nicht erlaubt. Verwenden Sie Strg+V zum Einf\xFCgen.",
27191
+ "The insert area extends beyond the sheet.": "Der einzuf\xFCgende Bereich reicht \xFCber das Blatt hinaus.",
27127
27192
  "The paste area extends beyond the sheet.": "Der Einf\xFCgebereich reicht \xFCber das Blatt hinaus.",
27128
27193
  "This action won't work on multiple selections.": "Diese Aktion funktioniert nicht bei Mehrfachauswahlen.",
27129
27194
  "This chart could not be displayed.": "Dieses Diagramm konnte nicht angezeigt werden.",
@@ -27445,6 +27510,7 @@ var grid2 = {
27445
27510
  "A sheet name cannot be blank.": "A sheet name cannot be blank.",
27446
27511
  "A sheet name cannot contain \\ / ? * [ ] or :": "A sheet name cannot contain \\ / ? * [ ] or :",
27447
27512
  "A sheet name cannot start or end with an apostrophe.": "A sheet name cannot start or end with an apostrophe.",
27513
+ "Cannot insert cells: non-empty cells would be pushed off the sheet.": "Cannot insert cells: non-empty cells would be pushed off the sheet.",
27448
27514
  Cancel: "Cancel",
27449
27515
  "Cell editor": "Cell editor",
27450
27516
  Chart: "Chart",
@@ -27510,6 +27576,7 @@ var grid2 = {
27510
27576
  "Tab Color": "Tab Color",
27511
27577
  "That name is already taken.": "That name is already taken.",
27512
27578
  "The browser didn't allow access to the clipboard. Use Ctrl+V to paste.": "The browser didn't allow access to the clipboard. Use Ctrl+V to paste.",
27579
+ "The insert area extends beyond the sheet.": "The insert area extends beyond the sheet.",
27513
27580
  "The paste area extends beyond the sheet.": "The paste area extends beyond the sheet.",
27514
27581
  "This action won't work on multiple selections.": "This action won't work on multiple selections.",
27515
27582
  "This chart could not be displayed.": "This chart could not be displayed.",
@@ -27831,6 +27898,7 @@ var grid3 = {
27831
27898
  "A sheet name cannot be blank.": "El nombre de una hoja no puede estar en blanco.",
27832
27899
  "A sheet name cannot contain \\ / ? * [ ] or :": "El nombre de una hoja no puede contener \\ / ? * [ ] ni :",
27833
27900
  "A sheet name cannot start or end with an apostrophe.": "El nombre de una hoja no puede empezar ni terminar con un ap\xF3strofo.",
27901
+ "Cannot insert cells: non-empty cells would be pushed off the sheet.": "No se pueden insertar celdas: las celdas no vac\xEDas se desplazar\xEDan fuera de la hoja.",
27834
27902
  Cancel: "Cancelar",
27835
27903
  "Cell editor": "Editor de celdas",
27836
27904
  Chart: "Gr\xE1fico",
@@ -27896,6 +27964,7 @@ var grid3 = {
27896
27964
  "Tab Color": "Color de pesta\xF1a",
27897
27965
  "That name is already taken.": "Ese nombre ya est\xE1 en uso.",
27898
27966
  "The browser didn't allow access to the clipboard. Use Ctrl+V to paste.": "El explorador no permiti\xF3 el acceso al portapapeles. Use Ctrl+V para pegar.",
27967
+ "The insert area extends beyond the sheet.": "El \xE1rea de inserci\xF3n se extiende m\xE1s all\xE1 de la hoja.",
27899
27968
  "The paste area extends beyond the sheet.": "El \xE1rea de pegado se extiende m\xE1s all\xE1 de la hoja.",
27900
27969
  "This action won't work on multiple selections.": "Esta acci\xF3n no funciona en selecciones m\xFAltiples.",
27901
27970
  "This chart could not be displayed.": "No se pudo mostrar este gr\xE1fico.",
@@ -28217,6 +28286,7 @@ var grid4 = {
28217
28286
  "A sheet name cannot be blank.": "Un nom de feuille ne peut pas \xEAtre vide.",
28218
28287
  "A sheet name cannot contain \\ / ? * [ ] or :": "Un nom de feuille ne peut pas contenir \\ / ? * [ ] ou :",
28219
28288
  "A sheet name cannot start or end with an apostrophe.": "Un nom de feuille ne peut pas commencer ou se terminer par une apostrophe.",
28289
+ "Cannot insert cells: non-empty cells would be pushed off the sheet.": "Impossible d\u2019ins\xE9rer des cellules : des cellules non vides seraient d\xE9plac\xE9es hors de la feuille.",
28220
28290
  Cancel: "Annuler",
28221
28291
  "Cell editor": "\xC9diteur de cellule",
28222
28292
  Chart: "Graphique",
@@ -28282,6 +28352,7 @@ var grid4 = {
28282
28352
  "Tab Color": "Couleur d\u2019onglet",
28283
28353
  "That name is already taken.": "Ce nom est d\xE9j\xE0 utilis\xE9.",
28284
28354
  "The browser didn't allow access to the clipboard. Use Ctrl+V to paste.": "Le navigateur n'a pas autoris\xE9 l'acc\xE8s au Presse-papiers. Utilisez Ctrl+V pour coller.",
28355
+ "The insert area extends beyond the sheet.": "La zone d\u2019insertion d\xE9passe les limites de la feuille.",
28285
28356
  "The paste area extends beyond the sheet.": "La zone de collage d\xE9passe les limites de la feuille.",
28286
28357
  "This action won't work on multiple selections.": "Cette action ne fonctionne pas sur des s\xE9lections multiples.",
28287
28358
  "This chart could not be displayed.": "Ce graphique n'a pas pu \xEAtre affich\xE9.",
@@ -28603,6 +28674,7 @@ var grid5 = {
28603
28674
  "A sheet name cannot be blank.": "\u5DE5\u4F5C\u8868\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u3002",
28604
28675
  "A sheet name cannot contain \\ / ? * [ ] or :": "\u5DE5\u4F5C\u8868\u540D\u79F0\u4E0D\u80FD\u5305\u542B \\ / ? * [ ] \u6216 :",
28605
28676
  "A sheet name cannot start or end with an apostrophe.": "\u5DE5\u4F5C\u8868\u540D\u79F0\u4E0D\u80FD\u4EE5\u6487\u53F7\u5F00\u5934\u6216\u7ED3\u5C3E\u3002",
28677
+ "Cannot insert cells: non-empty cells would be pushed off the sheet.": "\u65E0\u6CD5\u63D2\u5165\u5355\u5143\u683C\uFF1A\u975E\u7A7A\u5355\u5143\u683C\u4F1A\u88AB\u79FB\u51FA\u5DE5\u4F5C\u8868\u3002",
28606
28678
  Cancel: "\u53D6\u6D88",
28607
28679
  "Cell editor": "\u5355\u5143\u683C\u7F16\u8F91\u5668",
28608
28680
  Chart: "\u56FE\u8868",
@@ -28668,6 +28740,7 @@ var grid5 = {
28668
28740
  "Tab Color": "\u5DE5\u4F5C\u8868\u6807\u7B7E\u989C\u8272",
28669
28741
  "That name is already taken.": "\u8BE5\u540D\u79F0\u5DF2\u88AB\u4F7F\u7528\u3002",
28670
28742
  "The browser didn't allow access to the clipboard. Use Ctrl+V to paste.": "\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u8BBF\u95EE\u526A\u8D34\u677F\u3002\u8BF7\u4F7F\u7528 Ctrl+V \u7C98\u8D34\u3002",
28743
+ "The insert area extends beyond the sheet.": "\u63D2\u5165\u533A\u57DF\u8D85\u51FA\u4E86\u5DE5\u4F5C\u8868\u8303\u56F4\u3002",
28671
28744
  "The paste area extends beyond the sheet.": "\u7C98\u8D34\u533A\u57DF\u8D85\u51FA\u4E86\u5DE5\u4F5C\u8868\u8303\u56F4\u3002",
28672
28745
  "This action won't work on multiple selections.": "\u6B64\u64CD\u4F5C\u4E0D\u9002\u7528\u4E8E\u591A\u91CD\u9009\u62E9\u3002",
28673
28746
  "This chart could not be displayed.": "\u65E0\u6CD5\u663E\u793A\u6B64\u56FE\u8868\u3002",
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/de/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4FvC,CAAC"}
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/de/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgGvC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/en/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0FvC,CAAC"}
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/en/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6FvC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/es/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4FvC,CAAC"}
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/es/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgGvC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/fr/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6FvC,CAAC"}
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/fr/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAiGvC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/zh-CN/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwFvC,CAAC"}
1
+ {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../xlsx/ui/locales/zh-CN/grid.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2FvC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ooxml-core",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Shared OOXML logic for the Word, PowerPoint and Excel viewers: everything except the UI",
5
5
  "keywords": [
6
6
  "charts",