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