ooxml-core 1.2.1 → 1.4.0
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 +2 -0
- package/dist/{PptxHandler-VQQS4VS6.mjs → PptxHandler-ZPJNHEZZ.mjs} +2 -2
- package/dist/automation/index.cjs +7972 -5580
- package/dist/automation/index.mjs +7972 -5580
- package/dist/{chunk-5U27IVB7.mjs → chunk-BB55ASTX.mjs} +3 -3
- package/dist/{chunk-V2BIGIH4.mjs → chunk-H4TPDZV4.mjs} +1 -1
- package/dist/{chunk-5VLNF4OX.mjs → chunk-IVDC75E5.mjs} +1 -1
- package/dist/{chunk-XBNSBDNT.mjs → chunk-QPQDLSJQ.mjs} +1 -1
- package/dist/{chunk-XSFHGZFH.mjs → chunk-XGLKW3JJ.mjs} +5 -3
- package/dist/pptx/automation/index.cjs +4 -2
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/cli/index.cjs +4 -2
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/index.cjs +4 -2
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +91 -33
- package/dist/teams/index.mjs +91 -33
- package/dist/visio/clipboard-resources.d.ts +11 -0
- package/dist/visio/clipboard-resources.d.ts.map +1 -0
- package/dist/visio/clipboard-types.d.ts +26 -0
- package/dist/visio/clipboard-types.d.ts.map +1 -0
- package/dist/visio/clipboard-xml.d.ts +8 -0
- package/dist/visio/clipboard-xml.d.ts.map +1 -0
- package/dist/visio/clipboard.d.ts +7 -0
- package/dist/visio/clipboard.d.ts.map +1 -0
- package/dist/visio/create-document.d.ts +8 -0
- package/dist/visio/create-document.d.ts.map +1 -0
- package/dist/visio/edit-commands.d.ts +29 -3
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-delete.d.ts +9 -0
- package/dist/visio/edit-delete.d.ts.map +1 -0
- package/dist/visio/edit-duplicate-commands.d.ts +14 -0
- package/dist/visio/edit-duplicate-commands.d.ts.map +1 -0
- package/dist/visio/edit-duplicate-scope.d.ts +4 -0
- package/dist/visio/edit-duplicate-scope.d.ts.map +1 -0
- package/dist/visio/edit-duplicate.d.ts +10 -0
- package/dist/visio/edit-duplicate.d.ts.map +1 -0
- package/dist/visio/edit-formatting-cell-admission.d.ts +3 -0
- package/dist/visio/edit-formatting-cell-admission.d.ts.map +1 -0
- package/dist/visio/edit-formatting-commands.d.ts +46 -0
- package/dist/visio/edit-formatting-commands.d.ts.map +1 -0
- package/dist/visio/edit-formatting-font.d.ts +6 -0
- package/dist/visio/edit-formatting-font.d.ts.map +1 -0
- package/dist/visio/edit-formatting-paint-scope.d.ts +6 -0
- package/dist/visio/edit-formatting-paint-scope.d.ts.map +1 -0
- package/dist/visio/edit-formatting-paint.d.ts +6 -0
- package/dist/visio/edit-formatting-paint.d.ts.map +1 -0
- package/dist/visio/edit-formatting-rows.d.ts +14 -0
- package/dist/visio/edit-formatting-rows.d.ts.map +1 -0
- package/dist/visio/edit-formatting-scope.d.ts +6 -0
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -0
- package/dist/visio/edit-formatting-text.d.ts +8 -0
- package/dist/visio/edit-formatting-text.d.ts.map +1 -0
- package/dist/visio/edit-formatting.d.ts +12 -0
- package/dist/visio/edit-formatting.d.ts.map +1 -0
- package/dist/visio/edit-geometry.d.ts.map +1 -1
- package/dist/visio/edit-page-size.d.ts +5 -0
- package/dist/visio/edit-page-size.d.ts.map +1 -0
- package/dist/visio/edit-pages.d.ts.map +1 -1
- package/dist/visio/edit-paste-commands.d.ts +15 -0
- package/dist/visio/edit-paste-commands.d.ts.map +1 -0
- package/dist/visio/edit-paste.d.ts +5 -0
- package/dist/visio/edit-paste.d.ts.map +1 -0
- package/dist/visio/edit-recalculate.d.ts +3 -1
- package/dist/visio/edit-recalculate.d.ts.map +1 -1
- package/dist/visio/edit-resize-anchor.d.ts +8 -0
- package/dist/visio/edit-resize-anchor.d.ts.map +1 -0
- package/dist/visio/edit-scope.d.ts.map +1 -1
- package/dist/visio/edit-shape-create.d.ts +1 -1
- package/dist/visio/edit-shape-create.d.ts.map +1 -1
- package/dist/visio/edit-shape-order.d.ts +7 -0
- package/dist/visio/edit-shape-order.d.ts.map +1 -0
- package/dist/visio/edit-style-admission.d.ts +17 -0
- package/dist/visio/edit-style-admission.d.ts.map +1 -0
- package/dist/visio/edit-text-range-commands.d.ts +21 -0
- package/dist/visio/edit-text-range-commands.d.ts.map +1 -0
- package/dist/visio/edit-text-range-plan.d.ts +7 -0
- package/dist/visio/edit-text-range-plan.d.ts.map +1 -0
- package/dist/visio/edit-text-ranges.d.ts +4 -0
- package/dist/visio/edit-text-ranges.d.ts.map +1 -0
- package/dist/visio/edit-text-scope.d.ts +7 -0
- package/dist/visio/edit-text-scope.d.ts.map +1 -0
- package/dist/visio/edit-text-target.d.ts +3 -0
- package/dist/visio/edit-text-target.d.ts.map +1 -0
- package/dist/visio/edit-text.d.ts +1 -1
- package/dist/visio/edit-text.d.ts.map +1 -1
- package/dist/visio/edit.d.ts +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +3612 -1076
- package/dist/visio/index.d.ts +3 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +3608 -1078
- package/dist/visio/line-pattern.d.ts +1 -1
- package/dist/visio/line-pattern.d.ts.map +1 -1
- package/dist/visio/line-style.d.ts.map +1 -1
- package/dist/visio/model.d.ts +26 -3
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/parser.d.ts.map +1 -1
- package/dist/visio/plain-text.d.ts +5 -0
- package/dist/visio/plain-text.d.ts.map +1 -0
- package/dist/visio/resize-anchor.d.ts +27 -0
- package/dist/visio/resize-anchor.d.ts.map +1 -0
- package/dist/visio/source-paint.d.ts +5 -0
- package/dist/visio/source-paint.d.ts.map +1 -0
- package/dist/visio/style.d.ts.map +1 -1
- package/dist/visio/theme-root.d.ts.map +1 -1
- package/dist/visio/ui/contract.d.ts +10 -6
- package/dist/visio/ui/contract.d.ts.map +1 -1
- package/dist/visio/ui/draw-plan.d.ts +32 -0
- package/dist/visio/ui/draw-plan.d.ts.map +1 -0
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/formatting.d.ts +28 -0
- package/dist/visio/ui/formatting.d.ts.map +1 -0
- package/dist/visio/ui/index.cjs +1429 -16
- package/dist/visio/ui/index.d.ts +16 -0
- package/dist/visio/ui/index.d.ts.map +1 -1
- package/dist/visio/ui/index.mjs +1380 -17
- package/dist/visio/ui/line-dash.d.ts +4 -0
- package/dist/visio/ui/line-dash.d.ts.map +1 -0
- package/dist/visio/ui/marquee.d.ts +15 -0
- package/dist/visio/ui/marquee.d.ts.map +1 -0
- package/dist/visio/ui/page-edit.d.ts.map +1 -1
- package/dist/visio/ui/page-size.d.ts +31 -0
- package/dist/visio/ui/page-size.d.ts.map +1 -0
- package/dist/visio/ui/scene-validation.d.ts.map +1 -1
- package/dist/visio/ui/selection.d.ts +12 -0
- package/dist/visio/ui/selection.d.ts.map +1 -0
- package/dist/visio/ui/shape-arrange.d.ts +17 -0
- package/dist/visio/ui/shape-arrange.d.ts.map +1 -0
- package/dist/visio/ui/shape-clipboard.d.ts +10 -0
- package/dist/visio/ui/shape-clipboard.d.ts.map +1 -0
- package/dist/visio/ui/shape-duplicate.d.ts +5 -0
- package/dist/visio/ui/shape-duplicate.d.ts.map +1 -0
- package/dist/visio/ui/shape-formatting.d.ts +14 -0
- package/dist/visio/ui/shape-formatting.d.ts.map +1 -0
- package/dist/visio/ui/shape-move.d.ts +14 -0
- package/dist/visio/ui/shape-move.d.ts.map +1 -0
- package/dist/visio/ui/shape-order.d.ts +4 -0
- package/dist/visio/ui/shape-order.d.ts.map +1 -0
- package/dist/visio/ui/shape-resize.d.ts +61 -0
- package/dist/visio/ui/shape-resize.d.ts.map +1 -0
- package/dist/visio/ui/size-position.d.ts +19 -0
- package/dist/visio/ui/size-position.d.ts.map +1 -0
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/visio/ui/svg-stroke.d.ts +8 -0
- package/dist/visio/ui/svg-stroke.d.ts.map +1 -0
- package/dist/visio/ui/text-replace-selection.d.ts +9 -0
- package/dist/visio/ui/text-replace-selection.d.ts.map +1 -0
- package/dist/visio/ui/text-replace-snapshot.d.ts +14 -0
- package/dist/visio/ui/text-replace-snapshot.d.ts.map +1 -0
- package/dist/visio/ui/text-replace-types.d.ts +52 -0
- package/dist/visio/ui/text-replace-types.d.ts.map +1 -0
- package/dist/visio/ui/text-replace.d.ts +17 -0
- package/dist/visio/ui/text-replace.d.ts.map +1 -0
- package/dist/visio/xml-validation.d.ts.map +1 -1
- package/dist/xlsx/collab/codec.d.ts +2 -0
- package/dist/xlsx/collab/codec.d.ts.map +1 -1
- package/dist/xlsx/collab/index.cjs +5 -0
- package/dist/xlsx/collab/index.mjs +5 -0
- package/dist/xlsx/display-text.d.ts +4 -0
- package/dist/xlsx/display-text.d.ts.map +1 -0
- package/dist/xlsx/edit/cell-values.d.ts +4 -3
- package/dist/xlsx/edit/cell-values.d.ts.map +1 -1
- package/dist/xlsx/edit/clipboard.d.ts.map +1 -1
- package/dist/xlsx/edit/context.d.ts +7 -5
- package/dist/xlsx/edit/context.d.ts.map +1 -1
- package/dist/xlsx/edit/deps.d.ts +1 -1
- package/dist/xlsx/edit/deps.d.ts.map +1 -1
- package/dist/xlsx/edit/dimensions.d.ts.map +1 -1
- package/dist/xlsx/edit/fill.d.ts.map +1 -1
- package/dist/xlsx/edit/filter.d.ts.map +1 -1
- package/dist/xlsx/edit/find.d.ts.map +1 -1
- package/dist/xlsx/edit/paste-selection.d.ts.map +1 -1
- package/dist/xlsx/edit/shift-formulas.d.ts +10 -4
- package/dist/xlsx/edit/shift-formulas.d.ts.map +1 -1
- package/dist/xlsx/edit/table-header-names.d.ts +3 -0
- package/dist/xlsx/edit/table-header-names.d.ts.map +1 -0
- package/dist/xlsx/edit/tables.d.ts +1 -2
- package/dist/xlsx/edit/tables.d.ts.map +1 -1
- package/dist/xlsx/filter-rows.d.ts +8 -0
- package/dist/xlsx/filter-rows.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/math-sum.d.ts.map +1 -1
- package/dist/xlsx/formula/lexemes.d.ts.map +1 -1
- package/dist/xlsx/formula/table-refs.d.ts +2 -0
- package/dist/xlsx/formula/table-refs.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +463 -332
- package/dist/xlsx/index.mjs +463 -332
- package/dist/xlsx/load/index.cjs +7628 -7583
- package/dist/xlsx/load/index.mjs +7628 -7583
- package/dist/xlsx/model.d.ts +4 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +461 -332
- package/dist/xlsx/ui/index.mjs +461 -332
- package/dist/xlsx/ui/locales/de/shell.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/en/shell.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/es/shell.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/fr/shell.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/zh-CN/shell.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/xlsx/ui/index.mjs
CHANGED
|
@@ -2200,14 +2200,13 @@ function splitSheets(text2) {
|
|
|
2200
2200
|
if (book !== void 0) out.book = book;
|
|
2201
2201
|
return out;
|
|
2202
2202
|
}
|
|
2203
|
-
var PREFIX_AT = /(\[\d+\])?([A-Za-z0-9_.\u00A1-\uFFFF]+)(?::([A-Za-z0-9_.\u00A1-\uFFFF]+))?!/y;
|
|
2204
2203
|
function readPrefix(source, at) {
|
|
2205
2204
|
const ch = source[at];
|
|
2206
2205
|
if (ch === "'") {
|
|
2207
2206
|
const quoted = readQuoted(source, at);
|
|
2208
2207
|
if (source[at + quoted.length] !== "!") return void 0;
|
|
2209
|
-
const
|
|
2210
|
-
return { prefix: { text: source.slice(at, at +
|
|
2208
|
+
const length2 = quoted.length + 1;
|
|
2209
|
+
return { prefix: { text: source.slice(at, at + length2), ...splitSheets(quoted.name) }, length: length2 };
|
|
2211
2210
|
}
|
|
2212
2211
|
let i2 = at;
|
|
2213
2212
|
if (ch === "[") {
|
|
@@ -2216,13 +2215,23 @@ function readPrefix(source, at) {
|
|
|
2216
2215
|
if (i2 === at + 1 || source[i2] !== "]") return void 0;
|
|
2217
2216
|
i2++;
|
|
2218
2217
|
}
|
|
2218
|
+
const sheetFrom = i2;
|
|
2219
2219
|
while (i2 < source.length && isSheetCharCode(source.charCodeAt(i2))) i2++;
|
|
2220
|
-
if (
|
|
2221
|
-
|
|
2222
|
-
if (
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2220
|
+
if (i2 === sheetFrom) return void 0;
|
|
2221
|
+
let lastFrom = -1;
|
|
2222
|
+
if (source[i2] === ":") {
|
|
2223
|
+
lastFrom = i2 + 1;
|
|
2224
|
+
i2 = lastFrom;
|
|
2225
|
+
while (i2 < source.length && isSheetCharCode(source.charCodeAt(i2))) i2++;
|
|
2226
|
+
if (i2 === lastFrom) return void 0;
|
|
2227
|
+
}
|
|
2228
|
+
if (source[i2] !== "!") return void 0;
|
|
2229
|
+
if (ch !== "[" && lastFrom < 0 && isDigitCode(source.charCodeAt(sheetFrom))) return void 0;
|
|
2230
|
+
const length = i2 + 1 - at;
|
|
2231
|
+
return {
|
|
2232
|
+
prefix: { text: source.slice(at, at + length), ...splitSheets(source.slice(at, i2)) },
|
|
2233
|
+
length
|
|
2234
|
+
};
|
|
2226
2235
|
}
|
|
2227
2236
|
function numberLiteral(text2) {
|
|
2228
2237
|
if (text2.length <= 15) return Number(text2);
|
|
@@ -7738,6 +7747,33 @@ function liftCriteria(ctx, pairs, fn) {
|
|
|
7738
7747
|
});
|
|
7739
7748
|
}
|
|
7740
7749
|
|
|
7750
|
+
// xlsx/display-text.ts
|
|
7751
|
+
function displayText(workbook, cell) {
|
|
7752
|
+
if (!cell || cell.value === null) return "";
|
|
7753
|
+
const value2 = cell.value;
|
|
7754
|
+
if (isCellError(value2)) return value2.error;
|
|
7755
|
+
if (typeof value2 === "boolean") return value2 ? "TRUE" : "FALSE";
|
|
7756
|
+
if (cell.richText && typeof value2 === "string") return value2;
|
|
7757
|
+
return formatValue(value2, styleAt(workbook, cell.styleId).numFmt, {
|
|
7758
|
+
date1904: workbook.date1904
|
|
7759
|
+
}).text;
|
|
7760
|
+
}
|
|
7761
|
+
|
|
7762
|
+
// xlsx/filter-rows.ts
|
|
7763
|
+
function rowMatchesFilter(workbook, sheet, row2, filter2) {
|
|
7764
|
+
return (filter2.columns ?? []).every((column) => {
|
|
7765
|
+
if (!column.values && !column.blank) return true;
|
|
7766
|
+
const text2 = displayText(workbook, getCell(sheet, row2, filter2.range.start.col + column.offset));
|
|
7767
|
+
return text2 === "" ? !!column.blank : (column.values ?? []).includes(text2);
|
|
7768
|
+
});
|
|
7769
|
+
}
|
|
7770
|
+
function isFilteredRow(workbook, sheet, row2) {
|
|
7771
|
+
const info = sheet.rowInfo.get(row2);
|
|
7772
|
+
if (info?.filteredOut !== void 0) return info.filteredOut;
|
|
7773
|
+
const filter2 = sheet.autoFilter;
|
|
7774
|
+
return !!info?.hidden && !!filter2 && row2 > filter2.range.start.row && row2 <= filter2.range.end.row && !rowMatchesFilter(workbook, sheet, row2, filter2);
|
|
7775
|
+
}
|
|
7776
|
+
|
|
7741
7777
|
// xlsx/formula/functions/math-sum.ts
|
|
7742
7778
|
var C18 = "Math & Trig";
|
|
7743
7779
|
var numbersOf = (values2) => values2.filter((v) => typeof v === "number");
|
|
@@ -7775,7 +7811,7 @@ function pairwise(ctx, args, fn) {
|
|
|
7775
7811
|
return total2;
|
|
7776
7812
|
}
|
|
7777
7813
|
var SUBTOTAL_RE = /\b(?:_xlfn\.)?(?:SUBTOTAL|AGGREGATE)\s*\(/i;
|
|
7778
|
-
function subtotalValues(ctx, args, skipHidden, skipErrors, skipNested = true) {
|
|
7814
|
+
function subtotalValues(ctx, args, skipHidden, skipErrors, skipNested = true, skipFiltered = false) {
|
|
7779
7815
|
const out = [];
|
|
7780
7816
|
const host = ctx.frame.host;
|
|
7781
7817
|
for (const arg of args) {
|
|
@@ -7788,6 +7824,7 @@ function subtotalValues(ctx, args, skipHidden, skipErrors, skipNested = true) {
|
|
|
7788
7824
|
for (const area of arg.areas) {
|
|
7789
7825
|
const sheet = ctx.workbook.sheets[area.sheet];
|
|
7790
7826
|
host.forEachStored(area.sheet, area.range, (value2, row2, col) => {
|
|
7827
|
+
if (skipFiltered && sheet && isFilteredRow(ctx.workbook, sheet, row2)) return;
|
|
7791
7828
|
if (skipHidden && sheet?.rowInfo.get(row2)?.hidden) return;
|
|
7792
7829
|
if (skipNested && SUBTOTAL_RE.test(host.cellFormula(area.sheet, row2, col) ?? "")) return;
|
|
7793
7830
|
if (skipErrors && isError(value2)) return;
|
|
@@ -7953,7 +7990,7 @@ var SUM_FUNCTIONS = [
|
|
|
7953
7990
|
const code = int(args[0]);
|
|
7954
7991
|
const base = code > 100 ? code - 100 : code;
|
|
7955
7992
|
if (base < 1 || base > 11) fail(ERR.VALUE);
|
|
7956
|
-
return aggregate(base, subtotalValues(ctx, args.slice(1), code > 100, false));
|
|
7993
|
+
return aggregate(base, subtotalValues(ctx, args.slice(1), code > 100, false, true, true));
|
|
7957
7994
|
},
|
|
7958
7995
|
["value", "any"]
|
|
7959
7996
|
),
|
|
@@ -13451,6 +13488,31 @@ function renameTableInFormula(formula, oldName, newName) {
|
|
|
13451
13488
|
}
|
|
13452
13489
|
return changed ? joinTokens(tokens) : formula;
|
|
13453
13490
|
}
|
|
13491
|
+
function renameTableColumnInFormula(formula, tableName, oldName, newName, insideTable = false) {
|
|
13492
|
+
const tokens = safeTokens2(formula);
|
|
13493
|
+
if (!tokens) return formula;
|
|
13494
|
+
const escaped = newName.replace(/['#@[\]]/g, "'$&");
|
|
13495
|
+
let changed = false;
|
|
13496
|
+
for (const [index2, token] of tokens.entries()) {
|
|
13497
|
+
if (token.kind !== "structured" || token.prefix) continue;
|
|
13498
|
+
if (token.value === "" && tokens[index2 - 1]?.prefix) continue;
|
|
13499
|
+
if (token.value === "" ? !insideTable : String(token.value).toLowerCase() !== tableName.toLowerCase())
|
|
13500
|
+
continue;
|
|
13501
|
+
const next = token.text.replace(
|
|
13502
|
+
/\[(@?)((?:[^\[\]']|'[\s\S])*)\]/g,
|
|
13503
|
+
(original, at, name) => {
|
|
13504
|
+
if (name.startsWith("#") || name.replace(/'(.)/g, "$1").toLowerCase() !== oldName.toLowerCase())
|
|
13505
|
+
return original;
|
|
13506
|
+
return `[${at}${escaped}]`;
|
|
13507
|
+
}
|
|
13508
|
+
);
|
|
13509
|
+
if (next !== token.text) {
|
|
13510
|
+
token.text = next;
|
|
13511
|
+
changed = true;
|
|
13512
|
+
}
|
|
13513
|
+
}
|
|
13514
|
+
return changed ? joinTokens(tokens) : formula;
|
|
13515
|
+
}
|
|
13454
13516
|
|
|
13455
13517
|
// xlsx/formula/structured-to-a1.ts
|
|
13456
13518
|
var abs = (row2, col, rowAbs = true) => `$${columnLabel(col)}${rowAbs ? "$" : ""}${row2 + 1}`;
|
|
@@ -14287,16 +14349,6 @@ function forEachPosition(sheet, range2, visit2) {
|
|
|
14287
14349
|
for (let row2 = r.start.row; row2 <= r.end.row; row2++)
|
|
14288
14350
|
for (let col = r.start.col; col <= r.end.col; col++) visit2(row2, col);
|
|
14289
14351
|
}
|
|
14290
|
-
function displayText(workbook, cell) {
|
|
14291
|
-
if (!cell) return "";
|
|
14292
|
-
const value2 = cell.value;
|
|
14293
|
-
if (value2 === null) return "";
|
|
14294
|
-
if (isCellError(value2)) return value2.error;
|
|
14295
|
-
if (typeof value2 === "boolean") return value2 ? "TRUE" : "FALSE";
|
|
14296
|
-
if (cell.richText && typeof value2 === "string") return value2;
|
|
14297
|
-
const format = styleAt(workbook, cell.styleId).numFmt;
|
|
14298
|
-
return formatValue(value2, format, { date1904: workbook.date1904 }).text;
|
|
14299
|
-
}
|
|
14300
14352
|
function rawText(value2) {
|
|
14301
14353
|
if (value2 === null) return "";
|
|
14302
14354
|
if (isCellError(value2)) return value2.error;
|
|
@@ -14313,19 +14365,266 @@ function pruneCell(sheet, row2, col) {
|
|
|
14313
14365
|
}
|
|
14314
14366
|
}
|
|
14315
14367
|
|
|
14368
|
+
// xlsx/edit/shift-preserved.ts
|
|
14369
|
+
var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
14370
|
+
function descendants2(root, ns, local) {
|
|
14371
|
+
return Array.from(root.getElementsByTagNameNS(ns, local));
|
|
14372
|
+
}
|
|
14373
|
+
function editEntries(sheet, key, edit, quick) {
|
|
14374
|
+
const list = sheet.preserved.get(key);
|
|
14375
|
+
if (!list) return;
|
|
14376
|
+
const next = [];
|
|
14377
|
+
for (const xml of list) {
|
|
14378
|
+
if (!quick(xml)) {
|
|
14379
|
+
next.push(xml);
|
|
14380
|
+
continue;
|
|
14381
|
+
}
|
|
14382
|
+
let doc;
|
|
14383
|
+
try {
|
|
14384
|
+
doc = parseXml(xml);
|
|
14385
|
+
} catch {
|
|
14386
|
+
next.push(xml);
|
|
14387
|
+
continue;
|
|
14388
|
+
}
|
|
14389
|
+
const outcome = edit(doc.documentElement);
|
|
14390
|
+
if (outcome === "same") next.push(xml);
|
|
14391
|
+
else if (outcome === "changed") next.push(buildXml(doc));
|
|
14392
|
+
}
|
|
14393
|
+
if (next.length) sheet.preserved.set(key, next);
|
|
14394
|
+
else sheet.preserved.delete(key);
|
|
14395
|
+
}
|
|
14396
|
+
function shiftBreaks(root, shift2) {
|
|
14397
|
+
let changed = false;
|
|
14398
|
+
for (const brk of elements(root).filter((e) => e.localName === "brk")) {
|
|
14399
|
+
const id = Number(brk.getAttribute("id") ?? "0");
|
|
14400
|
+
const moved = shiftIndex(id, shift2);
|
|
14401
|
+
if (moved === id) continue;
|
|
14402
|
+
changed = true;
|
|
14403
|
+
if (moved === void 0 || moved === 0) root.removeChild(brk);
|
|
14404
|
+
else brk.setAttribute("id", String(moved));
|
|
14405
|
+
}
|
|
14406
|
+
if (!changed) return "same";
|
|
14407
|
+
const left2 = elements(root).filter((e) => e.localName === "brk");
|
|
14408
|
+
if (!left2.length) return "drop";
|
|
14409
|
+
if (root.hasAttribute("count")) root.setAttribute("count", String(left2.length));
|
|
14410
|
+
if (root.hasAttribute("manualBreakCount")) {
|
|
14411
|
+
const manual = left2.filter((b) => /^(1|true)$/.test(b.getAttribute("man") ?? "")).length;
|
|
14412
|
+
root.setAttribute("manualBreakCount", String(manual));
|
|
14413
|
+
}
|
|
14414
|
+
return "changed";
|
|
14415
|
+
}
|
|
14416
|
+
function removeUpwards(node, root) {
|
|
14417
|
+
let current = node;
|
|
14418
|
+
while (current && current !== root) {
|
|
14419
|
+
const parent = current.parentNode;
|
|
14420
|
+
parent?.removeChild(current);
|
|
14421
|
+
if (!parent) break;
|
|
14422
|
+
const emptied = elements(parent).length === 0 || parent.localName === "sparklineGroup" && !elements(parent).some((e) => e.localName === "sparklines");
|
|
14423
|
+
if (!emptied) break;
|
|
14424
|
+
current = parent;
|
|
14425
|
+
}
|
|
14426
|
+
}
|
|
14427
|
+
function shiftSqrefs(root, moveRange) {
|
|
14428
|
+
let changed = false;
|
|
14429
|
+
for (const sqref of descendants2(root, XM3, "sqref")) {
|
|
14430
|
+
const old = sqref.textContent ?? "";
|
|
14431
|
+
const ranges = parseSqref(old).map(moveRange).filter((r) => !!r);
|
|
14432
|
+
const text2 = ranges.map(formatRange).join(" ");
|
|
14433
|
+
if (text2 === old.trim()) continue;
|
|
14434
|
+
changed = true;
|
|
14435
|
+
const owner = sqref.parentNode;
|
|
14436
|
+
if (ranges.length) sqref.textContent = text2;
|
|
14437
|
+
else if (owner) removeUpwards(owner, root);
|
|
14438
|
+
}
|
|
14439
|
+
if (!changed) return "same";
|
|
14440
|
+
for (const list of elements(root).flatMap((ext) => elements(ext)))
|
|
14441
|
+
if (list.localName === "dataValidations" && list.hasAttribute("count"))
|
|
14442
|
+
list.setAttribute("count", String(elements(list).length));
|
|
14443
|
+
return elements(root).length > 0 ? "changed" : "drop";
|
|
14444
|
+
}
|
|
14445
|
+
function shiftPreservedXml(sheet, shift2, moveRange, banded) {
|
|
14446
|
+
if (!banded)
|
|
14447
|
+
editEntries(
|
|
14448
|
+
sheet,
|
|
14449
|
+
shift2.axis === "row" ? "rowBreaks" : "colBreaks",
|
|
14450
|
+
(root) => shiftBreaks(root, shift2),
|
|
14451
|
+
(xml) => xml.includes("brk")
|
|
14452
|
+
);
|
|
14453
|
+
editEntries(
|
|
14454
|
+
sheet,
|
|
14455
|
+
"extLst",
|
|
14456
|
+
(root) => shiftSqrefs(root, moveRange),
|
|
14457
|
+
(xml) => xml.includes("sqref")
|
|
14458
|
+
);
|
|
14459
|
+
}
|
|
14460
|
+
function rewritePreservedFormulas(sheet, rewrite) {
|
|
14461
|
+
editEntries(
|
|
14462
|
+
sheet,
|
|
14463
|
+
"extLst",
|
|
14464
|
+
(root) => {
|
|
14465
|
+
let changed = false;
|
|
14466
|
+
for (const f6 of descendants2(root, XM3, "f")) {
|
|
14467
|
+
const text2 = f6.textContent ?? "";
|
|
14468
|
+
let next = text2;
|
|
14469
|
+
try {
|
|
14470
|
+
next = rewrite(text2, sheet.name);
|
|
14471
|
+
} catch {
|
|
14472
|
+
next = text2;
|
|
14473
|
+
}
|
|
14474
|
+
if (next === text2) continue;
|
|
14475
|
+
f6.textContent = next;
|
|
14476
|
+
changed = true;
|
|
14477
|
+
}
|
|
14478
|
+
return changed ? "changed" : "same";
|
|
14479
|
+
},
|
|
14480
|
+
(xml) => xml.includes(":f>")
|
|
14481
|
+
);
|
|
14482
|
+
}
|
|
14483
|
+
|
|
14484
|
+
// xlsx/edit/conditional-formulas.ts
|
|
14485
|
+
function rewriteConditionalRule(rule, rewrite) {
|
|
14486
|
+
const safe2 = (formula) => {
|
|
14487
|
+
try {
|
|
14488
|
+
return rewrite(formula);
|
|
14489
|
+
} catch {
|
|
14490
|
+
return formula;
|
|
14491
|
+
}
|
|
14492
|
+
};
|
|
14493
|
+
if (rule.type === "cellIs") rule.formulas = rule.formulas.map(safe2);
|
|
14494
|
+
else if (rule.type === "expression") rule.formula = safe2(rule.formula);
|
|
14495
|
+
if (rule.type === "colorScale" || rule.type === "iconSet") {
|
|
14496
|
+
for (const threshold of rule.thresholds)
|
|
14497
|
+
if (threshold.type === "formula" && threshold.value) threshold.value = safe2(threshold.value);
|
|
14498
|
+
}
|
|
14499
|
+
if (rule.type === "dataBar") {
|
|
14500
|
+
for (const threshold of [rule.min, rule.max])
|
|
14501
|
+
if (threshold.type === "formula" && threshold.value) threshold.value = safe2(threshold.value);
|
|
14502
|
+
}
|
|
14503
|
+
if (rule.type === "dataBar") rewriteConditionalExtension(rule, safe2);
|
|
14504
|
+
}
|
|
14505
|
+
|
|
14506
|
+
// xlsx/edit/shift-formulas.ts
|
|
14507
|
+
function safe(rewrite, formula, formulaSheet, at) {
|
|
14508
|
+
try {
|
|
14509
|
+
return rewrite(formula, formulaSheet, at);
|
|
14510
|
+
} catch {
|
|
14511
|
+
return formula;
|
|
14512
|
+
}
|
|
14513
|
+
}
|
|
14514
|
+
function rewriteFormulas(workbook, rewrite, formulaCells) {
|
|
14515
|
+
const bySheet = formulaCells && /* @__PURE__ */ new Map();
|
|
14516
|
+
if (bySheet)
|
|
14517
|
+
for (const cell of formulaCells ?? []) {
|
|
14518
|
+
const positions2 = bySheet.get(cell.sheet);
|
|
14519
|
+
if (positions2) positions2.push(cell);
|
|
14520
|
+
else bySheet.set(cell.sheet, [cell]);
|
|
14521
|
+
}
|
|
14522
|
+
workbook.sheets.forEach(
|
|
14523
|
+
(sheet, index2) => rewriteSheetFormulas(sheet, rewrite, bySheet ? bySheet.get(index2) ?? [] : void 0)
|
|
14524
|
+
);
|
|
14525
|
+
for (const definedName of workbook.definedNames) {
|
|
14526
|
+
const local = definedName.localSheet === void 0 ? void 0 : workbook.sheets[definedName.localSheet];
|
|
14527
|
+
definedName.formula = safe(rewrite, definedName.formula, local?.name ?? "");
|
|
14528
|
+
}
|
|
14529
|
+
}
|
|
14530
|
+
function rewriteSheetFormulas(sheet, rewrite, formulaCells) {
|
|
14531
|
+
rewritePreservedFormulas(sheet, rewrite);
|
|
14532
|
+
{
|
|
14533
|
+
const name = sheet.name;
|
|
14534
|
+
for (const table2 of sheet.tables)
|
|
14535
|
+
for (const [index2, column] of table2.columns.entries())
|
|
14536
|
+
if (column.calculatedColumnFormula !== void 0)
|
|
14537
|
+
column.calculatedColumnFormula = safe(rewrite, column.calculatedColumnFormula, name, {
|
|
14538
|
+
row: table2.range.start.row + (table2.headerRow ? 1 : 0),
|
|
14539
|
+
col: table2.range.start.col + index2
|
|
14540
|
+
});
|
|
14541
|
+
if (formulaCells) {
|
|
14542
|
+
for (const at of formulaCells) {
|
|
14543
|
+
const cell = getCell(sheet, at.row, at.col);
|
|
14544
|
+
if (cell?.formula !== void 0) cell.formula = safe(rewrite, cell.formula, name, at);
|
|
14545
|
+
}
|
|
14546
|
+
} else {
|
|
14547
|
+
sheet.rows.forEach(
|
|
14548
|
+
(cells, row2) => cells.forEach((cell, col) => {
|
|
14549
|
+
if (cell.formula !== void 0)
|
|
14550
|
+
cell.formula = safe(rewrite, cell.formula, name, { row: row2, col });
|
|
14551
|
+
})
|
|
14552
|
+
);
|
|
14553
|
+
}
|
|
14554
|
+
for (const cf of sheet.conditionalFormats)
|
|
14555
|
+
for (const rule of cf.rules)
|
|
14556
|
+
rewriteConditionalRule(rule, (f6) => rewrite(f6, name, cf.ranges[0]?.start));
|
|
14557
|
+
for (const dv of sheet.dataValidations) {
|
|
14558
|
+
if (dv.formula1 !== void 0)
|
|
14559
|
+
dv.formula1 = safe(rewrite, dv.formula1, name, dv.ranges[0]?.start);
|
|
14560
|
+
if (dv.formula2 !== void 0)
|
|
14561
|
+
dv.formula2 = safe(rewrite, dv.formula2, name, dv.ranges[0]?.start);
|
|
14562
|
+
}
|
|
14563
|
+
for (const link of sheet.hyperlinks)
|
|
14564
|
+
if (link.location && /![A-Za-z$]/.test(link.location))
|
|
14565
|
+
link.location = safe(rewrite, link.location, name);
|
|
14566
|
+
for (const drawing of sheet.drawings) {
|
|
14567
|
+
if (drawing.kind !== "chart") continue;
|
|
14568
|
+
for (const series of drawing.series) {
|
|
14569
|
+
if (series.nameRef) series.nameRef = safe(rewrite, series.nameRef, name);
|
|
14570
|
+
if (series.categoriesRef) series.categoriesRef = safe(rewrite, series.categoriesRef, name);
|
|
14571
|
+
if (series.valuesRef) series.valuesRef = safe(rewrite, series.valuesRef, name);
|
|
14572
|
+
}
|
|
14573
|
+
}
|
|
14574
|
+
}
|
|
14575
|
+
}
|
|
14576
|
+
|
|
14577
|
+
// xlsx/edit/table-header-names.ts
|
|
14578
|
+
function uniqueHeaders(texts) {
|
|
14579
|
+
const used = /* @__PURE__ */ new Set();
|
|
14580
|
+
return texts.map((text2, i2) => {
|
|
14581
|
+
let base = text2.trim() || `Column${i2 + 1}`;
|
|
14582
|
+
if (!used.has(base.toLowerCase())) {
|
|
14583
|
+
used.add(base.toLowerCase());
|
|
14584
|
+
return base;
|
|
14585
|
+
}
|
|
14586
|
+
for (let n = 2; ; n++) {
|
|
14587
|
+
const candidate = `${base}${n}`;
|
|
14588
|
+
if (!used.has(candidate.toLowerCase())) {
|
|
14589
|
+
used.add(candidate.toLowerCase());
|
|
14590
|
+
base = candidate;
|
|
14591
|
+
return base;
|
|
14592
|
+
}
|
|
14593
|
+
}
|
|
14594
|
+
});
|
|
14595
|
+
}
|
|
14596
|
+
|
|
14316
14597
|
// xlsx/edit/cell-values.ts
|
|
14317
14598
|
function tableHeaderAt(sheet, row2, col) {
|
|
14318
14599
|
return sheet.tables.find(
|
|
14319
14600
|
(t) => t.headerRow && t.range.start.row === row2 && col >= t.range.start.col && col <= t.range.end.col
|
|
14320
14601
|
);
|
|
14321
14602
|
}
|
|
14322
|
-
function syncTableHeader(ctx, sheet, row2, col) {
|
|
14603
|
+
function syncTableHeader(ctx, sheet, row2, col, formulaCells) {
|
|
14323
14604
|
const table2 = tableHeaderAt(sheet, row2, col);
|
|
14324
14605
|
if (!table2) return;
|
|
14325
14606
|
const column = table2.columns[col - table2.range.start.col];
|
|
14326
14607
|
if (!column) return;
|
|
14327
14608
|
const text2 = displayText(ctx.workbook, getCell(sheet, row2, col)).trim();
|
|
14328
|
-
if (text2
|
|
14609
|
+
if (!text2 || column.name === text2) return;
|
|
14610
|
+
const oldName = column.name;
|
|
14611
|
+
const others = table2.columns.filter((entry) => entry !== column).map((entry) => entry.name);
|
|
14612
|
+
const newName = uniqueHeaders([...others, text2]).at(-1);
|
|
14613
|
+
column.name = newName;
|
|
14614
|
+
if (newName !== text2) writeValue(sheet, row2, col, newName);
|
|
14615
|
+
const index2 = ctx.workbook.sheets.indexOf(sheet);
|
|
14616
|
+
const cells = formulaCells && (formulaCells.some((cell) => cell.sheet === index2 && cell.row === row2 && cell.col === col) ? formulaCells : [...formulaCells, { sheet: index2, row: row2, col }]);
|
|
14617
|
+
rewriteFormulas(
|
|
14618
|
+
ctx.workbook,
|
|
14619
|
+
(formula, formulaSheet, at) => renameTableColumnInFormula(
|
|
14620
|
+
formula,
|
|
14621
|
+
table2.name,
|
|
14622
|
+
oldName,
|
|
14623
|
+
newName,
|
|
14624
|
+
formulaSheet === sheet.name && !!at && rangeContains(table2.range, at)
|
|
14625
|
+
),
|
|
14626
|
+
cells
|
|
14627
|
+
);
|
|
14329
14628
|
}
|
|
14330
14629
|
function writeScopes(sheet, index2, range2, parts = []) {
|
|
14331
14630
|
const r = normalizeRange(range2);
|
|
@@ -14335,9 +14634,9 @@ function writeScopes(sheet, index2, range2, parts = []) {
|
|
|
14335
14634
|
cellRange(t.range.start.row, t.range.start.col, t.range.start.row, t.range.end.col)
|
|
14336
14635
|
)
|
|
14337
14636
|
);
|
|
14338
|
-
|
|
14637
|
+
if (touchesHeader) return [{ kind: "refs" }, { kind: "cells", sheet: index2, ranges: [r] }];
|
|
14339
14638
|
const scopes = [{ kind: "cells", sheet: index2, ranges: [r] }];
|
|
14340
|
-
if (
|
|
14639
|
+
if (parts.length) scopes.push({ kind: "parts", sheet: index2, parts });
|
|
14341
14640
|
return scopes;
|
|
14342
14641
|
}
|
|
14343
14642
|
function writeInput(ctx, sheet, row2, col, text2) {
|
|
@@ -14388,9 +14687,9 @@ function setCellInput(ctx, s, row2, col, text2) {
|
|
|
14388
14687
|
`Typing in ${formatAddress({ row: row2, col })}`,
|
|
14389
14688
|
"cells",
|
|
14390
14689
|
writeScopes(sheet, s, range2),
|
|
14391
|
-
() => {
|
|
14690
|
+
(formulaCells) => {
|
|
14392
14691
|
writeInput(ctx, sheet, row2, col, text2);
|
|
14393
|
-
syncTableHeader(ctx, sheet, row2, col);
|
|
14692
|
+
syncTableHeader(ctx, sheet, row2, col, formulaCells);
|
|
14394
14693
|
},
|
|
14395
14694
|
{ sheet: s, ranges: [range2] }
|
|
14396
14695
|
);
|
|
@@ -14402,9 +14701,9 @@ function setCellValue(ctx, s, row2, col, value2) {
|
|
|
14402
14701
|
`Edit ${formatAddress({ row: row2, col })}`,
|
|
14403
14702
|
"cells",
|
|
14404
14703
|
writeScopes(sheet, s, range2),
|
|
14405
|
-
() => {
|
|
14704
|
+
(formulaCells) => {
|
|
14406
14705
|
writeValue(sheet, row2, col, value2);
|
|
14407
|
-
syncTableHeader(ctx, sheet, row2, col);
|
|
14706
|
+
syncTableHeader(ctx, sheet, row2, col, formulaCells);
|
|
14408
14707
|
},
|
|
14409
14708
|
{ sheet: s, ranges: [range2] }
|
|
14410
14709
|
);
|
|
@@ -14831,7 +15130,7 @@ function fillRange(ctx, s, source, target2, mode = "auto") {
|
|
|
14831
15130
|
ctx.run(
|
|
14832
15131
|
"Fill",
|
|
14833
15132
|
"cells",
|
|
14834
|
-
|
|
15133
|
+
writeScopes(sheet, s, all2),
|
|
14835
15134
|
() => {
|
|
14836
15135
|
const laneCount = vertical2 ? src.end.col - src.start.col + 1 : src.end.row - src.start.row + 1;
|
|
14837
15136
|
const length = vertical2 ? src.end.row - src.start.row + 1 : src.end.col - src.start.col + 1;
|
|
@@ -14854,6 +15153,7 @@ function fillRange(ctx, s, source, target2, mode = "auto") {
|
|
|
14854
15153
|
const step = series?.(k);
|
|
14855
15154
|
const cell = !step || step.kind === "copy" ? copyCell(origin, row2 - srcRow, col - srcCol) : { value: step.value, ...origin.styleId ? { styleId: origin.styleId } : {} };
|
|
14856
15155
|
putCell(sheet, row2, col, cell);
|
|
15156
|
+
syncTableHeader(ctx, sheet, row2, col);
|
|
14857
15157
|
}
|
|
14858
15158
|
}
|
|
14859
15159
|
},
|
|
@@ -14892,28 +15192,6 @@ function removeValidationArea(rules, area) {
|
|
|
14892
15192
|
});
|
|
14893
15193
|
}
|
|
14894
15194
|
|
|
14895
|
-
// xlsx/edit/conditional-formulas.ts
|
|
14896
|
-
function rewriteConditionalRule(rule, rewrite) {
|
|
14897
|
-
const safe2 = (formula) => {
|
|
14898
|
-
try {
|
|
14899
|
-
return rewrite(formula);
|
|
14900
|
-
} catch {
|
|
14901
|
-
return formula;
|
|
14902
|
-
}
|
|
14903
|
-
};
|
|
14904
|
-
if (rule.type === "cellIs") rule.formulas = rule.formulas.map(safe2);
|
|
14905
|
-
else if (rule.type === "expression") rule.formula = safe2(rule.formula);
|
|
14906
|
-
if (rule.type === "colorScale" || rule.type === "iconSet") {
|
|
14907
|
-
for (const threshold of rule.thresholds)
|
|
14908
|
-
if (threshold.type === "formula" && threshold.value) threshold.value = safe2(threshold.value);
|
|
14909
|
-
}
|
|
14910
|
-
if (rule.type === "dataBar") {
|
|
14911
|
-
for (const threshold of [rule.min, rule.max])
|
|
14912
|
-
if (threshold.type === "formula" && threshold.value) threshold.value = safe2(threshold.value);
|
|
14913
|
-
}
|
|
14914
|
-
if (rule.type === "dataBar") rewriteConditionalExtension(rule, safe2);
|
|
14915
|
-
}
|
|
14916
|
-
|
|
14917
15195
|
// xlsx/edit/conditional-formats.ts
|
|
14918
15196
|
function formatAt(sheet, index2) {
|
|
14919
15197
|
const format = sheet.conditionalFormats[index2];
|
|
@@ -15323,168 +15601,6 @@ function setBorders(ctx, s, range2, preset, edge = { style: "thin" }) {
|
|
|
15323
15601
|
);
|
|
15324
15602
|
}
|
|
15325
15603
|
|
|
15326
|
-
// xlsx/edit/shift-preserved.ts
|
|
15327
|
-
var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
15328
|
-
function descendants2(root, ns, local) {
|
|
15329
|
-
return Array.from(root.getElementsByTagNameNS(ns, local));
|
|
15330
|
-
}
|
|
15331
|
-
function editEntries(sheet, key, edit, quick) {
|
|
15332
|
-
const list = sheet.preserved.get(key);
|
|
15333
|
-
if (!list) return;
|
|
15334
|
-
const next = [];
|
|
15335
|
-
for (const xml of list) {
|
|
15336
|
-
if (!quick(xml)) {
|
|
15337
|
-
next.push(xml);
|
|
15338
|
-
continue;
|
|
15339
|
-
}
|
|
15340
|
-
let doc;
|
|
15341
|
-
try {
|
|
15342
|
-
doc = parseXml(xml);
|
|
15343
|
-
} catch {
|
|
15344
|
-
next.push(xml);
|
|
15345
|
-
continue;
|
|
15346
|
-
}
|
|
15347
|
-
const outcome = edit(doc.documentElement);
|
|
15348
|
-
if (outcome === "same") next.push(xml);
|
|
15349
|
-
else if (outcome === "changed") next.push(buildXml(doc));
|
|
15350
|
-
}
|
|
15351
|
-
if (next.length) sheet.preserved.set(key, next);
|
|
15352
|
-
else sheet.preserved.delete(key);
|
|
15353
|
-
}
|
|
15354
|
-
function shiftBreaks(root, shift2) {
|
|
15355
|
-
let changed = false;
|
|
15356
|
-
for (const brk of elements(root).filter((e) => e.localName === "brk")) {
|
|
15357
|
-
const id = Number(brk.getAttribute("id") ?? "0");
|
|
15358
|
-
const moved = shiftIndex(id, shift2);
|
|
15359
|
-
if (moved === id) continue;
|
|
15360
|
-
changed = true;
|
|
15361
|
-
if (moved === void 0 || moved === 0) root.removeChild(brk);
|
|
15362
|
-
else brk.setAttribute("id", String(moved));
|
|
15363
|
-
}
|
|
15364
|
-
if (!changed) return "same";
|
|
15365
|
-
const left2 = elements(root).filter((e) => e.localName === "brk");
|
|
15366
|
-
if (!left2.length) return "drop";
|
|
15367
|
-
if (root.hasAttribute("count")) root.setAttribute("count", String(left2.length));
|
|
15368
|
-
if (root.hasAttribute("manualBreakCount")) {
|
|
15369
|
-
const manual = left2.filter((b) => /^(1|true)$/.test(b.getAttribute("man") ?? "")).length;
|
|
15370
|
-
root.setAttribute("manualBreakCount", String(manual));
|
|
15371
|
-
}
|
|
15372
|
-
return "changed";
|
|
15373
|
-
}
|
|
15374
|
-
function removeUpwards(node, root) {
|
|
15375
|
-
let current = node;
|
|
15376
|
-
while (current && current !== root) {
|
|
15377
|
-
const parent = current.parentNode;
|
|
15378
|
-
parent?.removeChild(current);
|
|
15379
|
-
if (!parent) break;
|
|
15380
|
-
const emptied = elements(parent).length === 0 || parent.localName === "sparklineGroup" && !elements(parent).some((e) => e.localName === "sparklines");
|
|
15381
|
-
if (!emptied) break;
|
|
15382
|
-
current = parent;
|
|
15383
|
-
}
|
|
15384
|
-
}
|
|
15385
|
-
function shiftSqrefs(root, moveRange) {
|
|
15386
|
-
let changed = false;
|
|
15387
|
-
for (const sqref of descendants2(root, XM3, "sqref")) {
|
|
15388
|
-
const old = sqref.textContent ?? "";
|
|
15389
|
-
const ranges = parseSqref(old).map(moveRange).filter((r) => !!r);
|
|
15390
|
-
const text2 = ranges.map(formatRange).join(" ");
|
|
15391
|
-
if (text2 === old.trim()) continue;
|
|
15392
|
-
changed = true;
|
|
15393
|
-
const owner = sqref.parentNode;
|
|
15394
|
-
if (ranges.length) sqref.textContent = text2;
|
|
15395
|
-
else if (owner) removeUpwards(owner, root);
|
|
15396
|
-
}
|
|
15397
|
-
if (!changed) return "same";
|
|
15398
|
-
for (const list of elements(root).flatMap((ext) => elements(ext)))
|
|
15399
|
-
if (list.localName === "dataValidations" && list.hasAttribute("count"))
|
|
15400
|
-
list.setAttribute("count", String(elements(list).length));
|
|
15401
|
-
return elements(root).length > 0 ? "changed" : "drop";
|
|
15402
|
-
}
|
|
15403
|
-
function shiftPreservedXml(sheet, shift2, moveRange, banded) {
|
|
15404
|
-
if (!banded)
|
|
15405
|
-
editEntries(
|
|
15406
|
-
sheet,
|
|
15407
|
-
shift2.axis === "row" ? "rowBreaks" : "colBreaks",
|
|
15408
|
-
(root) => shiftBreaks(root, shift2),
|
|
15409
|
-
(xml) => xml.includes("brk")
|
|
15410
|
-
);
|
|
15411
|
-
editEntries(
|
|
15412
|
-
sheet,
|
|
15413
|
-
"extLst",
|
|
15414
|
-
(root) => shiftSqrefs(root, moveRange),
|
|
15415
|
-
(xml) => xml.includes("sqref")
|
|
15416
|
-
);
|
|
15417
|
-
}
|
|
15418
|
-
function rewritePreservedFormulas(sheet, rewrite) {
|
|
15419
|
-
editEntries(
|
|
15420
|
-
sheet,
|
|
15421
|
-
"extLst",
|
|
15422
|
-
(root) => {
|
|
15423
|
-
let changed = false;
|
|
15424
|
-
for (const f6 of descendants2(root, XM3, "f")) {
|
|
15425
|
-
const text2 = f6.textContent ?? "";
|
|
15426
|
-
let next = text2;
|
|
15427
|
-
try {
|
|
15428
|
-
next = rewrite(text2, sheet.name);
|
|
15429
|
-
} catch {
|
|
15430
|
-
next = text2;
|
|
15431
|
-
}
|
|
15432
|
-
if (next === text2) continue;
|
|
15433
|
-
f6.textContent = next;
|
|
15434
|
-
changed = true;
|
|
15435
|
-
}
|
|
15436
|
-
return changed ? "changed" : "same";
|
|
15437
|
-
},
|
|
15438
|
-
(xml) => xml.includes(":f>")
|
|
15439
|
-
);
|
|
15440
|
-
}
|
|
15441
|
-
|
|
15442
|
-
// xlsx/edit/shift-formulas.ts
|
|
15443
|
-
function safe(rewrite, formula, formulaSheet) {
|
|
15444
|
-
try {
|
|
15445
|
-
return rewrite(formula, formulaSheet);
|
|
15446
|
-
} catch {
|
|
15447
|
-
return formula;
|
|
15448
|
-
}
|
|
15449
|
-
}
|
|
15450
|
-
function rewriteFormulas(workbook, rewrite) {
|
|
15451
|
-
for (const sheet of workbook.sheets) rewriteSheetFormulas(sheet, rewrite);
|
|
15452
|
-
for (const definedName of workbook.definedNames) {
|
|
15453
|
-
const local = definedName.localSheet === void 0 ? void 0 : workbook.sheets[definedName.localSheet];
|
|
15454
|
-
definedName.formula = safe(rewrite, definedName.formula, local?.name ?? "");
|
|
15455
|
-
}
|
|
15456
|
-
}
|
|
15457
|
-
function rewriteSheetFormulas(sheet, rewrite) {
|
|
15458
|
-
rewritePreservedFormulas(sheet, rewrite);
|
|
15459
|
-
{
|
|
15460
|
-
const name = sheet.name;
|
|
15461
|
-
for (const table2 of sheet.tables)
|
|
15462
|
-
for (const column of table2.columns)
|
|
15463
|
-
if (column.calculatedColumnFormula !== void 0)
|
|
15464
|
-
column.calculatedColumnFormula = safe(rewrite, column.calculatedColumnFormula, name);
|
|
15465
|
-
for (const cells of sheet.rows.values())
|
|
15466
|
-
for (const cell of cells.values())
|
|
15467
|
-
if (cell.formula !== void 0) cell.formula = safe(rewrite, cell.formula, name);
|
|
15468
|
-
for (const cf of sheet.conditionalFormats)
|
|
15469
|
-
for (const rule of cf.rules) rewriteConditionalRule(rule, (f6) => rewrite(f6, name));
|
|
15470
|
-
for (const dv of sheet.dataValidations) {
|
|
15471
|
-
if (dv.formula1 !== void 0) dv.formula1 = safe(rewrite, dv.formula1, name);
|
|
15472
|
-
if (dv.formula2 !== void 0) dv.formula2 = safe(rewrite, dv.formula2, name);
|
|
15473
|
-
}
|
|
15474
|
-
for (const link of sheet.hyperlinks)
|
|
15475
|
-
if (link.location && /![A-Za-z$]/.test(link.location))
|
|
15476
|
-
link.location = safe(rewrite, link.location, name);
|
|
15477
|
-
for (const drawing of sheet.drawings) {
|
|
15478
|
-
if (drawing.kind !== "chart") continue;
|
|
15479
|
-
for (const series of drawing.series) {
|
|
15480
|
-
if (series.nameRef) series.nameRef = safe(rewrite, series.nameRef, name);
|
|
15481
|
-
if (series.categoriesRef) series.categoriesRef = safe(rewrite, series.categoriesRef, name);
|
|
15482
|
-
if (series.valuesRef) series.valuesRef = safe(rewrite, series.valuesRef, name);
|
|
15483
|
-
}
|
|
15484
|
-
}
|
|
15485
|
-
}
|
|
15486
|
-
}
|
|
15487
|
-
|
|
15488
15604
|
// xlsx/edit/shift-sheet.ts
|
|
15489
15605
|
function shiftSheetContent(sheet, shift2, band) {
|
|
15490
15606
|
const moveRange = (range2) => band ? shiftRangeInBand(range2, shift2, band.lo, band.hi) : shiftRange(range2, shift2);
|
|
@@ -16474,14 +16590,13 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
16474
16590
|
if (cut && operation !== "none")
|
|
16475
16591
|
throw new RangeError("Paste operations are not available for cut cells.");
|
|
16476
16592
|
const destCells = { kind: "cells", sheet: s, ranges: [dest] };
|
|
16477
|
-
const scopes = cut ? [{ kind: "refs" }, { kind: "cells", sheet: cut.sheet, ranges: [cut.range] }, destCells] : [
|
|
16478
|
-
|
|
16479
|
-
|
|
16480
|
-
|
|
16481
|
-
|
|
16482
|
-
|
|
16483
|
-
|
|
16484
|
-
];
|
|
16593
|
+
const scopes = cut ? [{ kind: "refs" }, { kind: "cells", sheet: cut.sheet, ranges: [cut.range] }, destCells] : writeScopes(sheet, s, dest, [
|
|
16594
|
+
"merges",
|
|
16595
|
+
"comments",
|
|
16596
|
+
"dataValidations",
|
|
16597
|
+
"hyperlinks",
|
|
16598
|
+
"conditionalFormats"
|
|
16599
|
+
]);
|
|
16485
16600
|
const move = cut && {
|
|
16486
16601
|
fromSheet: sheetAt(workbook, cut.sheet).name,
|
|
16487
16602
|
range: cut.range,
|
|
@@ -16554,6 +16669,8 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
16554
16669
|
const origin = cells.source?.range.start;
|
|
16555
16670
|
const formula = clip?.formula === void 0 ? void 0 : move ? moveReferencesInFormula(clip.formula, move.fromSheet, move, move.toSheet) : !origin ? clip.formula : moveFormula(clip.formula, at.row - origin.row, at.col - origin.col);
|
|
16556
16671
|
writeClip(workbook, sheet, row2, col, clip, mode, formula, styleOf, operation);
|
|
16672
|
+
if (mode !== "formats" && mode !== "comments" && mode !== "validation")
|
|
16673
|
+
syncTableHeader(ctx, sheet, row2, col);
|
|
16557
16674
|
}
|
|
16558
16675
|
if (mode === "all" || mode === "mergeFormats" || mode === "noBorders" || mode === "formats") {
|
|
16559
16676
|
sheet.merges = sheet.merges.filter((m) => !rangesIntersect(m, dest));
|
|
@@ -16597,14 +16714,13 @@ function pasteSelection(ctx, sheet, selection, payload, request) {
|
|
|
16597
16714
|
return ctx.run(
|
|
16598
16715
|
"Paste",
|
|
16599
16716
|
"cells",
|
|
16600
|
-
[
|
|
16601
|
-
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
],
|
|
16717
|
+
writeScopes(sheetAt(ctx.workbook, sheet), sheet, dest, [
|
|
16718
|
+
"merges",
|
|
16719
|
+
"comments",
|
|
16720
|
+
"dataValidations",
|
|
16721
|
+
"hyperlinks",
|
|
16722
|
+
"conditionalFormats"
|
|
16723
|
+
]),
|
|
16608
16724
|
() => {
|
|
16609
16725
|
for (let row2 = dest.start.row; row2 <= dest.end.row; row2 += height)
|
|
16610
16726
|
for (let col = dest.start.col; col <= dest.end.col; col += width)
|
|
@@ -16756,6 +16872,15 @@ function setHidden(ctx, s, axis, indices, hidden) {
|
|
|
16756
16872
|
}
|
|
16757
16873
|
for (const row2 of indices) {
|
|
16758
16874
|
const info = { ...sheet.rowInfo.get(row2) };
|
|
16875
|
+
if (info.filteredOut) {
|
|
16876
|
+
if (hidden) info.manuallyHidden = true;
|
|
16877
|
+
else delete info.manuallyHidden;
|
|
16878
|
+
sheet.rowInfo.set(row2, info);
|
|
16879
|
+
continue;
|
|
16880
|
+
}
|
|
16881
|
+
const filter2 = sheet.autoFilter;
|
|
16882
|
+
if (filter2?.columns?.length && row2 > filter2.range.start.row && row2 <= filter2.range.end.row)
|
|
16883
|
+
info.filteredOut = false;
|
|
16759
16884
|
if (hidden) info.hidden = true;
|
|
16760
16885
|
else {
|
|
16761
16886
|
delete info.hidden;
|
|
@@ -16910,14 +17035,21 @@ function currentRegion(sheet, at) {
|
|
|
16910
17035
|
function applyFilter(ctx, sheet, filter2) {
|
|
16911
17036
|
const { range: range2 } = filter2;
|
|
16912
17037
|
for (let row2 = range2.start.row + 1; row2 <= range2.end.row; row2++) {
|
|
16913
|
-
const visible = (
|
|
16914
|
-
if (!fc.values && !fc.blank) return true;
|
|
16915
|
-
const text2 = displayText(ctx.workbook, getCell(sheet, row2, range2.start.col + fc.offset));
|
|
16916
|
-
return text2 === "" ? !!fc.blank : (fc.values ?? []).includes(text2);
|
|
16917
|
-
});
|
|
17038
|
+
const visible = rowMatchesFilter(ctx.workbook, sheet, row2, filter2);
|
|
16918
17039
|
const info = { ...sheet.rowInfo.get(row2) };
|
|
16919
|
-
|
|
16920
|
-
|
|
17040
|
+
const manual = info.manuallyHidden || info.hidden && !info.filteredOut;
|
|
17041
|
+
if (visible) {
|
|
17042
|
+
delete info.filteredOut;
|
|
17043
|
+
delete info.manuallyHidden;
|
|
17044
|
+
if (manual) {
|
|
17045
|
+
info.hidden = true;
|
|
17046
|
+
if (filter2.columns?.length) info.filteredOut = false;
|
|
17047
|
+
} else delete info.hidden;
|
|
17048
|
+
} else {
|
|
17049
|
+
info.hidden = true;
|
|
17050
|
+
info.filteredOut = true;
|
|
17051
|
+
if (manual) info.manuallyHidden = true;
|
|
17052
|
+
}
|
|
16921
17053
|
if (Object.keys(info).length) sheet.rowInfo.set(row2, info);
|
|
16922
17054
|
else sheet.rowInfo.delete(row2);
|
|
16923
17055
|
}
|
|
@@ -17077,16 +17209,16 @@ var isSpilledAt = (workbook, at) => {
|
|
|
17077
17209
|
return !!sheet && isSpilledCell(getCell(sheet, at.row, at.col));
|
|
17078
17210
|
};
|
|
17079
17211
|
var replaceQuery = (query) => query.lookIn === "comments" ? query : { ...query, lookIn: "formulas" };
|
|
17080
|
-
function replaceScopes(query, sheet, matches2) {
|
|
17212
|
+
function replaceScopes(ctx, query, sheet, matches2) {
|
|
17081
17213
|
if (query.lookIn === "comments") return [{ kind: "parts", sheet, parts: ["comments"] }];
|
|
17082
17214
|
const ranges = matches2.map((m) => ({
|
|
17083
17215
|
start: { row: m.row, col: m.col },
|
|
17084
17216
|
end: { row: m.row, col: m.col }
|
|
17085
17217
|
}));
|
|
17086
|
-
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
];
|
|
17218
|
+
const header = ranges.some(
|
|
17219
|
+
(range2) => writeScopes(sheetAt(ctx.workbook, sheet), sheet, range2).some((scope) => scope.kind === "refs")
|
|
17220
|
+
);
|
|
17221
|
+
return [...header ? [{ kind: "refs" }] : [], { kind: "cells", sheet, ranges }];
|
|
17090
17222
|
}
|
|
17091
17223
|
function applyReplace(ctx, query, replacement, matches2) {
|
|
17092
17224
|
let changed = 0;
|
|
@@ -17116,14 +17248,24 @@ function replaceAll(ctx, query, replacement) {
|
|
|
17116
17248
|
const sheets = [...new Set(matches2.map((m) => m.sheet))];
|
|
17117
17249
|
const scopes = sheets.flatMap(
|
|
17118
17250
|
(sheet) => replaceScopes(
|
|
17251
|
+
ctx,
|
|
17119
17252
|
q,
|
|
17120
17253
|
sheet,
|
|
17121
17254
|
matches2.filter((m) => m.sheet === sheet)
|
|
17122
17255
|
)
|
|
17123
17256
|
);
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17257
|
+
const uniqueScopes = scopes.filter(
|
|
17258
|
+
(scope, index2) => scope.kind !== "refs" || scopes.findIndex((entry) => entry.kind === "refs") === index2
|
|
17259
|
+
);
|
|
17260
|
+
return ctx.run(
|
|
17261
|
+
"Replace",
|
|
17262
|
+
"cells",
|
|
17263
|
+
uniqueScopes,
|
|
17264
|
+
() => applyReplace(ctx, q, replacement, matches2),
|
|
17265
|
+
{
|
|
17266
|
+
...sheets.length === 1 && sheets[0] !== void 0 ? { sheet: sheets[0] } : {}
|
|
17267
|
+
}
|
|
17268
|
+
);
|
|
17127
17269
|
}
|
|
17128
17270
|
function replaceOne(ctx, query, replacement, at) {
|
|
17129
17271
|
const q = replaceQuery(query);
|
|
@@ -17136,7 +17278,7 @@ function replaceOne(ctx, query, replacement, at) {
|
|
|
17136
17278
|
ctx.run(
|
|
17137
17279
|
"Replace",
|
|
17138
17280
|
"cells",
|
|
17139
|
-
replaceScopes(q, at.sheet, [match2]),
|
|
17281
|
+
replaceScopes(ctx, q, at.sheet, [match2]),
|
|
17140
17282
|
() => applyReplace(ctx, q, replacement, [match2]),
|
|
17141
17283
|
{ sheet: at.sheet }
|
|
17142
17284
|
);
|
|
@@ -17916,90 +18058,6 @@ function applyTotalsRow(sheet, table2) {
|
|
|
17916
18058
|
});
|
|
17917
18059
|
}
|
|
17918
18060
|
|
|
17919
|
-
// xlsx/edit/tables.ts
|
|
17920
|
-
function nextTableName(workbook) {
|
|
17921
|
-
const taken = new Set(workbook.sheets.flatMap((s) => s.tables.map((t) => t.name.toLowerCase())));
|
|
17922
|
-
const names = new Set(workbook.definedNames.map((n) => n.name.toLowerCase()));
|
|
17923
|
-
for (let n = 1; ; n++) if (!taken.has(`table${n}`) && !names.has(`table${n}`)) return `Table${n}`;
|
|
17924
|
-
}
|
|
17925
|
-
function uniqueHeaders(texts) {
|
|
17926
|
-
const used = /* @__PURE__ */ new Set();
|
|
17927
|
-
return texts.map((text2, i2) => {
|
|
17928
|
-
let base = text2.trim() || `Column${i2 + 1}`;
|
|
17929
|
-
if (!used.has(base.toLowerCase())) {
|
|
17930
|
-
used.add(base.toLowerCase());
|
|
17931
|
-
return base;
|
|
17932
|
-
}
|
|
17933
|
-
for (let n = 2; ; n++) {
|
|
17934
|
-
const candidate = `${base}${n}`;
|
|
17935
|
-
if (!used.has(candidate.toLowerCase())) {
|
|
17936
|
-
used.add(candidate.toLowerCase());
|
|
17937
|
-
base = candidate;
|
|
17938
|
-
return base;
|
|
17939
|
-
}
|
|
17940
|
-
}
|
|
17941
|
-
});
|
|
17942
|
-
}
|
|
17943
|
-
function createTable(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2") {
|
|
17944
|
-
const { workbook } = ctx;
|
|
17945
|
-
const sheet = sheetAt(workbook, s);
|
|
17946
|
-
let r = normalizeRange(range2);
|
|
17947
|
-
if (r.start.row === r.end.row && r.start.col === r.end.col) r = currentRegion(sheet, r.start);
|
|
17948
|
-
if (sheet.tables.some((t) => rangesIntersect(t.range, r)))
|
|
17949
|
-
throw new Error("A table cannot overlap another table.");
|
|
17950
|
-
if (sheet.merges.some((m) => rangesIntersect(m, r)))
|
|
17951
|
-
throw new Error("A table cannot contain merged cells.");
|
|
17952
|
-
return ctx.run(
|
|
17953
|
-
"Create table",
|
|
17954
|
-
"structure",
|
|
17955
|
-
[hasHeader ? { kind: "sheet", sheet: s } : { kind: "workbook" }],
|
|
17956
|
-
() => {
|
|
17957
|
-
if (!hasHeader) {
|
|
17958
|
-
const shift2 = { axis: "row", at: r.start.row, count: 1 };
|
|
17959
|
-
const band = { lo: r.start.col, hi: r.end.col };
|
|
17960
|
-
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
|
|
17961
|
-
shiftSheetContent(sheet, shift2, band);
|
|
17962
|
-
r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
|
|
17963
|
-
}
|
|
17964
|
-
const width = r.end.col - r.start.col + 1;
|
|
17965
|
-
const texts = Array.from(
|
|
17966
|
-
{ length: width },
|
|
17967
|
-
(_v, i2) => hasHeader ? displayText(workbook, getCell(sheet, r.start.row, r.start.col + i2)) : ""
|
|
17968
|
-
);
|
|
17969
|
-
const headers = uniqueHeaders(texts);
|
|
17970
|
-
const columns = headers.map((name2, i2) => {
|
|
17971
|
-
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17972
|
-
if (cell?.value !== name2) {
|
|
17973
|
-
const styleId = cell?.styleId;
|
|
17974
|
-
writeValue(sheet, r.start.row, r.start.col + i2, name2);
|
|
17975
|
-
const written = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17976
|
-
if (written && styleId) written.styleId = styleId;
|
|
17977
|
-
}
|
|
17978
|
-
return { name: name2 };
|
|
17979
|
-
});
|
|
17980
|
-
const name = nextTableName(workbook);
|
|
17981
|
-
const id = Math.max(0, ...workbook.sheets.flatMap((ws) => ws.tables.map((t) => t.id))) + 1;
|
|
17982
|
-
const table2 = {
|
|
17983
|
-
id,
|
|
17984
|
-
name,
|
|
17985
|
-
displayName: name,
|
|
17986
|
-
range: r,
|
|
17987
|
-
headerRow: true,
|
|
17988
|
-
totalsRow: false,
|
|
17989
|
-
columns,
|
|
17990
|
-
styleName,
|
|
17991
|
-
showRowStripes: true,
|
|
17992
|
-
showColumnStripes: false,
|
|
17993
|
-
showFirstColumn: false,
|
|
17994
|
-
showLastColumn: false
|
|
17995
|
-
};
|
|
17996
|
-
sheet.tables.push(table2);
|
|
17997
|
-
return table2;
|
|
17998
|
-
},
|
|
17999
|
-
{ sheet: s, ranges: [r], structural: !hasHeader }
|
|
18000
|
-
);
|
|
18001
|
-
}
|
|
18002
|
-
|
|
18003
18061
|
// xlsx/edit/table-edits.ts
|
|
18004
18062
|
function tableIndex(sheet, ref) {
|
|
18005
18063
|
const index2 = typeof ref === "number" ? ref : sheet.tables.findIndex((t) => t.name.toLowerCase() === ref.toLowerCase());
|
|
@@ -21216,8 +21274,8 @@ function setSheetState(ctx, index2, state) {
|
|
|
21216
21274
|
const { workbook } = ctx;
|
|
21217
21275
|
const sheet = sheetAt(workbook, index2);
|
|
21218
21276
|
if (sheet.state === state) return;
|
|
21277
|
+
assertUnlocked(workbook);
|
|
21219
21278
|
if (state !== "visible") {
|
|
21220
|
-
assertUnlocked(workbook);
|
|
21221
21279
|
if (sheet.state === "visible" && visibleCount(workbook) <= 1)
|
|
21222
21280
|
throw new Error("A workbook must contain at least one visible sheet.");
|
|
21223
21281
|
}
|
|
@@ -21247,6 +21305,72 @@ function setTabColor(ctx, index2, color) {
|
|
|
21247
21305
|
);
|
|
21248
21306
|
}
|
|
21249
21307
|
|
|
21308
|
+
// xlsx/edit/tables.ts
|
|
21309
|
+
function nextTableName(workbook) {
|
|
21310
|
+
const taken = new Set(workbook.sheets.flatMap((s) => s.tables.map((t) => t.name.toLowerCase())));
|
|
21311
|
+
const names = new Set(workbook.definedNames.map((n) => n.name.toLowerCase()));
|
|
21312
|
+
for (let n = 1; ; n++) if (!taken.has(`table${n}`) && !names.has(`table${n}`)) return `Table${n}`;
|
|
21313
|
+
}
|
|
21314
|
+
function createTable(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2") {
|
|
21315
|
+
const { workbook } = ctx;
|
|
21316
|
+
const sheet = sheetAt(workbook, s);
|
|
21317
|
+
let r = normalizeRange(range2);
|
|
21318
|
+
if (r.start.row === r.end.row && r.start.col === r.end.col) r = currentRegion(sheet, r.start);
|
|
21319
|
+
if (sheet.tables.some((t) => rangesIntersect(t.range, r)))
|
|
21320
|
+
throw new Error("A table cannot overlap another table.");
|
|
21321
|
+
if (sheet.merges.some((m) => rangesIntersect(m, r)))
|
|
21322
|
+
throw new Error("A table cannot contain merged cells.");
|
|
21323
|
+
return ctx.run(
|
|
21324
|
+
"Create table",
|
|
21325
|
+
"structure",
|
|
21326
|
+
[hasHeader ? { kind: "sheet", sheet: s } : { kind: "workbook" }],
|
|
21327
|
+
() => {
|
|
21328
|
+
if (!hasHeader) {
|
|
21329
|
+
const shift2 = { axis: "row", at: r.start.row, count: 1 };
|
|
21330
|
+
const band = { lo: r.start.col, hi: r.end.col };
|
|
21331
|
+
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
|
|
21332
|
+
shiftSheetContent(sheet, shift2, band);
|
|
21333
|
+
r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
|
|
21334
|
+
}
|
|
21335
|
+
const width = r.end.col - r.start.col + 1;
|
|
21336
|
+
const texts = Array.from(
|
|
21337
|
+
{ length: width },
|
|
21338
|
+
(_v, i2) => hasHeader ? displayText(workbook, getCell(sheet, r.start.row, r.start.col + i2)) : ""
|
|
21339
|
+
);
|
|
21340
|
+
const headers = uniqueHeaders(texts);
|
|
21341
|
+
const columns = headers.map((name2, i2) => {
|
|
21342
|
+
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
21343
|
+
if (cell?.value !== name2) {
|
|
21344
|
+
const styleId = cell?.styleId;
|
|
21345
|
+
writeValue(sheet, r.start.row, r.start.col + i2, name2);
|
|
21346
|
+
const written = getCell(sheet, r.start.row, r.start.col + i2);
|
|
21347
|
+
if (written && styleId) written.styleId = styleId;
|
|
21348
|
+
}
|
|
21349
|
+
return { name: name2 };
|
|
21350
|
+
});
|
|
21351
|
+
const name = nextTableName(workbook);
|
|
21352
|
+
const id = Math.max(0, ...workbook.sheets.flatMap((ws) => ws.tables.map((t) => t.id))) + 1;
|
|
21353
|
+
const table2 = {
|
|
21354
|
+
id,
|
|
21355
|
+
name,
|
|
21356
|
+
displayName: name,
|
|
21357
|
+
range: r,
|
|
21358
|
+
headerRow: true,
|
|
21359
|
+
totalsRow: false,
|
|
21360
|
+
columns,
|
|
21361
|
+
styleName,
|
|
21362
|
+
showRowStripes: true,
|
|
21363
|
+
showColumnStripes: false,
|
|
21364
|
+
showFirstColumn: false,
|
|
21365
|
+
showLastColumn: false
|
|
21366
|
+
};
|
|
21367
|
+
sheet.tables.push(table2);
|
|
21368
|
+
return table2;
|
|
21369
|
+
},
|
|
21370
|
+
{ sheet: s, ranges: [r], structural: !hasHeader }
|
|
21371
|
+
);
|
|
21372
|
+
}
|
|
21373
|
+
|
|
21250
21374
|
// xlsx/edit/validation-list.ts
|
|
21251
21375
|
function listSource(workbook, sheet, formula, evaluate, at, depth = 0) {
|
|
21252
21376
|
const text2 = formula.replace(/^=/, "").trim();
|
|
@@ -21534,7 +21658,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
21534
21658
|
const befores = scopes.map((scope) => captureScope(workbook, scope));
|
|
21535
21659
|
let result2;
|
|
21536
21660
|
try {
|
|
21537
|
-
result2 = fn();
|
|
21661
|
+
result2 = fn(befores.find((snapshot) => snapshot.kind === "refs")?.data.formulas);
|
|
21538
21662
|
} catch (error) {
|
|
21539
21663
|
for (let i2 = befores.length - 1; i2 >= 0; i2--) {
|
|
21540
21664
|
const snapshot = befores[i2];
|
|
@@ -26980,6 +27104,7 @@ __export(shell_exports, {
|
|
|
26980
27104
|
shell: () => shell
|
|
26981
27105
|
});
|
|
26982
27106
|
var shell = {
|
|
27107
|
+
"Finish or cancel the current cell edit before saving.": "Beenden oder verwerfen Sie die aktuelle Zellbearbeitung vor dem Speichern.",
|
|
26983
27108
|
File: "Datei",
|
|
26984
27109
|
Ribbon: "Men\xFCband",
|
|
26985
27110
|
"Ribbon tabs": "Men\xFCbandregisterkarten",
|
|
@@ -27365,6 +27490,7 @@ __export(shell_exports2, {
|
|
|
27365
27490
|
shell: () => shell2
|
|
27366
27491
|
});
|
|
27367
27492
|
var shell2 = {
|
|
27493
|
+
"Finish or cancel the current cell edit before saving.": "Finish or cancel the current cell edit before saving.",
|
|
27368
27494
|
File: "File",
|
|
27369
27495
|
Ribbon: "Ribbon",
|
|
27370
27496
|
"Ribbon tabs": "Ribbon tabs",
|
|
@@ -27750,6 +27876,7 @@ __export(shell_exports3, {
|
|
|
27750
27876
|
shell: () => shell3
|
|
27751
27877
|
});
|
|
27752
27878
|
var shell3 = {
|
|
27879
|
+
"Finish or cancel the current cell edit before saving.": "Finalice o cancele la edici\xF3n de la celda actual antes de guardar.",
|
|
27753
27880
|
File: "Archivo",
|
|
27754
27881
|
Ribbon: "Cinta de opciones",
|
|
27755
27882
|
"Ribbon tabs": "Pesta\xF1as de la cinta",
|
|
@@ -28135,6 +28262,7 @@ __export(shell_exports4, {
|
|
|
28135
28262
|
shell: () => shell4
|
|
28136
28263
|
});
|
|
28137
28264
|
var shell4 = {
|
|
28265
|
+
"Finish or cancel the current cell edit before saving.": "Terminez ou annulez la modification de la cellule avant de sauvegarder.",
|
|
28138
28266
|
File: "Fichier",
|
|
28139
28267
|
Ribbon: "Ruban",
|
|
28140
28268
|
"Ribbon tabs": "Onglets du ruban",
|
|
@@ -28520,6 +28648,7 @@ __export(shell_exports5, {
|
|
|
28520
28648
|
shell: () => shell5
|
|
28521
28649
|
});
|
|
28522
28650
|
var shell5 = {
|
|
28651
|
+
"Finish or cancel the current cell edit before saving.": "\u8BF7\u5148\u5B8C\u6210\u6216\u53D6\u6D88\u5F53\u524D\u5355\u5143\u683C\u7684\u7F16\u8F91\uFF0C\u518D\u4FDD\u5B58\u3002",
|
|
28523
28652
|
File: "\u6587\u4EF6",
|
|
28524
28653
|
Ribbon: "\u529F\u80FD\u533A",
|
|
28525
28654
|
"Ribbon tabs": "\u529F\u80FD\u533A\u9009\u9879\u5361",
|