ooxml-core 1.10.0 → 1.12.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/dist/PptxHandler-DNZHAHUY.cjs +12 -0
- package/dist/PptxHandler-E44KDHMQ.mjs +3 -0
- package/dist/{PptxHandler-ADEFY476.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
- package/dist/automation/index.cjs +3504 -2888
- package/dist/automation/index.mjs +3504 -2888
- package/dist/{chunk-3N6XMMTT.cjs → chunk-2UVH6RHI.cjs} +1138 -996
- package/dist/{chunk-ZOUGMAZG.mjs → chunk-7DSZI7S6.mjs} +1 -1
- package/dist/{chunk-S6DOCMQC.cjs → chunk-7QZGRB3T.cjs} +0 -10
- package/dist/chunk-ANZ4Q6I3.cjs +21 -0
- package/dist/{chunk-5NVJN4E6.mjs → chunk-EC2W2MDY.mjs} +1 -1
- package/dist/chunk-EGTRL3QJ.mjs +19 -0
- package/dist/chunk-GXHKNSZX.mjs +9 -0
- package/dist/{chunk-CCHYFCPD.mjs → chunk-HCXUI5UC.mjs} +296 -103
- package/dist/chunk-HDQXPSHY.cjs +17 -0
- package/dist/chunk-KTYBFGEY.mjs +14 -0
- package/dist/chunk-QOO36KG4.cjs +42 -0
- package/dist/chunk-R2KZXD6U.mjs +39 -0
- package/dist/{chunk-A6P7G3UK.mjs → chunk-U2DF3EGK.mjs} +1 -1
- package/dist/{chunk-R6KSBNKX.mjs → chunk-UAY26XOI.mjs} +1 -9
- package/dist/{chunk-WUE5ZHU3.mjs → chunk-W5ARCUJB.mjs} +3 -3
- package/dist/chunk-XZPZHXV4.cjs +12 -0
- package/dist/{chunk-ZE53K7DH.mjs → chunk-YB5SRNFS.mjs} +244 -102
- package/dist/docx/embedded.cjs +1 -1
- package/dist/docx/embedded.mjs +1 -1
- package/dist/docx/index.cjs +1 -1
- package/dist/docx/index.mjs +1 -1
- package/dist/docx/layout/adapt-table.d.ts.map +1 -1
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +266 -61
- package/dist/docx/layout/index.d.ts +1 -0
- package/dist/docx/layout/index.d.ts.map +1 -1
- package/dist/docx/layout/index.mjs +266 -62
- package/dist/docx/layout/input.d.ts +5 -0
- package/dist/docx/layout/input.d.ts.map +1 -1
- package/dist/docx/layout/layout-session.d.ts +10 -0
- package/dist/docx/layout/layout-session.d.ts.map +1 -0
- package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
- package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
- package/dist/docx/layout/paragraph-cache.d.ts +8 -0
- package/dist/docx/layout/paragraph-cache.d.ts.map +1 -0
- package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-tokens.d.ts +1 -1
- package/dist/docx/layout/paragraph-tokens.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +7 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/table-border-layout.d.ts +1 -1
- package/dist/docx/layout/table-border-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-frames.d.ts.map +1 -1
- package/dist/docx/layout/table-layout.d.ts +1 -1
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-paragraph-keeps.d.ts +14 -0
- package/dist/docx/layout/table-paragraph-keeps.d.ts.map +1 -0
- package/dist/docx/load/index.cjs +1 -1
- package/dist/docx/load/index.mjs +1 -1
- package/dist/docx/ui/index.cjs +83 -6
- package/dist/docx/ui/index.mjs +83 -7
- package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
- package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
- package/dist/docx/ui/word-count.d.ts +3 -0
- package/dist/docx/ui/word-count.d.ts.map +1 -1
- package/dist/geometry/element-transform.d.ts +90 -0
- package/dist/geometry/element-transform.d.ts.map +1 -0
- package/dist/geometry/index.cjs +90 -0
- package/dist/geometry/index.d.ts +1 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +83 -1
- package/dist/index.cjs +90 -0
- package/dist/index.mjs +90 -0
- package/dist/pptx/automation/index.cjs +266 -114
- package/dist/pptx/automation/index.d.ts +5 -4
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{text-operations-BqHmLaLA.d.ts → elements-DD3UGOMd.d.ts} +17 -3262
- package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-DUCGeZh7.d.ts → index-BZrFyNtU.d.ts} +53 -5
- package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-Cuxtr76Y.d.ts → index-DdX02BSm.d.ts} +5 -3
- package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +266 -114
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +17 -16
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +2 -1
- package/dist/pptx/editor/render/font-family-update.cjs +14 -0
- package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
- package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
- package/dist/pptx/editor/render/font-family-update.mjs +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
- package/dist/pptx/editor/render/slide-operations.cjs +9 -8
- package/dist/pptx/editor/render/slide-operations.mjs +3 -2
- package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
- package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
- package/dist/pptx/editor/render/text-content-style.cjs +18 -0
- package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
- package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-content-style.mjs +5 -0
- package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
- package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
- package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
- package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
- package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
- package/dist/pptx/index.cjs +329 -114
- package/dist/pptx/index.d.ts +7 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/teams/index.cjs +112 -16
- package/dist/teams/index.mjs +112 -16
- package/dist/visio/edit-commands.d.ts +3 -3
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-text-field-commands.d.ts +15 -0
- package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
- package/dist/visio/edit-text-field.d.ts +2 -2
- package/dist/visio/edit-text-field.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 +696 -249
- package/dist/visio/index.d.ts +2 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +695 -250
- package/dist/visio/model.d.ts +18 -0
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/paper-sizes.d.ts +5 -0
- package/dist/visio/paper-sizes.d.ts.map +1 -1
- package/dist/visio/parser.d.ts.map +1 -1
- package/dist/visio/print-count.d.ts +20 -0
- package/dist/visio/print-count.d.ts.map +1 -0
- package/dist/visio/print-settings.d.ts +14 -0
- package/dist/visio/print-settings.d.ts.map +1 -0
- package/dist/visio/shapes.d.ts.map +1 -1
- package/dist/visio/style.d.ts +1 -1
- package/dist/visio/style.d.ts.map +1 -1
- package/dist/visio/text-field-display.d.ts +3 -0
- package/dist/visio/text-field-display.d.ts.map +1 -1
- package/dist/visio/text-field-editability.d.ts +6 -0
- package/dist/visio/text-field-editability.d.ts.map +1 -0
- package/dist/visio/text-field-independent.d.ts +4 -0
- package/dist/visio/text-field-independent.d.ts.map +1 -0
- package/dist/visio/text-field-source.d.ts +6 -0
- package/dist/visio/text-field-source.d.ts.map +1 -0
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +588 -215
- package/dist/visio/ui/index.mjs +588 -215
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +773 -514
- package/dist/xlsx/index.mjs +772 -515
- package/dist/xlsx/load/index.cjs +541 -292
- package/dist/xlsx/load/index.mjs +541 -292
- package/dist/xlsx/model-pivots.d.ts +8 -0
- package/dist/xlsx/model-pivots.d.ts.map +1 -1
- package/dist/xlsx/pivot/admission.d.ts.map +1 -1
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
- package/dist/xlsx/pivot/data.d.ts +2 -2
- package/dist/xlsx/pivot/data.d.ts.map +1 -1
- package/dist/xlsx/pivot/index.d.ts +2 -0
- package/dist/xlsx/pivot/index.d.ts.map +1 -1
- package/dist/xlsx/pivot/measures.d.ts +1 -1
- package/dist/xlsx/pivot/measures.d.ts.map +1 -1
- package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
- package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
- package/dist/xlsx/pivot/page-filter.d.ts +11 -0
- package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
- package/dist/xlsx/pivot/read.d.ts.map +1 -1
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
- package/dist/xlsx/pivot/values-axis.d.ts +4 -1
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +95 -12
- package/dist/xlsx/ui/index.mjs +95 -12
- package/dist/xlsx/ui/ribbon/parts.d.ts +1 -0
- package/dist/xlsx/ui/ribbon/parts.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/PptxHandler-5UURGJEV.mjs +0 -2
- package/dist/PptxHandler-U5XB2HUE.cjs +0 -11
- package/dist/pptx/chunks/index-Cuxtr76Y.d.ts.map +0 -1
- package/dist/pptx/chunks/index-DUCGeZh7.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts +0 -2980
- package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BqHmLaLA.d.ts.map +0 -1
package/dist/xlsx/index.mjs
CHANGED
|
@@ -276,7 +276,7 @@ function createWorksheet(name, sheetId) {
|
|
|
276
276
|
function createWorkbook(options = {}) {
|
|
277
277
|
const names = options.sheets?.length ? options.sheets : ["Sheet1"];
|
|
278
278
|
return {
|
|
279
|
-
sheets: names.map((name,
|
|
279
|
+
sheets: names.map((name, index3) => createWorksheet(name, index3 + 1)),
|
|
280
280
|
styles: [defaultCellStyle()],
|
|
281
281
|
namedStyles: [{ name: "Normal", style: defaultCellStyle(), builtinId: 0 }],
|
|
282
282
|
definedNames: [],
|
|
@@ -298,7 +298,7 @@ function validateSheetName(workbook, name, exceptIndex = -1) {
|
|
|
298
298
|
return "A sheet name cannot start or end with an apostrophe.";
|
|
299
299
|
if (name.toLowerCase() === "history") return '"History" is reserved by Excel.';
|
|
300
300
|
const clash = workbook.sheets.findIndex(
|
|
301
|
-
(sheet,
|
|
301
|
+
(sheet, index3) => index3 !== exceptIndex && sheet.name.toLowerCase() === name.toLowerCase()
|
|
302
302
|
);
|
|
303
303
|
return clash >= 0 ? "That name is already taken." : void 0;
|
|
304
304
|
}
|
|
@@ -337,10 +337,10 @@ function internStyle(workbook, style2) {
|
|
|
337
337
|
const known = cache3.get(key);
|
|
338
338
|
if (known !== void 0 && workbook.styles[known] && styleKey(workbook.styles[known]) === key)
|
|
339
339
|
return known;
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
342
|
-
cache3.set(key,
|
|
343
|
-
return
|
|
340
|
+
const index3 = workbook.styles.findIndex((candidate) => styleKey(candidate) === key);
|
|
341
|
+
if (index3 >= 0) {
|
|
342
|
+
cache3.set(key, index3);
|
|
343
|
+
return index3;
|
|
344
344
|
}
|
|
345
345
|
workbook.styles.push(style2);
|
|
346
346
|
cache3.set(key, workbook.styles.length - 1);
|
|
@@ -1746,10 +1746,10 @@ var MONTH_NAMES = [
|
|
|
1746
1746
|
function monthFromName(name) {
|
|
1747
1747
|
const lower2 = name.toLowerCase();
|
|
1748
1748
|
if (lower2.length < 3) return void 0;
|
|
1749
|
-
const
|
|
1749
|
+
const index3 = MONTH_NAMES.findIndex(
|
|
1750
1750
|
(m) => m.startsWith(lower2) || lower2.length > 3 && lower2 === m
|
|
1751
1751
|
);
|
|
1752
|
-
return
|
|
1752
|
+
return index3 < 0 ? void 0 : index3 + 1;
|
|
1753
1753
|
}
|
|
1754
1754
|
function fullYear(text3) {
|
|
1755
1755
|
const y = Number(text3);
|
|
@@ -3004,10 +3004,10 @@ var MONTHS2 = [
|
|
|
3004
3004
|
function monthFromName2(name) {
|
|
3005
3005
|
const lower2 = name.toLowerCase();
|
|
3006
3006
|
if (lower2.length < 3) return void 0;
|
|
3007
|
-
const
|
|
3008
|
-
if (
|
|
3009
|
-
const full = new Date(Date.UTC(2e3,
|
|
3010
|
-
return lower2.length === 3 || full.startsWith(lower2) || lower2 === "sept" ?
|
|
3007
|
+
const index3 = MONTHS2.findIndex((m) => lower2.startsWith(m));
|
|
3008
|
+
if (index3 < 0) return void 0;
|
|
3009
|
+
const full = new Date(Date.UTC(2e3, index3, 1)).toLocaleString("en-US", { month: "long", timeZone: "UTC" }).toLowerCase();
|
|
3010
|
+
return lower2.length === 3 || full.startsWith(lower2) || lower2 === "sept" ? index3 + 1 : void 0;
|
|
3011
3011
|
}
|
|
3012
3012
|
var NUMBER_RE3 = /^(\d+(?:,\d{3,})+|\d*)(\.\d*)?(?:e([+-]?\d+))?$/i;
|
|
3013
3013
|
var TIME_RE2 = /^(\d{1,4})(?::(\d+))?(?::(\d+(?:\.\d*)?))?(?:\s+(am|pm|a|p))?$/i;
|
|
@@ -3775,11 +3775,11 @@ function sort(args, ctx) {
|
|
|
3775
3775
|
if (byCol) m = transpose(m);
|
|
3776
3776
|
const indexes2 = args.length > 1 && args[1] !== null ? ctx.toMatrix(args[1] ?? null).flat().map((v) => Math.trunc(num(v))) : [1];
|
|
3777
3777
|
const orders = args.length > 2 && args[2] !== null ? ctx.toMatrix(args[2] ?? null).flat().map((v) => num(v)) : [1];
|
|
3778
|
-
const keys = indexes2.map((
|
|
3779
|
-
if (
|
|
3778
|
+
const keys = indexes2.map((index3, k) => {
|
|
3779
|
+
if (index3 < 1 || index3 > m.cols) fail(ERR.VALUE);
|
|
3780
3780
|
const order = orders[Math.min(k, orders.length - 1)] ?? 1;
|
|
3781
3781
|
if (order !== 1 && order !== -1) fail(ERR.VALUE);
|
|
3782
|
-
return { values: m.data.map((row2) => row2[
|
|
3782
|
+
return { values: m.data.map((row2) => row2[index3 - 1] ?? null), descending: order === -1 };
|
|
3783
3783
|
});
|
|
3784
3784
|
const sorted2 = new Matrix(sortRows(m.data, keys));
|
|
3785
3785
|
return byCol ? transpose(sorted2) : sorted2;
|
|
@@ -3907,14 +3907,14 @@ var ARRAY_FUNCTIONS = [
|
|
|
3907
3907
|
const cols = optInt(ctx, args, 1, 1);
|
|
3908
3908
|
const min = args.length > 2 && args[2] !== null ? num(ctx.toScalar(args[2] ?? null)) : 0;
|
|
3909
3909
|
const max = args.length > 3 && args[3] !== null ? num(ctx.toScalar(args[3] ?? null)) : 1;
|
|
3910
|
-
const
|
|
3910
|
+
const integer2 = args.length > 4 && args[4] !== null && toBool(ctx.toScalar(args[4] ?? null));
|
|
3911
3911
|
if (rows < 1 || cols < 1) return ERR.CALC;
|
|
3912
3912
|
if (min > max) fail(ERR.VALUE);
|
|
3913
3913
|
const random = () => ctx.frame.host.random();
|
|
3914
3914
|
return Matrix.build(
|
|
3915
3915
|
rows,
|
|
3916
3916
|
cols,
|
|
3917
|
-
() =>
|
|
3917
|
+
() => integer2 ? Math.ceil(min) + Math.floor(random() * (Math.floor(max) - Math.ceil(min) + 1)) : min + random() * (max - min)
|
|
3918
3918
|
);
|
|
3919
3919
|
},
|
|
3920
3920
|
["any"],
|
|
@@ -3969,8 +3969,8 @@ function modes(values2) {
|
|
|
3969
3969
|
function kth(values2, k, largest) {
|
|
3970
3970
|
const n2 = values2.length;
|
|
3971
3971
|
if (n2 === 0 || !(k >= 1) || k > n2) fail(ERR.NUM);
|
|
3972
|
-
const
|
|
3973
|
-
return sorted(values2)[
|
|
3972
|
+
const index3 = Math.floor(largest ? n2 + 1 - k : k) - 1;
|
|
3973
|
+
return sorted(values2)[index3];
|
|
3974
3974
|
}
|
|
3975
3975
|
function extreme(values2, max) {
|
|
3976
3976
|
if (values2.length === 0) return 0;
|
|
@@ -4110,13 +4110,13 @@ function fieldIndex(table2, field) {
|
|
|
4110
4110
|
const value2 = scalar(field);
|
|
4111
4111
|
if (isError(value2)) fail(value2);
|
|
4112
4112
|
if (typeof value2 === "number") {
|
|
4113
|
-
const
|
|
4114
|
-
if (
|
|
4115
|
-
return
|
|
4113
|
+
const index4 = Math.trunc(value2) - 1;
|
|
4114
|
+
if (index4 < 0 || index4 >= table2.headers.length) fail(ERR.VALUE);
|
|
4115
|
+
return index4;
|
|
4116
4116
|
}
|
|
4117
|
-
const
|
|
4118
|
-
if (
|
|
4119
|
-
return
|
|
4117
|
+
const index3 = table2.headers.indexOf(label(value2).toLowerCase());
|
|
4118
|
+
if (index3 < 0) fail(ERR.VALUE);
|
|
4119
|
+
return index3;
|
|
4120
4120
|
}
|
|
4121
4121
|
function recordFilter(table2, criteria) {
|
|
4122
4122
|
const [head, ...rows] = criteria;
|
|
@@ -5402,8 +5402,8 @@ function cumulative(args, principal) {
|
|
|
5402
5402
|
|
|
5403
5403
|
// xlsx/formula/functions/bonds.ts
|
|
5404
5404
|
var C9 = "Financial";
|
|
5405
|
-
var basisOf = (args,
|
|
5406
|
-
const basis = args.length >
|
|
5405
|
+
var basisOf = (args, index3) => {
|
|
5406
|
+
const basis = args.length > index3 && args[index3] !== null ? int(args[index3]) : 0;
|
|
5407
5407
|
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5408
5408
|
return basis;
|
|
5409
5409
|
};
|
|
@@ -5585,9 +5585,9 @@ var AMORLINC = {
|
|
|
5585
5585
|
}
|
|
5586
5586
|
const fraction = purchase === firstPeriod ? 1 : basis === 1 ? (firstPeriod - purchase) / (isLeapYear(serialToYmd(purchase, ctx.date1904).year) ? 366 : 365) : yearFrac(purchase, firstPeriod, basis, ctx);
|
|
5587
5587
|
const first2 = Math.min(cost - salvage, annual * fraction);
|
|
5588
|
-
const
|
|
5589
|
-
if (
|
|
5590
|
-
return Math.max(0, Math.min(annual, cost - salvage - first2 - (
|
|
5588
|
+
const index3 = Math.trunc(period);
|
|
5589
|
+
if (index3 === 0) return first2;
|
|
5590
|
+
return Math.max(0, Math.min(annual, cost - salvage - first2 - (index3 - 1) * annual));
|
|
5591
5591
|
}
|
|
5592
5592
|
),
|
|
5593
5593
|
missingRequiredError: "#N/A"
|
|
@@ -5814,8 +5814,8 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5814
5814
|
|
|
5815
5815
|
// xlsx/formula/functions/securities.ts
|
|
5816
5816
|
var C11 = "Financial";
|
|
5817
|
-
var basisOf2 = (args,
|
|
5818
|
-
const basis = args.length >
|
|
5817
|
+
var basisOf2 = (args, index3) => {
|
|
5818
|
+
const basis = args.length > index3 && args[index3] !== null ? int(args[index3]) : 0;
|
|
5819
5819
|
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5820
5820
|
return basis;
|
|
5821
5821
|
};
|
|
@@ -6181,8 +6181,8 @@ function resolveStructured(ref, frame) {
|
|
|
6181
6181
|
const totalsRow = table2.totalsRow ? range.end.row : -1;
|
|
6182
6182
|
const columnOf = (name) => {
|
|
6183
6183
|
const lower2 = name.toLowerCase();
|
|
6184
|
-
const
|
|
6185
|
-
return
|
|
6184
|
+
const index3 = table2.columns.findIndex((c3) => c3.name.toLowerCase() === lower2);
|
|
6185
|
+
return index3 < 0 ? -1 : range.start.col + index3;
|
|
6186
6186
|
};
|
|
6187
6187
|
let c1 = range.start.col;
|
|
6188
6188
|
let c2 = range.end.col;
|
|
@@ -6427,8 +6427,8 @@ var INFO_FUNCTIONS = [
|
|
|
6427
6427
|
const v = args[0];
|
|
6428
6428
|
if (v === void 0) return ctx.sheet + 1;
|
|
6429
6429
|
if (v instanceof RefValue) return (v.areas[0]?.sheet ?? ctx.sheet) + 1;
|
|
6430
|
-
const
|
|
6431
|
-
return
|
|
6430
|
+
const index3 = sheetIndex(ctx.frame.host, str(v));
|
|
6431
|
+
return index3 < 0 ? ERR.NA : index3 + 1;
|
|
6432
6432
|
},
|
|
6433
6433
|
["any"]
|
|
6434
6434
|
),
|
|
@@ -6986,14 +6986,14 @@ function shape(value2) {
|
|
|
6986
6986
|
if (value2 instanceof Matrix) return { rows: value2.rows, cols: value2.cols };
|
|
6987
6987
|
return { rows: 1, cols: 1 };
|
|
6988
6988
|
}
|
|
6989
|
-
function line(ctx, value2, axis,
|
|
6989
|
+
function line(ctx, value2, axis, index3) {
|
|
6990
6990
|
if (value2 instanceof RefValue) {
|
|
6991
6991
|
const area = value2.areas[0];
|
|
6992
6992
|
if (!area || value2.areas.length !== 1) fail(ERR.VALUE);
|
|
6993
6993
|
const { start, end } = area.range;
|
|
6994
6994
|
const bounds = ctx.frame.host.bounds(area.sheet);
|
|
6995
6995
|
if (axis === "col") {
|
|
6996
|
-
const col = start.col +
|
|
6996
|
+
const col = start.col + index3;
|
|
6997
6997
|
const length2 = Math.max(0, Math.min(end.row, bounds.rows - 1) - start.row + 1);
|
|
6998
6998
|
return {
|
|
6999
6999
|
length: length2,
|
|
@@ -7001,7 +7001,7 @@ function line(ctx, value2, axis, index2) {
|
|
|
7001
7001
|
get: (i2) => ctx.readCell(area.sheet, start.row + i2, col)
|
|
7002
7002
|
};
|
|
7003
7003
|
}
|
|
7004
|
-
const row2 = start.row +
|
|
7004
|
+
const row2 = start.row + index3;
|
|
7005
7005
|
const length = Math.max(0, Math.min(end.col, bounds.cols - 1) - start.col + 1);
|
|
7006
7006
|
return {
|
|
7007
7007
|
length,
|
|
@@ -7010,8 +7010,8 @@ function line(ctx, value2, axis, index2) {
|
|
|
7010
7010
|
};
|
|
7011
7011
|
}
|
|
7012
7012
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
7013
|
-
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2,
|
|
7014
|
-
return { length: m.cols, get: (i2) => m.get(
|
|
7013
|
+
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2, index3) };
|
|
7014
|
+
return { length: m.cols, get: (i2) => m.get(index3, i2) };
|
|
7015
7015
|
}
|
|
7016
7016
|
function vectorOf(ctx, value2) {
|
|
7017
7017
|
const { rows, cols } = shape(value2);
|
|
@@ -7405,24 +7405,24 @@ function cellOf(value2, row2, col) {
|
|
|
7405
7405
|
if (value2 instanceof Matrix) return value2.get(row2, col);
|
|
7406
7406
|
return value2;
|
|
7407
7407
|
}
|
|
7408
|
-
function sliceOf(value2, axis,
|
|
7408
|
+
function sliceOf(value2, axis, index3) {
|
|
7409
7409
|
const { rows } = shape(value2);
|
|
7410
7410
|
if (value2 instanceof RefValue) {
|
|
7411
7411
|
const area = value2.areas[0];
|
|
7412
7412
|
if (!area) fail(ERR.REF);
|
|
7413
7413
|
const { start, end } = area.range;
|
|
7414
7414
|
const range = axis === "row" ? {
|
|
7415
|
-
start: { row: start.row +
|
|
7416
|
-
end: { row: start.row +
|
|
7415
|
+
start: { row: start.row + index3, col: start.col },
|
|
7416
|
+
end: { row: start.row + index3, col: end.col }
|
|
7417
7417
|
} : {
|
|
7418
|
-
start: { row: start.row, col: start.col +
|
|
7419
|
-
end: { row: end.row, col: start.col +
|
|
7418
|
+
start: { row: start.row, col: start.col + index3 },
|
|
7419
|
+
end: { row: end.row, col: start.col + index3 }
|
|
7420
7420
|
};
|
|
7421
7421
|
return new RefValue([{ sheet: area.sheet, range }]);
|
|
7422
7422
|
}
|
|
7423
7423
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
7424
|
-
if (axis === "row") return new Matrix([m.data[
|
|
7425
|
-
return new Matrix(Array.from({ length: rows }, (_, r) => [m.get(r,
|
|
7424
|
+
if (axis === "row") return new Matrix([m.data[index3] ?? []]);
|
|
7425
|
+
return new Matrix(Array.from({ length: rows }, (_, r) => [m.get(r, index3)]));
|
|
7426
7426
|
}
|
|
7427
7427
|
function lookupValue(args) {
|
|
7428
7428
|
const v = scalar(args[0]);
|
|
@@ -7438,15 +7438,15 @@ function lookupArray(value2) {
|
|
|
7438
7438
|
function vhlookup(args, ctx, vertical) {
|
|
7439
7439
|
const lookup2 = blankAsZero(args);
|
|
7440
7440
|
const table2 = lookupArray(args[1] ?? null);
|
|
7441
|
-
const
|
|
7441
|
+
const index3 = int(args[2]);
|
|
7442
7442
|
const approximate2 = args.length < 4 ? true : bool(args[3]);
|
|
7443
7443
|
const { rows, cols } = shape(table2);
|
|
7444
|
-
if (
|
|
7445
|
-
if (
|
|
7444
|
+
if (index3 < 1) fail(ERR.VALUE);
|
|
7445
|
+
if (index3 > (vertical ? cols : rows)) fail(ERR.REF);
|
|
7446
7446
|
const keys = line(ctx, table2, vertical ? "col" : "row", 0);
|
|
7447
7447
|
const at = approximate2 ? findAscending(keys, lookup2) : findExact(keys, lookup2, true);
|
|
7448
7448
|
if (at < 0) fail(ERR.NA);
|
|
7449
|
-
return vertical ? cellOf(table2, at,
|
|
7449
|
+
return vertical ? cellOf(table2, at, index3 - 1) : cellOf(table2, index3 - 1, at);
|
|
7450
7450
|
}
|
|
7451
7451
|
function match(args, ctx) {
|
|
7452
7452
|
const lookup2 = blankAsZero(args);
|
|
@@ -7645,27 +7645,27 @@ function valueKeys(value2, out) {
|
|
|
7645
7645
|
}
|
|
7646
7646
|
}
|
|
7647
7647
|
function positionsOf(block, key) {
|
|
7648
|
-
let
|
|
7649
|
-
if (!
|
|
7648
|
+
let index3 = indexes.get(block);
|
|
7649
|
+
if (!index3) {
|
|
7650
7650
|
const count2 = (uses.get(block) ?? 0) + 1;
|
|
7651
7651
|
uses.set(block, count2);
|
|
7652
7652
|
if (count2 < 2 || block.isPadded) return void 0;
|
|
7653
|
-
|
|
7653
|
+
index3 = /* @__PURE__ */ new Map();
|
|
7654
7654
|
const keys = [];
|
|
7655
7655
|
const cols = block.cols;
|
|
7656
7656
|
for (let r = 0; r < block.rows; r++) {
|
|
7657
7657
|
for (let c2 = 0; c2 < cols; c2++) {
|
|
7658
7658
|
valueKeys(block.get(r, c2), keys);
|
|
7659
7659
|
for (const k of keys) {
|
|
7660
|
-
const list =
|
|
7660
|
+
const list = index3.get(k);
|
|
7661
7661
|
if (list) list.push(r * cols + c2);
|
|
7662
|
-
else
|
|
7662
|
+
else index3.set(k, [r * cols + c2]);
|
|
7663
7663
|
}
|
|
7664
7664
|
}
|
|
7665
7665
|
}
|
|
7666
|
-
indexes.set(block,
|
|
7666
|
+
indexes.set(block, index3);
|
|
7667
7667
|
}
|
|
7668
|
-
return
|
|
7668
|
+
return index3.get(key) ?? [];
|
|
7669
7669
|
}
|
|
7670
7670
|
|
|
7671
7671
|
// xlsx/formula/functions/criteria.ts
|
|
@@ -8882,7 +8882,7 @@ function layout(ctx, args) {
|
|
|
8882
8882
|
}
|
|
8883
8883
|
return { y, x, column };
|
|
8884
8884
|
}
|
|
8885
|
-
var withConst = (args,
|
|
8885
|
+
var withConst = (args, index3) => omitted(args, index3) ? true : bool(args[index3]);
|
|
8886
8886
|
var row = (values2, width) => [
|
|
8887
8887
|
...values2,
|
|
8888
8888
|
...new Array(Math.max(0, width - values2.length)).fill(ERR.NA)
|
|
@@ -11196,7 +11196,7 @@ function compile(pattern, caseMode2, global) {
|
|
|
11196
11196
|
return fail(ERR.VALUE);
|
|
11197
11197
|
}
|
|
11198
11198
|
}
|
|
11199
|
-
var caseMode = (args,
|
|
11199
|
+
var caseMode = (args, index3) => optNum(args, index3, 0);
|
|
11200
11200
|
function encodeUrl(text3) {
|
|
11201
11201
|
return encodeURIComponent(text3).replace(
|
|
11202
11202
|
/[!'()*]/g,
|
|
@@ -11315,9 +11315,9 @@ function textAround(args, ctx, before) {
|
|
|
11315
11315
|
if (instance > 0) found.push({ at: text3.length, length: 0 });
|
|
11316
11316
|
else found.unshift({ at: 0, length: 0 });
|
|
11317
11317
|
}
|
|
11318
|
-
const
|
|
11319
|
-
const hit = found[
|
|
11320
|
-
if (!hit ||
|
|
11318
|
+
const index3 = instance > 0 ? instance - 1 : found.length + instance;
|
|
11319
|
+
const hit = found[index3];
|
|
11320
|
+
if (!hit || index3 < 0) return notFound;
|
|
11321
11321
|
return before ? text3.slice(0, hit.at) : text3.slice(hit.at + hit.length);
|
|
11322
11322
|
}
|
|
11323
11323
|
function splitText(text3, delimiters, insensitive, ignoreEmpty) {
|
|
@@ -11433,10 +11433,10 @@ var FUNCTION_CATALOG = Object.freeze(
|
|
|
11433
11433
|
);
|
|
11434
11434
|
|
|
11435
11435
|
// xlsx/formula/functions/types.ts
|
|
11436
|
-
var paramKind = (spec2,
|
|
11436
|
+
var paramKind = (spec2, index3) => {
|
|
11437
11437
|
const params = spec2.params;
|
|
11438
11438
|
if (!params || params.length === 0) return "value";
|
|
11439
|
-
return params[Math.min(
|
|
11439
|
+
return params[Math.min(index3, params.length - 1)] ?? "value";
|
|
11440
11440
|
};
|
|
11441
11441
|
|
|
11442
11442
|
// xlsx/formula/call.ts
|
|
@@ -12372,16 +12372,16 @@ var EngineHost = class {
|
|
|
12372
12372
|
}
|
|
12373
12373
|
/** Formulas by the area their spill or CSE array covers (spatial lookup for every read). */
|
|
12374
12374
|
footprintsBy() {
|
|
12375
|
-
let
|
|
12376
|
-
if (!
|
|
12377
|
-
|
|
12375
|
+
let index3 = this.footprintIndex;
|
|
12376
|
+
if (!index3) {
|
|
12377
|
+
index3 = new AreaIndex();
|
|
12378
12378
|
for (const node of this.footprints) {
|
|
12379
12379
|
const fp = node.spill ?? node.blockedSpill ?? node.arrayRange;
|
|
12380
|
-
if (fp)
|
|
12380
|
+
if (fp) index3.add({ sheet: node.sheet, range: fp }, node);
|
|
12381
12381
|
}
|
|
12382
|
-
this.footprintIndex =
|
|
12382
|
+
this.footprintIndex = index3;
|
|
12383
12383
|
}
|
|
12384
|
-
return
|
|
12384
|
+
return index3;
|
|
12385
12385
|
}
|
|
12386
12386
|
allNodes() {
|
|
12387
12387
|
const out = [];
|
|
@@ -12398,17 +12398,17 @@ var EngineHost = class {
|
|
|
12398
12398
|
|
|
12399
12399
|
// xlsx/formula/scc.ts
|
|
12400
12400
|
function stronglyConnected(nodes, successors) {
|
|
12401
|
-
const
|
|
12401
|
+
const index3 = /* @__PURE__ */ new Map();
|
|
12402
12402
|
const low = /* @__PURE__ */ new Map();
|
|
12403
12403
|
const onStack = /* @__PURE__ */ new Set();
|
|
12404
12404
|
const stack2 = [];
|
|
12405
12405
|
const out = [];
|
|
12406
12406
|
let counter = 0;
|
|
12407
12407
|
for (const root of nodes) {
|
|
12408
|
-
if (
|
|
12408
|
+
if (index3.has(root)) continue;
|
|
12409
12409
|
const work = [];
|
|
12410
12410
|
const open = (node) => {
|
|
12411
|
-
|
|
12411
|
+
index3.set(node, counter);
|
|
12412
12412
|
low.set(node, counter);
|
|
12413
12413
|
counter++;
|
|
12414
12414
|
stack2.push(node);
|
|
@@ -12420,9 +12420,9 @@ function stronglyConnected(nodes, successors) {
|
|
|
12420
12420
|
const frame = work[work.length - 1];
|
|
12421
12421
|
if (frame.i < frame.succ.length) {
|
|
12422
12422
|
const next = frame.succ[frame.i++];
|
|
12423
|
-
if (!
|
|
12423
|
+
if (!index3.has(next)) open(next);
|
|
12424
12424
|
else if (onStack.has(next)) {
|
|
12425
|
-
low.set(frame.node, Math.min(low.get(frame.node),
|
|
12425
|
+
low.set(frame.node, Math.min(low.get(frame.node), index3.get(next)));
|
|
12426
12426
|
}
|
|
12427
12427
|
continue;
|
|
12428
12428
|
}
|
|
@@ -12433,7 +12433,7 @@ function stronglyConnected(nodes, successors) {
|
|
|
12433
12433
|
parent.node,
|
|
12434
12434
|
Math.min(low.get(parent.node), low.get(frame.node))
|
|
12435
12435
|
);
|
|
12436
|
-
if (low.get(frame.node) ===
|
|
12436
|
+
if (low.get(frame.node) === index3.get(frame.node)) {
|
|
12437
12437
|
const component = [];
|
|
12438
12438
|
let member;
|
|
12439
12439
|
do {
|
|
@@ -13639,9 +13639,9 @@ function renameTableColumnInFormula(formula, tableName, oldName, newName, inside
|
|
|
13639
13639
|
if (!tokens2) return formula;
|
|
13640
13640
|
const escaped = newName.replace(/['#@[\]]/g, "'$&");
|
|
13641
13641
|
let changed = false;
|
|
13642
|
-
for (const [
|
|
13642
|
+
for (const [index3, token] of tokens2.entries()) {
|
|
13643
13643
|
if (token.kind !== "structured" || token.prefix) continue;
|
|
13644
|
-
if (token.value === "" && tokens2[
|
|
13644
|
+
if (token.value === "" && tokens2[index3 - 1]?.prefix) continue;
|
|
13645
13645
|
if (token.value === "" ? !insideTable : String(token.value).toLowerCase() !== tableName.toLowerCase())
|
|
13646
13646
|
continue;
|
|
13647
13647
|
const next = token.text.replace(
|
|
@@ -13665,13 +13665,13 @@ var abs = (row2, col, rowAbs = true) => `$${columnLabel(col)}${rowAbs ? "$" : ""
|
|
|
13665
13665
|
function a1For(ref, t) {
|
|
13666
13666
|
const { table: table2 } = t;
|
|
13667
13667
|
const { start, end } = table2.range;
|
|
13668
|
-
const
|
|
13668
|
+
const index3 = (name) => {
|
|
13669
13669
|
if (name === void 0) return void 0;
|
|
13670
13670
|
const i2 = table2.columns.findIndex((c3) => c3.name.toLowerCase() === name.toLowerCase());
|
|
13671
13671
|
return i2 < 0 ? -1 : start.col + i2;
|
|
13672
13672
|
};
|
|
13673
|
-
const c1 =
|
|
13674
|
-
const c2 =
|
|
13673
|
+
const c1 = index3(ref.column);
|
|
13674
|
+
const c2 = index3(ref.column2) ?? c1;
|
|
13675
13675
|
if (c1 === -1 || c2 === -1) return "#REF!";
|
|
13676
13676
|
const colLo = c1 ?? start.col;
|
|
13677
13677
|
const colHi = c2 ?? end.col;
|
|
@@ -13823,17 +13823,17 @@ function coloredReferences(text3) {
|
|
|
13823
13823
|
const seen = /* @__PURE__ */ new Map();
|
|
13824
13824
|
return referenceSpans(text3.slice(1), "").map((span3) => {
|
|
13825
13825
|
const key = span3.text.replace(/\$/g, "").toUpperCase();
|
|
13826
|
-
let
|
|
13827
|
-
if (
|
|
13828
|
-
|
|
13829
|
-
seen.set(key,
|
|
13826
|
+
let index3 = seen.get(key);
|
|
13827
|
+
if (index3 === void 0) {
|
|
13828
|
+
index3 = seen.size;
|
|
13829
|
+
seen.set(key, index3);
|
|
13830
13830
|
}
|
|
13831
13831
|
return {
|
|
13832
13832
|
start: span3.start + 1,
|
|
13833
13833
|
end: span3.end + 1,
|
|
13834
13834
|
text: span3.text,
|
|
13835
|
-
index:
|
|
13836
|
-
color: REFERENCE_COLORS[
|
|
13835
|
+
index: index3,
|
|
13836
|
+
color: REFERENCE_COLORS[index3 % REFERENCE_COLORS.length] ?? REFERENCE_COLORS[0]
|
|
13837
13837
|
};
|
|
13838
13838
|
});
|
|
13839
13839
|
}
|
|
@@ -14491,7 +14491,7 @@ var PartPatch = class {
|
|
|
14491
14491
|
const { root, children: children2 } = scan3(xml);
|
|
14492
14492
|
const kids2 = elements(rootElement);
|
|
14493
14493
|
if (kids2.length !== children2.length) throw new Error("Property part markup is not supported");
|
|
14494
|
-
kids2.forEach((kid,
|
|
14494
|
+
kids2.forEach((kid, index3) => this.spans.set(kid, children2[index3]));
|
|
14495
14495
|
this.root = root;
|
|
14496
14496
|
for (const attribute2 of Array.from(rootElement.attributes)) {
|
|
14497
14497
|
if (attribute2.name === "xmlns") this.defaultNs = attribute2.value;
|
|
@@ -14741,7 +14741,7 @@ function writeAppProperties(props, sourceXml) {
|
|
|
14741
14741
|
const patch3 = new PartPatch(xml, root);
|
|
14742
14742
|
const prior = readKnown(root, ns);
|
|
14743
14743
|
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
14744
|
-
FIELDS2.forEach(([field, local, kind],
|
|
14744
|
+
FIELDS2.forEach(([field, local, kind], index3) => {
|
|
14745
14745
|
const value2 = props[field];
|
|
14746
14746
|
const existing = first(root, local, ns.app);
|
|
14747
14747
|
if (value2 === void 0 || kind === "text" && value2 === "") {
|
|
@@ -14755,7 +14755,7 @@ function writeAppProperties(props, sourceXml) {
|
|
|
14755
14755
|
patch3.setContent(existing, body);
|
|
14756
14756
|
return;
|
|
14757
14757
|
}
|
|
14758
|
-
const next = FIELDS2.slice(
|
|
14758
|
+
const next = FIELDS2.slice(index3 + 1).map(([, name]) => first(root, name, ns.app)).find((node) => node !== void 0);
|
|
14759
14759
|
patch3.insert(`<${ownPrefix}${local}>${body}</${ownPrefix}${local}>`, next);
|
|
14760
14760
|
});
|
|
14761
14761
|
return patch3.toString();
|
|
@@ -14850,9 +14850,9 @@ function writeCustomProperties(properties2) {
|
|
|
14850
14850
|
});
|
|
14851
14851
|
if (!unique2.length) return void 0;
|
|
14852
14852
|
const pids = allocateCustomPropertyIds(unique2);
|
|
14853
|
-
const body = unique2.map((property,
|
|
14853
|
+
const body = unique2.map((property, index3) => {
|
|
14854
14854
|
const link = property.linkTarget ? ` linkTarget="${escape(property.linkTarget, true)}"` : "";
|
|
14855
|
-
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[
|
|
14855
|
+
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[index3] ?? index3 + 2}" name="${escape(property.name, true)}"${link}>${variantXml(property)}</property>`;
|
|
14856
14856
|
}).join("");
|
|
14857
14857
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
14858
14858
|
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
@@ -14947,9 +14947,9 @@ function sparklineDataRange(workbook, sheet, source2) {
|
|
|
14947
14947
|
}
|
|
14948
14948
|
if (ast.type !== "ref" || !ast.ref || !["cell", "area"].includes(ast.ref.kind) || ast.prefix?.book || ast.prefix?.sheet2 || ast.spill)
|
|
14949
14949
|
throw new Error("The reference is not valid.");
|
|
14950
|
-
const
|
|
14951
|
-
if (!workbook.sheets[
|
|
14952
|
-
return { sheet:
|
|
14950
|
+
const index3 = ast.prefix ? workbook.sheets.findIndex((ws) => ws.name.toLowerCase() === ast.prefix.sheet.toLowerCase()) : sheet;
|
|
14951
|
+
if (!workbook.sheets[index3]) throw new Error("The reference is not valid.");
|
|
14952
|
+
return { sheet: index3, range: checkedSparklineRange({ start: ast.ref.start, end: ast.ref.end }) };
|
|
14953
14953
|
}
|
|
14954
14954
|
function newSparklines(workbook, sheet, source2, locations) {
|
|
14955
14955
|
const data = sparklineDataRange(workbook, sheet, source2);
|
|
@@ -14976,6 +14976,99 @@ function newSparklines(workbook, sheet, source2, locations) {
|
|
|
14976
14976
|
return out;
|
|
14977
14977
|
}
|
|
14978
14978
|
|
|
14979
|
+
// xlsx/pivot/page-filter.ts
|
|
14980
|
+
function validatePivotPageFilter(pivot) {
|
|
14981
|
+
const filter2 = pivot.pageFilter;
|
|
14982
|
+
const extras = Array.isArray(pivot.additionalValues) ? pivot.additionalValues : [];
|
|
14983
|
+
if (filter2 === void 0) return;
|
|
14984
|
+
if (!filter2 || typeof filter2 !== "object" || Array.isArray(filter2) || Object.keys(filter2).some((key) => key !== "field" && key !== "item") || typeof filter2.field !== "string" || !pivot.fields.includes(filter2.field) || [
|
|
14985
|
+
pivot.rowField,
|
|
14986
|
+
pivot.secondRowField,
|
|
14987
|
+
pivot.columnField,
|
|
14988
|
+
pivot.valueField,
|
|
14989
|
+
...extras.map((v) => v?.field)
|
|
14990
|
+
].includes(filter2.field) || pivot.valuesAxis === "rows")
|
|
14991
|
+
throw new Error("Report filters require Values on columns and a separate source field.");
|
|
14992
|
+
if (filter2.item !== void 0 && !(filter2.item === null || typeof filter2.item === "string" || typeof filter2.item === "boolean" || typeof filter2.item === "number" && Number.isFinite(filter2.item) || isCellError(filter2.item) && isErrorCode(filter2.item.error) && Object.keys(filter2.item).length === 1))
|
|
14993
|
+
throw new Error("Choose a cached literal report filter item.");
|
|
14994
|
+
}
|
|
14995
|
+
function pivotPageProjection(pivot) {
|
|
14996
|
+
const filter2 = pivot.pageFilter;
|
|
14997
|
+
if (!filter2) return pivot;
|
|
14998
|
+
const labels = /* @__PURE__ */ new Map();
|
|
14999
|
+
for (const item of pivotItems(pivot, filter2.field)) {
|
|
15000
|
+
const label3 = String(pivotItemLabel(item)).toLowerCase(), key2 = pivotValueKey(item);
|
|
15001
|
+
if (label3 === "(all)" || labels.has(label3) && labels.get(label3) !== key2)
|
|
15002
|
+
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
15003
|
+
labels.set(label3, key2);
|
|
15004
|
+
}
|
|
15005
|
+
if (filter2.item === void 0) return pivot;
|
|
15006
|
+
const index3 = pivot.fields.indexOf(filter2.field), key = pivotValueKey(filter2.item);
|
|
15007
|
+
const records = pivot.records.filter((record) => pivotValueKey(record[index3] ?? null) === key);
|
|
15008
|
+
if (!records.length) throw new Error("The report filter item is missing from the source.");
|
|
15009
|
+
if (JSON.stringify(records[0][index3] ?? null) !== JSON.stringify(filter2.item))
|
|
15010
|
+
throw new Error("Choose an exact cached literal report filter item.");
|
|
15011
|
+
return { ...pivot, records };
|
|
15012
|
+
}
|
|
15013
|
+
function prependPivotPage(grid, pivot) {
|
|
15014
|
+
if (!pivot.pageFilter) return grid;
|
|
15015
|
+
const width = grid.values[0].length;
|
|
15016
|
+
return {
|
|
15017
|
+
...grid,
|
|
15018
|
+
values: [
|
|
15019
|
+
[
|
|
15020
|
+
pivot.pageFilter.field,
|
|
15021
|
+
pivot.pageFilter.item === void 0 ? "(All)" : pivotItemLabel(pivot.pageFilter.item),
|
|
15022
|
+
...Array(width - 2).fill(null)
|
|
15023
|
+
],
|
|
15024
|
+
Array(width).fill(null),
|
|
15025
|
+
...grid.values
|
|
15026
|
+
],
|
|
15027
|
+
firstDataRow: grid.firstDataRow + 2,
|
|
15028
|
+
...grid.firstHeaderRow !== void 0 ? { firstHeaderRow: grid.firstHeaderRow + 2 } : {},
|
|
15029
|
+
...grid.indents ? { indents: [0, 0, ...grid.indents] } : {}
|
|
15030
|
+
};
|
|
15031
|
+
}
|
|
15032
|
+
var index2 = (raw2) => raw2 !== null && /^\d+$/.test(raw2.trim()) && Number.isSafeInteger(Number(raw2)) ? Number(raw2) : NaN;
|
|
15033
|
+
function readPivotPageFilter(root, fields, shared) {
|
|
15034
|
+
const list = first(root, "pageFields", NS.x), location = first(root, "location", NS.x);
|
|
15035
|
+
const definitions = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
15036
|
+
if (!list) {
|
|
15037
|
+
if (definitions.some((n2) => n2.getAttribute("axis") === "axisPage") || location?.hasAttribute("rowPageCount") || location?.hasAttribute("colPageCount"))
|
|
15038
|
+
throw new Error("Unmodeled report filter metadata");
|
|
15039
|
+
return;
|
|
15040
|
+
}
|
|
15041
|
+
if (root.getAttribute("multipleFieldFilters") === "1")
|
|
15042
|
+
throw new Error("Multiple report filters are preserved");
|
|
15043
|
+
const pages = children(list, "pageField", NS.x);
|
|
15044
|
+
if (pages.length !== 1 || list.getAttribute("count") !== "1" || location?.getAttribute("rowPageCount") !== "1" || location.getAttribute("colPageCount") !== "1")
|
|
15045
|
+
throw new Error("Only one report filter is modeled");
|
|
15046
|
+
const page = pages[0], field = index2(page.getAttribute("fld"));
|
|
15047
|
+
if (page.getAttribute("hier") !== "-1" || !fields[field] || definitions[field]?.getAttribute("axis") !== "axisPage" || definitions.filter((n2) => n2.getAttribute("axis") === "axisPage").length !== 1)
|
|
15048
|
+
throw new Error("Unsupported report field");
|
|
15049
|
+
const container = first(definitions[field], "items", NS.x);
|
|
15050
|
+
const items = children(container, "item", NS.x);
|
|
15051
|
+
if (!container || index2(container.getAttribute("count")) !== items.length || items.filter((n2) => n2.getAttribute("t") === "default").length !== 1 || items.at(-1)?.getAttribute("t") !== "default" || items.at(-1)?.hasAttribute("x"))
|
|
15052
|
+
throw new Error("Unsupported report field items");
|
|
15053
|
+
const data = items.slice(0, -1).map((item2) => {
|
|
15054
|
+
const i2 = index2(item2.getAttribute("x"));
|
|
15055
|
+
if (item2.hasAttribute("t") || !Number.isInteger(i2) || i2 >= shared[field].length)
|
|
15056
|
+
throw new Error("Invalid report cache item");
|
|
15057
|
+
return i2;
|
|
15058
|
+
});
|
|
15059
|
+
if (new Set(data).size !== data.length || data.length !== shared[field].length)
|
|
15060
|
+
throw new Error("Incomplete report cache items");
|
|
15061
|
+
const item = page.getAttribute("item");
|
|
15062
|
+
if (item === null) return { field: fields[field] };
|
|
15063
|
+
const selected2 = index2(item);
|
|
15064
|
+
if (!Number.isInteger(selected2) || selected2 >= data.length)
|
|
15065
|
+
throw new Error("Invalid report item selection");
|
|
15066
|
+
return { field: fields[field], item: shared[field][data[selected2]] };
|
|
15067
|
+
}
|
|
15068
|
+
function pivotPageItems(pivot, field) {
|
|
15069
|
+
return pivotItems(pivot, field);
|
|
15070
|
+
}
|
|
15071
|
+
|
|
14979
15072
|
// xlsx/pivot/data.ts
|
|
14980
15073
|
var PIVOT_AGGREGATES = ["sum", "count", "average", "min", "max"];
|
|
14981
15074
|
function pivotSourceData(workbook, sheet, source2) {
|
|
@@ -15006,10 +15099,10 @@ function pivotValueKey(value2) {
|
|
|
15006
15099
|
return value2 === null || value2 === "" ? "blank" : isCellError(value2) ? `error:${value2.error}` : `${typeof value2}:${String(value2).toLowerCase()}`;
|
|
15007
15100
|
}
|
|
15008
15101
|
function pivotItems(pivot, field) {
|
|
15009
|
-
const
|
|
15102
|
+
const index3 = pivot.fields.indexOf(field);
|
|
15010
15103
|
const items = /* @__PURE__ */ new Map();
|
|
15011
15104
|
for (const record of pivot.records) {
|
|
15012
|
-
const value2 = record[
|
|
15105
|
+
const value2 = record[index3] ?? null;
|
|
15013
15106
|
const key = pivotValueKey(value2);
|
|
15014
15107
|
if (!items.has(key)) items.set(key, value2);
|
|
15015
15108
|
}
|
|
@@ -15027,6 +15120,7 @@ function pivotItemLabel(value2) {
|
|
|
15027
15120
|
return isCellError(value2) ? value2.error : value2;
|
|
15028
15121
|
}
|
|
15029
15122
|
function validatePivotFields(pivot) {
|
|
15123
|
+
validatePivotPageFilter(pivot);
|
|
15030
15124
|
const used = [
|
|
15031
15125
|
pivot.rowField,
|
|
15032
15126
|
...pivot.secondRowField ? [pivot.secondRowField] : [],
|
|
@@ -15099,11 +15193,11 @@ function pivotHeaderDimensions(pivot, columnItems, rowLabels) {
|
|
|
15099
15193
|
const measures = 1 + (pivot.additionalValues?.length ?? 0);
|
|
15100
15194
|
if (pivot.valuesAxis === "rows")
|
|
15101
15195
|
return {
|
|
15102
|
-
rows: pivot.columnField ? 2 : 1,
|
|
15196
|
+
rows: (pivot.columnField ? 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
15103
15197
|
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
15104
15198
|
};
|
|
15105
15199
|
return {
|
|
15106
|
-
rows: pivot.columnField ? measures > 1 ? 3 : 2 : 1,
|
|
15200
|
+
rows: (pivot.columnField ? measures > 1 ? 3 : 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
15107
15201
|
width: rowLabels + (pivot.columnField ? measures === 1 ? Math.max(1, columnItems) + 1 : (columnItems + 1) * measures : measures)
|
|
15108
15202
|
};
|
|
15109
15203
|
}
|
|
@@ -15247,7 +15341,7 @@ function hierarchicalPivotGrid(pivot) {
|
|
|
15247
15341
|
const groups = /* @__PURE__ */ new Map();
|
|
15248
15342
|
const details = /* @__PURE__ */ new Map();
|
|
15249
15343
|
const children2 = /* @__PURE__ */ new Map();
|
|
15250
|
-
const innerIndices = new Map(secondRowItems.map((item,
|
|
15344
|
+
const innerIndices = new Map(secondRowItems.map((item, index3) => [pivotValueKey(item), index3]));
|
|
15251
15345
|
const buckets = /* @__PURE__ */ new Map();
|
|
15252
15346
|
const collect2 = (map, key, record) => {
|
|
15253
15347
|
const list = map.get(key);
|
|
@@ -15439,6 +15533,9 @@ function hierarchicalPivotGrid(pivot) {
|
|
|
15439
15533
|
// xlsx/pivot/aggregate.ts
|
|
15440
15534
|
function pivotGrid(pivot) {
|
|
15441
15535
|
validatePivotFields(pivot);
|
|
15536
|
+
return prependPivotPage(pivotDataGrid(pivotPageProjection(pivot)), pivot);
|
|
15537
|
+
}
|
|
15538
|
+
function pivotDataGrid(pivot) {
|
|
15442
15539
|
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
15443
15540
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
15444
15541
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
@@ -15480,7 +15577,7 @@ function pivotGrid(pivot) {
|
|
|
15480
15577
|
const measures = pivotMeasures(pivot);
|
|
15481
15578
|
const rowEntries = [];
|
|
15482
15579
|
const indents = values2.map(() => 0);
|
|
15483
|
-
const append = (caption, bands,
|
|
15580
|
+
const append = (caption, bands, index3, grand = false) => {
|
|
15484
15581
|
measures.forEach((measure, m) => {
|
|
15485
15582
|
values2.push([
|
|
15486
15583
|
...compact3 ? [grand ? `Total ${measure.caption}` : measure.caption] : [
|
|
@@ -15491,17 +15588,17 @@ function pivotGrid(pivot) {
|
|
|
15491
15588
|
]);
|
|
15492
15589
|
indents.push(compact3 && !grand ? 1 : 0);
|
|
15493
15590
|
rowEntries.push({
|
|
15494
|
-
indices: grand ? [0] : [
|
|
15591
|
+
indices: grand ? [0] : [index3, m],
|
|
15495
15592
|
measure: m,
|
|
15496
15593
|
...grand ? { type: "grand" } : {}
|
|
15497
15594
|
});
|
|
15498
15595
|
});
|
|
15499
15596
|
};
|
|
15500
|
-
rowItems.forEach((item,
|
|
15597
|
+
rowItems.forEach((item, index3) => {
|
|
15501
15598
|
const key = pivotValueKey(item);
|
|
15502
15599
|
if (headings) {
|
|
15503
15600
|
values2.push([label3(item), ...Array(dimensions.width - 1).fill(null)]);
|
|
15504
|
-
rowEntries.push({ indices: [
|
|
15601
|
+
rowEntries.push({ indices: [index3] });
|
|
15505
15602
|
indents.push(0);
|
|
15506
15603
|
}
|
|
15507
15604
|
append(
|
|
@@ -15512,7 +15609,7 @@ function pivotGrid(pivot) {
|
|
|
15512
15609
|
),
|
|
15513
15610
|
pivotNumbers(pivot, groups.get(key) ?? [])
|
|
15514
15611
|
],
|
|
15515
|
-
|
|
15612
|
+
index3
|
|
15516
15613
|
);
|
|
15517
15614
|
});
|
|
15518
15615
|
append(
|
|
@@ -15564,7 +15661,9 @@ var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
|
15564
15661
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
15565
15662
|
var TABLE = {
|
|
15566
15663
|
pivotTableDefinition: "name cacheId dataCaption dataOnRows dataPosition updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
|
|
15567
|
-
location: "ref firstHeaderRow firstDataRow firstDataCol",
|
|
15664
|
+
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
15665
|
+
pageFields: "count",
|
|
15666
|
+
pageField: "fld item hier",
|
|
15568
15667
|
pivotFields: "count",
|
|
15569
15668
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal",
|
|
15570
15669
|
items: "count",
|
|
@@ -15699,6 +15798,18 @@ function inlineFragment(xml) {
|
|
|
15699
15798
|
}
|
|
15700
15799
|
|
|
15701
15800
|
// xlsx/pivot/values-axis.ts
|
|
15801
|
+
function remapPivotRowEntries(entries, axes3) {
|
|
15802
|
+
return entries.map(
|
|
15803
|
+
(entry3) => entry3.type === "grand" ? entry3 : {
|
|
15804
|
+
...entry3,
|
|
15805
|
+
indices: entry3.indices.map((item, axis) => {
|
|
15806
|
+
const index3 = axes3[axis]?.[item];
|
|
15807
|
+
if (index3 === void 0) throw new Error("Invalid report row axis item");
|
|
15808
|
+
return index3;
|
|
15809
|
+
})
|
|
15810
|
+
}
|
|
15811
|
+
);
|
|
15812
|
+
}
|
|
15702
15813
|
function pivotFieldIndex(field) {
|
|
15703
15814
|
const raw2 = field?.getAttribute("x");
|
|
15704
15815
|
if (raw2 === null || raw2 === void 0 || !/^-?\d+$/.test(raw2.trim())) return NaN;
|
|
@@ -15706,15 +15817,15 @@ function pivotFieldIndex(field) {
|
|
|
15706
15817
|
return Number.isSafeInteger(value2) ? value2 : NaN;
|
|
15707
15818
|
}
|
|
15708
15819
|
function pivotValueIndex(root, axis) {
|
|
15709
|
-
const
|
|
15820
|
+
const index3 = axis.findIndex((field) => pivotFieldIndex(field) === -2);
|
|
15710
15821
|
const position = root.getAttribute("dataPosition");
|
|
15711
|
-
if (position !== null && (!/^\d+$/.test(position.trim()) || Number(position) !==
|
|
15822
|
+
if (position !== null && (!/^\d+$/.test(position.trim()) || Number(position) !== index3))
|
|
15712
15823
|
throw new Error("Inconsistent Values axis position");
|
|
15713
|
-
if (axis.length === 3 &&
|
|
15824
|
+
if (axis.length === 3 && index3 < 2 && position === null)
|
|
15714
15825
|
throw new Error("Missing leading or between-field Values position");
|
|
15715
|
-
return
|
|
15826
|
+
return index3;
|
|
15716
15827
|
}
|
|
15717
|
-
function pivotValueAxisItems(measures, columns) {
|
|
15828
|
+
function pivotValueAxisItems(measures, columns, columnIndices) {
|
|
15718
15829
|
const entries = [];
|
|
15719
15830
|
if (columns === void 0) {
|
|
15720
15831
|
for (let measure = 0; measure < measures; measure++)
|
|
@@ -15725,7 +15836,7 @@ function pivotValueAxisItems(measures, columns) {
|
|
|
15725
15836
|
for (let column = 0; column < columns; column++)
|
|
15726
15837
|
for (let measure = 0; measure < measures; measure++) {
|
|
15727
15838
|
entries.push(
|
|
15728
|
-
`<i${attrs({ r: measure ? 1 : void 0, i: measure || void 0 })}>${measure ? "" : `<x${attrs({ v: column || void 0 })}/>`}<x${attrs({ v: measure || void 0 })}/></i>`
|
|
15839
|
+
`<i${attrs({ r: measure ? 1 : void 0, i: measure || void 0 })}>${measure ? "" : `<x${attrs({ v: (columnIndices?.[column] ?? column) || void 0 })}/>`}<x${attrs({ v: measure || void 0 })}/></i>`
|
|
15729
15840
|
);
|
|
15730
15841
|
}
|
|
15731
15842
|
for (let measure = 0; measure < measures; measure++)
|
|
@@ -15734,11 +15845,169 @@ function pivotValueAxisItems(measures, columns) {
|
|
|
15734
15845
|
return `<colItems count="${entries.length}">${entries.join("")}</colItems>`;
|
|
15735
15846
|
}
|
|
15736
15847
|
function supportedPivotAxes(rows, columns, measures, valuesOnRows) {
|
|
15737
|
-
const
|
|
15848
|
+
const index3 = pivotFieldIndex;
|
|
15738
15849
|
if (valuesOnRows)
|
|
15739
|
-
return measures > 1 && (rows.length === 2 || rows.length === 3) && (
|
|
15740
|
-
if (rows.some((field) => !Number.isInteger(
|
|
15741
|
-
return measures === 1 ? columns.length <= 1 : columns.length >= 1 && columns.length <= 2 &&
|
|
15850
|
+
return measures > 1 && (rows.length === 2 || rows.length === 3) && (index3(rows[0]) >= 0 || rows.length === 3) && rows.filter((field) => index3(field) === -2).length === 1 && rows.filter((field) => index3(field) !== -2).every((field) => index3(field) >= 0) && columns.length <= 1 && (!columns.length || index3(columns[0]) >= 0);
|
|
15851
|
+
if (rows.some((field) => !Number.isInteger(index3(field)) || index3(field) < 0)) return false;
|
|
15852
|
+
return measures === 1 ? columns.length <= 1 : columns.length >= 1 && columns.length <= 2 && index3(columns.at(-1)) === -2 && (columns.length !== 2 || index3(columns[0]) >= 0);
|
|
15853
|
+
}
|
|
15854
|
+
|
|
15855
|
+
// drawingml/dom.ts
|
|
15856
|
+
function attributeReader(element2) {
|
|
15857
|
+
return (name) => {
|
|
15858
|
+
if (!element2) return void 0;
|
|
15859
|
+
const direct = element2.getAttribute(name);
|
|
15860
|
+
if (direct !== null) return direct;
|
|
15861
|
+
const attributes = element2.attributes;
|
|
15862
|
+
for (let index3 = 0; index3 < attributes.length; index3++) {
|
|
15863
|
+
const candidate = attributes.item(index3);
|
|
15864
|
+
if (candidate && candidate.localName === name) return candidate.value;
|
|
15865
|
+
}
|
|
15866
|
+
return void 0;
|
|
15867
|
+
};
|
|
15868
|
+
}
|
|
15869
|
+
function stringAttribute(element2, name) {
|
|
15870
|
+
const value2 = attributeReader(element2)(name)?.trim();
|
|
15871
|
+
return value2 ? value2 : void 0;
|
|
15872
|
+
}
|
|
15873
|
+
function integerAttribute(element2, name) {
|
|
15874
|
+
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
15875
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
15876
|
+
}
|
|
15877
|
+
function booleanAttribute(element2, name) {
|
|
15878
|
+
const value2 = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
15879
|
+
if (value2 === "1" || value2 === "true") return true;
|
|
15880
|
+
if (value2 === "0" || value2 === "false") return false;
|
|
15881
|
+
return void 0;
|
|
15882
|
+
}
|
|
15883
|
+
function descendants2(root, local) {
|
|
15884
|
+
const result2 = [];
|
|
15885
|
+
const visit2 = (node) => {
|
|
15886
|
+
for (const child3 of Array.from(node.childNodes)) {
|
|
15887
|
+
if (!isElement(child3)) continue;
|
|
15888
|
+
if (child3.localName === local) result2.push(child3);
|
|
15889
|
+
visit2(child3);
|
|
15890
|
+
}
|
|
15891
|
+
};
|
|
15892
|
+
visit2(root);
|
|
15893
|
+
return result2;
|
|
15894
|
+
}
|
|
15895
|
+
|
|
15896
|
+
// xlsx/pivot/page-filter-admission.ts
|
|
15897
|
+
var integer = (value2, fallback) => value2 === null ? fallback ?? NaN : /^\d+$/.test(value2.trim()) && Number.isSafeInteger(Number(value2)) ? Number(value2) : NaN;
|
|
15898
|
+
function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
15899
|
+
if (!pivot.pageFilter) return;
|
|
15900
|
+
const literals = (node) => {
|
|
15901
|
+
const raw2 = node.getAttribute("v");
|
|
15902
|
+
if (node.localName === "x" && (raw2 === null || !/^\d+$/.test(raw2.trim())) || node.localName === "b" && !["0", "1"].includes(raw2 ?? "") || node.localName === "n" && (raw2 === null || !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(raw2.trim())))
|
|
15903
|
+
throw new Error("Unmodeled report cache literal");
|
|
15904
|
+
for (const child3 of elements(node)) literals(child3);
|
|
15905
|
+
};
|
|
15906
|
+
literals(cache3);
|
|
15907
|
+
literals(recordRoot);
|
|
15908
|
+
const cacheFields = children(first(cache3, "cacheFields", NS.x), "cacheField", NS.x);
|
|
15909
|
+
if (pivot.columnField) {
|
|
15910
|
+
const column = children(first(root, "pivotFields", NS.x), "pivotField", NS.x)[pivot.fields.indexOf(pivot.columnField)];
|
|
15911
|
+
const list = first(column, "extLst", NS.x);
|
|
15912
|
+
const extensions = list ? children(list, "ext", NS.x) : [];
|
|
15913
|
+
if (extensions.some(
|
|
15914
|
+
(extension) => children(
|
|
15915
|
+
extension,
|
|
15916
|
+
"pivotField",
|
|
15917
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
15918
|
+
).some((field) => {
|
|
15919
|
+
const raw2 = field.getAttribute("fillDownLabels");
|
|
15920
|
+
if (raw2 !== null && !["0", "1", "false", "true"].includes(raw2.trim()))
|
|
15921
|
+
throw new Error("Invalid report column label repetition");
|
|
15922
|
+
return booleanAttribute(field, "fillDownLabels") === true;
|
|
15923
|
+
})
|
|
15924
|
+
))
|
|
15925
|
+
throw new Error("Repeated report column labels are preserved");
|
|
15926
|
+
}
|
|
15927
|
+
if (integer(first(cache3, "cacheFields", NS.x)?.getAttribute("count") ?? null) !== pivot.fields.length || integer(cache3.getAttribute("recordCount")) !== pivot.records.length || integer(recordRoot.getAttribute("count")) !== pivot.records.length)
|
|
15928
|
+
throw new Error("Inconsistent report cache counts");
|
|
15929
|
+
for (const name of [
|
|
15930
|
+
pivot.rowField,
|
|
15931
|
+
pivot.secondRowField,
|
|
15932
|
+
pivot.columnField,
|
|
15933
|
+
pivot.pageFilter.field
|
|
15934
|
+
].filter(Boolean)) {
|
|
15935
|
+
const field = pivot.fields.indexOf(name);
|
|
15936
|
+
if (integer(first(cacheFields[field], "sharedItems", NS.x)?.getAttribute("count") ?? null) !== shared[field].length)
|
|
15937
|
+
throw new Error("Inconsistent report shared-item counts");
|
|
15938
|
+
}
|
|
15939
|
+
for (const name of ["rowFields", "colFields"]) {
|
|
15940
|
+
const list = first(root, name, NS.x);
|
|
15941
|
+
if (list && integer(list.getAttribute("count")) !== children(list, "field", NS.x).length)
|
|
15942
|
+
throw new Error("Inconsistent report axis counts");
|
|
15943
|
+
}
|
|
15944
|
+
const projected = pivotPageProjection(pivot), fields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
15945
|
+
const axisValues = (name, axis) => {
|
|
15946
|
+
const f6 = pivot.fields.indexOf(name), node = fields[f6], list = first(node, "items", NS.x), items = children(list, "item", NS.x), count2 = shared[f6].length;
|
|
15947
|
+
if (node.getAttribute("axis") !== axis) throw new Error("Inconsistent report axis field");
|
|
15948
|
+
const defaults = node.getAttribute("defaultSubtotal") !== "0";
|
|
15949
|
+
if (!list || integer(list.getAttribute("count")) !== items.length || items.length !== count2 + Number(defaults))
|
|
15950
|
+
throw new Error("Incomplete page-axis field items");
|
|
15951
|
+
const data = items.slice(0, count2).map((item) => {
|
|
15952
|
+
const i2 = integer(item.getAttribute("x"));
|
|
15953
|
+
if (item.hasAttribute("t") || !Number.isInteger(i2) || i2 >= count2)
|
|
15954
|
+
throw new Error("Invalid page-axis cache item");
|
|
15955
|
+
return shared[f6][i2];
|
|
15956
|
+
});
|
|
15957
|
+
if (new Set(data.map(pivotValueKey)).size !== count2 || defaults && (items.at(-1)?.getAttribute("t") !== "default" || items.at(-1)?.hasAttribute("x")))
|
|
15958
|
+
throw new Error("Invalid page-axis default item");
|
|
15959
|
+
const indices = new Map(data.map((v, i2) => [pivotValueKey(v), i2]));
|
|
15960
|
+
return pivotItems(projected, name).map((v) => indices.get(pivotValueKey(v)));
|
|
15961
|
+
};
|
|
15962
|
+
const read = (name) => {
|
|
15963
|
+
const list = first(root, name, NS.x), items = children(list, "i", NS.x);
|
|
15964
|
+
if (!list || integer(list.getAttribute("count")) !== items.length)
|
|
15965
|
+
throw new Error("Invalid page-axis item count");
|
|
15966
|
+
return items;
|
|
15967
|
+
};
|
|
15968
|
+
const rows = axisValues(pivot.rowField, "axisRow"), rowItems = read("rowItems");
|
|
15969
|
+
const grid = pivotGrid(pivot);
|
|
15970
|
+
const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, [
|
|
15971
|
+
rows,
|
|
15972
|
+
pivot.secondRowField ? axisValues(pivot.secondRowField, "axisRow") : []
|
|
15973
|
+
]) : [
|
|
15974
|
+
...rows.map((index3) => ({ indices: [index3], type: void 0 })),
|
|
15975
|
+
{ indices: [0], type: "grand" }
|
|
15976
|
+
];
|
|
15977
|
+
if (rowItems.length !== entries.length) throw new Error("Invalid page row items");
|
|
15978
|
+
let previousRow = [];
|
|
15979
|
+
rowItems.forEach((item, i2) => {
|
|
15980
|
+
const expected2 = entries[i2];
|
|
15981
|
+
const xs = children(item, "x", NS.x).map((x) => integer(x.getAttribute("v"), 0)), prefix = integer(item.getAttribute("r"), 0);
|
|
15982
|
+
if (item.getAttribute("t") !== (expected2.type ?? null) || !Number.isInteger(prefix) || prefix < 0 || prefix > previousRow.length || prefix >= expected2.indices.length || expected2.type && prefix !== 0 || integer(item.getAttribute("i"), 0) !== 0 || JSON.stringify([...previousRow.slice(0, prefix), ...xs]) !== JSON.stringify(expected2.indices))
|
|
15983
|
+
throw new Error("Unmodeled page row item");
|
|
15984
|
+
previousRow = expected2.type ? [] : expected2.indices;
|
|
15985
|
+
});
|
|
15986
|
+
const measures = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
15987
|
+
if (columns)
|
|
15988
|
+
for (const col of columns)
|
|
15989
|
+
for (let m = 0; m < measures; m++) expected.push(measures > 1 ? [col, m] : [col]);
|
|
15990
|
+
else for (let m = 0; m < measures; m++) expected.push([m]);
|
|
15991
|
+
const colItems = read("colItems");
|
|
15992
|
+
if (colItems.length !== expected.length + (columns ? measures : 0))
|
|
15993
|
+
throw new Error("Invalid page column items");
|
|
15994
|
+
let previous = [];
|
|
15995
|
+
colItems.forEach((item, i2) => {
|
|
15996
|
+
const grand = i2 >= expected.length, measure = grand ? i2 - expected.length : i2 % measures;
|
|
15997
|
+
const xs = children(item, "x", NS.x).map((x) => integer(x.getAttribute("v"), 0)), prefix = integer(item.getAttribute("r"), 0);
|
|
15998
|
+
if (integer(item.getAttribute("i"), 0) !== measure || !Number.isInteger(prefix) || prefix < 0 || prefix > Math.max(0, previous.length - 1))
|
|
15999
|
+
throw new Error("Invalid page column prefix");
|
|
16000
|
+
if (grand) {
|
|
16001
|
+
if (item.getAttribute("t") !== "grand" || prefix !== 0 || xs.length !== 1 || xs[0] !== 0)
|
|
16002
|
+
throw new Error("Unmodeled page grand item");
|
|
16003
|
+
previous = [];
|
|
16004
|
+
return;
|
|
16005
|
+
}
|
|
16006
|
+
const values2 = !columns && measures === 1 && xs.length === 0 && prefix === 0 ? [0] : [...previous.slice(0, prefix), ...xs];
|
|
16007
|
+
if (item.hasAttribute("t") || JSON.stringify(values2) !== JSON.stringify(expected[i2]))
|
|
16008
|
+
throw new Error("Unmodeled page column item");
|
|
16009
|
+
previous = values2;
|
|
16010
|
+
});
|
|
15742
16011
|
}
|
|
15743
16012
|
|
|
15744
16013
|
// xlsx/pivot/read.ts
|
|
@@ -15778,20 +16047,21 @@ function readOne(workbook, source2, part) {
|
|
|
15778
16047
|
const rowsAxis = att(root, "dataOnRows") === "1";
|
|
15779
16048
|
if (!dataSheet || !dataRange || !recordPart || !workbook.sheets.some((sheet) => sheet.name === dataSheet))
|
|
15780
16049
|
throw new Error("Unsupported pivot source");
|
|
15781
|
-
|
|
16050
|
+
const recordRoot = parseXml(source2.text(recordPart)).documentElement;
|
|
16051
|
+
assertPivotRecords(recordRoot);
|
|
15782
16052
|
const fields = children(first(cache3, "cacheFields", NS.x), "cacheField", NS.x);
|
|
15783
16053
|
if (fields.some((field) => first(field, "fieldGroup", NS.x) || field.hasAttribute("formula")))
|
|
15784
16054
|
throw new Error("Grouped or calculated cache field");
|
|
15785
16055
|
const shared = fields.map(
|
|
15786
16056
|
(field) => elements(first(field, "sharedItems", NS.x) ?? parseXml("<root/>").documentElement).map(value)
|
|
15787
16057
|
);
|
|
15788
|
-
const records = children(
|
|
16058
|
+
const records = children(recordRoot, "r", NS.x).map(
|
|
15789
16059
|
(record) => elements(record).map((node, field) => {
|
|
15790
16060
|
if (node.localName !== "x") return value(node);
|
|
15791
|
-
const
|
|
15792
|
-
if (!Number.isInteger(
|
|
16061
|
+
const index3 = Number(att(node, "v"));
|
|
16062
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= (shared[field]?.length ?? 0))
|
|
15793
16063
|
throw new Error("Invalid pivot cache index");
|
|
15794
|
-
return shared[field][
|
|
16064
|
+
return shared[field][index3];
|
|
15795
16065
|
})
|
|
15796
16066
|
);
|
|
15797
16067
|
if (records.some((record) => record.length !== fields.length) || records.length * fields.length > 1e6)
|
|
@@ -15811,7 +16081,7 @@ function readOne(workbook, source2, part) {
|
|
|
15811
16081
|
"dataField",
|
|
15812
16082
|
NS.x
|
|
15813
16083
|
);
|
|
15814
|
-
if (rowFields.length < 1 || rowFields.length > (rowsAxis ? 3 : 2) || dataFields.length < 1 || dataFields.length > 16 || !supportedPivotAxes(rowFields, colFields, dataFields.length, rowsAxis) || first(root, "
|
|
16084
|
+
if (rowFields.length < 1 || rowFields.length > (rowsAxis ? 3 : 2) || dataFields.length < 1 || dataFields.length > 16 || !supportedPivotAxes(rowFields, colFields, dataFields.length, rowsAxis) || first(root, "filters", NS.x) || root.getAttribute("rowGrandTotals") === "0" || root.getAttribute("colGrandTotals") === "0")
|
|
15815
16085
|
throw new Error("Unsupported pivot layout");
|
|
15816
16086
|
const valueIndex = pivotValueIndex(root, rowsAxis ? rowFields : colFields);
|
|
15817
16087
|
const measure = dataFields[0];
|
|
@@ -15833,8 +16103,8 @@ function readOne(workbook, source2, part) {
|
|
|
15833
16103
|
"i",
|
|
15834
16104
|
NS.x
|
|
15835
16105
|
)) {
|
|
15836
|
-
const
|
|
15837
|
-
if (!Number.isInteger(
|
|
16106
|
+
const index3 = Number(att(item, "i") ?? "0");
|
|
16107
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= count2)
|
|
15838
16108
|
throw new Error("Unsupported Values axis item");
|
|
15839
16109
|
}
|
|
15840
16110
|
}
|
|
@@ -15845,6 +16115,7 @@ function readOne(workbook, source2, part) {
|
|
|
15845
16115
|
const realRows = rowsAxis ? rowFields.filter((field) => pivotFieldIndex(field) !== -2) : rowFields;
|
|
15846
16116
|
const row2 = names[pivotFieldIndex(realRows[0])];
|
|
15847
16117
|
const second = realRows[1] ? names[Number(att(realRows[1], "x"))] : void 0;
|
|
16118
|
+
const pageFilter = readPivotPageFilter(root, names, shared);
|
|
15848
16119
|
const tableFields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
15849
16120
|
const outer = tableFields[pivotFieldIndex(realRows[0])];
|
|
15850
16121
|
const compact3 = att(outer, "compact") !== "0";
|
|
@@ -15874,7 +16145,12 @@ function readOne(workbook, source2, part) {
|
|
|
15874
16145
|
const location = parseRange(att(first(root, "location", NS.x), "ref") ?? "");
|
|
15875
16146
|
if (!row2 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
|
|
15876
16147
|
throw new Error("Invalid pivot fields");
|
|
16148
|
+
if (pageFilter) {
|
|
16149
|
+
if (location.start.row < 2) throw new Error("Invalid report filter location");
|
|
16150
|
+
location.start.row -= 2;
|
|
16151
|
+
}
|
|
15877
16152
|
const pivot = {
|
|
16153
|
+
...pageFilter ? { pageFilter } : {},
|
|
15878
16154
|
name: att(root, "name") ?? "PivotTable",
|
|
15879
16155
|
source: `${quoteSheetName(dataSheet)}!${formatRange(dataRange)}`,
|
|
15880
16156
|
rowField: row2,
|
|
@@ -15906,6 +16182,7 @@ function readOne(workbook, source2, part) {
|
|
|
15906
16182
|
sourceXml: xml,
|
|
15907
16183
|
...col ? { columnField: col } : {}
|
|
15908
16184
|
};
|
|
16185
|
+
assertPageAxisItems(root, pivot, shared, cache3, recordRoot);
|
|
15909
16186
|
return pivot;
|
|
15910
16187
|
}
|
|
15911
16188
|
function readPivotTables(workbook, source2, warn) {
|
|
@@ -16231,10 +16508,10 @@ function parseDynamicArrayMetadata(xml) {
|
|
|
16231
16508
|
const flag2 = props?.getAttribute("fDynamic");
|
|
16232
16509
|
return flag2 === "1" || flag2 === "true";
|
|
16233
16510
|
});
|
|
16234
|
-
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk,
|
|
16511
|
+
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk, index3) => {
|
|
16235
16512
|
for (const rc of childrenNamed(bk, "rc")) {
|
|
16236
16513
|
const type = types[Number(att(rc, "t")) - 1];
|
|
16237
|
-
if (type === DYNAMIC_ARRAY_TYPE && dynamic[Number(att(rc, "v"))]) out.add(
|
|
16514
|
+
if (type === DYNAMIC_ARRAY_TYPE && dynamic[Number(att(rc, "v"))]) out.add(index3 + 1);
|
|
16238
16515
|
}
|
|
16239
16516
|
});
|
|
16240
16517
|
return out;
|
|
@@ -16512,13 +16789,13 @@ function parseStyles(xml, warnings) {
|
|
|
16512
16789
|
const named2 = namesByXf.get(xfId);
|
|
16513
16790
|
if (named2 && xfId !== 0 && named2 !== "Normal") style2.cellStyleName = named2;
|
|
16514
16791
|
const key = styleKey(style2);
|
|
16515
|
-
let
|
|
16516
|
-
if (
|
|
16517
|
-
|
|
16792
|
+
let index3 = keys.get(key);
|
|
16793
|
+
if (index3 === void 0) {
|
|
16794
|
+
index3 = styles.length;
|
|
16518
16795
|
styles.push(style2);
|
|
16519
|
-
keys.set(key,
|
|
16796
|
+
keys.set(key, index3);
|
|
16520
16797
|
}
|
|
16521
|
-
xfMap.push(
|
|
16798
|
+
xfMap.push(index3);
|
|
16522
16799
|
}
|
|
16523
16800
|
if (!styles.length) {
|
|
16524
16801
|
styles.push(fallback);
|
|
@@ -16927,11 +17204,11 @@ function sigmaGradientStops(stops) {
|
|
|
16927
17204
|
const front = hexToRgbChannels(stops[0].color);
|
|
16928
17205
|
const back = hexToRgbChannels(stops[1].color);
|
|
16929
17206
|
if (!front || !back) return void 0;
|
|
16930
|
-
return OFFICE_SIGMA_FACTORS.map((value2,
|
|
17207
|
+
return OFFICE_SIGMA_FACTORS.map((value2, index3) => {
|
|
16931
17208
|
const factor = value2 / 65536;
|
|
16932
17209
|
const mix = (a2, b) => toHex(255 * ((a2 / 255) ** 2.2 * (1 - factor) + (b / 255) ** 2.2 * factor) ** (1 / 2.2));
|
|
16933
17210
|
return {
|
|
16934
|
-
offset: Math.fround(
|
|
17211
|
+
offset: Math.fround(index3 / 255),
|
|
16935
17212
|
color: `#${mix(front.r, back.r)}${mix(front.g, back.g)}${mix(front.b, back.b)}`,
|
|
16936
17213
|
opacity: 1
|
|
16937
17214
|
};
|
|
@@ -16948,47 +17225,6 @@ function parseArgbHex(hex) {
|
|
|
16948
17225
|
var clamp255 = (v) => Math.max(0, Math.min(255, v));
|
|
16949
17226
|
var rgbToUpperHex = (rgb2) => `#${rgb2.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
16950
17227
|
|
|
16951
|
-
// drawingml/dom.ts
|
|
16952
|
-
function attributeReader(element2) {
|
|
16953
|
-
return (name) => {
|
|
16954
|
-
if (!element2) return void 0;
|
|
16955
|
-
const direct = element2.getAttribute(name);
|
|
16956
|
-
if (direct !== null) return direct;
|
|
16957
|
-
const attributes = element2.attributes;
|
|
16958
|
-
for (let index2 = 0; index2 < attributes.length; index2++) {
|
|
16959
|
-
const candidate = attributes.item(index2);
|
|
16960
|
-
if (candidate && candidate.localName === name) return candidate.value;
|
|
16961
|
-
}
|
|
16962
|
-
return void 0;
|
|
16963
|
-
};
|
|
16964
|
-
}
|
|
16965
|
-
function stringAttribute(element2, name) {
|
|
16966
|
-
const value2 = attributeReader(element2)(name)?.trim();
|
|
16967
|
-
return value2 ? value2 : void 0;
|
|
16968
|
-
}
|
|
16969
|
-
function integerAttribute(element2, name) {
|
|
16970
|
-
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
16971
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
16972
|
-
}
|
|
16973
|
-
function booleanAttribute(element2, name) {
|
|
16974
|
-
const value2 = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
16975
|
-
if (value2 === "1" || value2 === "true") return true;
|
|
16976
|
-
if (value2 === "0" || value2 === "false") return false;
|
|
16977
|
-
return void 0;
|
|
16978
|
-
}
|
|
16979
|
-
function descendants2(root, local) {
|
|
16980
|
-
const result2 = [];
|
|
16981
|
-
const visit2 = (node) => {
|
|
16982
|
-
for (const child3 of Array.from(node.childNodes)) {
|
|
16983
|
-
if (!isElement(child3)) continue;
|
|
16984
|
-
if (child3.localName === local) result2.push(child3);
|
|
16985
|
-
visit2(child3);
|
|
16986
|
-
}
|
|
16987
|
-
};
|
|
16988
|
-
visit2(root);
|
|
16989
|
-
return result2;
|
|
16990
|
-
}
|
|
16991
|
-
|
|
16992
17228
|
// drawingml/ordered-color-transforms.ts
|
|
16993
17229
|
function orderedColorTransforms(channels, transforms) {
|
|
16994
17230
|
let { r, g: g2, b } = channels;
|
|
@@ -17310,7 +17546,7 @@ function parseTheme2(xml) {
|
|
|
17310
17546
|
if (!xml) return palette;
|
|
17311
17547
|
const theme2 = parseTheme(parseXml(xml, { label: "XLSX theme" }));
|
|
17312
17548
|
palette.colors = PALETTE_SLOTS.map(
|
|
17313
|
-
(slot2,
|
|
17549
|
+
(slot2, index3) => paletteHex(theme2.colorScheme.colors[slot2]) ?? DEFAULT_THEME.colors[index3] ?? "000000"
|
|
17314
17550
|
);
|
|
17315
17551
|
palette.majorFont = theme2.fontScheme.major.latin ?? palette.majorFont;
|
|
17316
17552
|
palette.minorFont = theme2.fontScheme.minor.latin ?? palette.minorFont;
|
|
@@ -17493,11 +17729,11 @@ function readModernHash(node, prefix = "") {
|
|
|
17493
17729
|
function parseWorkbookPart(xml) {
|
|
17494
17730
|
const root = parseXml(xml, { label: "XLSX workbook" }).documentElement;
|
|
17495
17731
|
const sheets = [];
|
|
17496
|
-
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node,
|
|
17732
|
+
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node, index3) => {
|
|
17497
17733
|
const state = att(node, "state");
|
|
17498
17734
|
sheets.push({
|
|
17499
|
-
name: att(node, "name") ?? `Sheet${
|
|
17500
|
-
sheetId: numAttr(node, "sheetId") ??
|
|
17735
|
+
name: att(node, "name") ?? `Sheet${index3 + 1}`,
|
|
17736
|
+
sheetId: numAttr(node, "sheetId") ?? index3 + 1,
|
|
17501
17737
|
state: state === "hidden" || state === "veryHidden" ? state : "visible",
|
|
17502
17738
|
relId: relAttr(node, "id") ?? ""
|
|
17503
17739
|
});
|
|
@@ -17847,8 +18083,8 @@ function styleRef(element2) {
|
|
|
17847
18083
|
if (element2.localName === "fontRef") {
|
|
17848
18084
|
if (raw2) ref.fontIndex = raw2;
|
|
17849
18085
|
} else {
|
|
17850
|
-
const
|
|
17851
|
-
if (Number.isFinite(
|
|
18086
|
+
const index3 = Number.parseInt(raw2 ?? "", 10);
|
|
18087
|
+
if (Number.isFinite(index3)) ref.index = index3;
|
|
17852
18088
|
}
|
|
17853
18089
|
const color = parseDrawingColorIn(element2);
|
|
17854
18090
|
if (color) ref.color = color;
|
|
@@ -18236,11 +18472,11 @@ function groupTransform(group, parent) {
|
|
|
18236
18472
|
scaleY: parent.scaleY * local.scaleY
|
|
18237
18473
|
};
|
|
18238
18474
|
}
|
|
18239
|
-
function parseShape(sp,
|
|
18475
|
+
function parseShape(sp, index3, group, issues) {
|
|
18240
18476
|
const spPr = first(sp, "spPr", NS.dsp);
|
|
18241
18477
|
const transform6 = parseTransform(first(spPr, "xfrm", NS.a));
|
|
18242
18478
|
if (!transform6) return void 0;
|
|
18243
|
-
const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${
|
|
18479
|
+
const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${index3}`;
|
|
18244
18480
|
const { geometry, adjustments, paths, issue } = parseDrawingGeometry(spPr);
|
|
18245
18481
|
if (issue) issues.push({ code: issue, message: `Shape ${modelId}: ${issue}.` });
|
|
18246
18482
|
const frame = applyGroup(transform6.frame, group);
|
|
@@ -18458,8 +18694,8 @@ function drawingFillXml(fill) {
|
|
|
18458
18694
|
const stops = children(list, "gs", NS.a).filter(
|
|
18459
18695
|
(node) => parseDrawingColorIn(node) && Number.isFinite(Number.parseInt(node.getAttribute("pos") ?? "", 10))
|
|
18460
18696
|
);
|
|
18461
|
-
fill.stops.forEach((stop,
|
|
18462
|
-
const node = stops[
|
|
18697
|
+
fill.stops.forEach((stop, index3) => {
|
|
18698
|
+
const node = stops[index3] ?? doc.createElementNS(NS.a, "a:gs");
|
|
18463
18699
|
if (!node.parentNode) list.appendChild(node);
|
|
18464
18700
|
node.setAttribute("pos", String(Math.round(stop.position * 1e3)));
|
|
18465
18701
|
for (const old of elements(node))
|
|
@@ -18817,8 +19053,8 @@ var OFFICE_GRADIENT_PRESET_DATA = [
|
|
|
18817
19053
|
];
|
|
18818
19054
|
|
|
18819
19055
|
// drawingml/gradient-presets.ts
|
|
18820
|
-
OFFICE_GRADIENT_PRESET_DATA.map(([label3],
|
|
18821
|
-
id:
|
|
19056
|
+
OFFICE_GRADIENT_PRESET_DATA.map(([label3], index3) => ({
|
|
19057
|
+
id: index3 + 1,
|
|
18822
19058
|
label: label3
|
|
18823
19059
|
}));
|
|
18824
19060
|
function officeGradientPresetFill(id) {
|
|
@@ -19435,8 +19671,8 @@ function writeSettings(node, rule) {
|
|
|
19435
19671
|
if (rule.minLength !== void 0) bar.setAttribute("minLength", String(rule.minLength));
|
|
19436
19672
|
if (rule.maxLength !== void 0) bar.setAttribute("maxLength", String(rule.maxLength));
|
|
19437
19673
|
const thresholds = children(bar, "cfvo", NS.x14);
|
|
19438
|
-
for (const [
|
|
19439
|
-
const target = thresholds[
|
|
19674
|
+
for (const [index3, threshold] of [rule.min, rule.max].entries()) {
|
|
19675
|
+
const target = thresholds[index3];
|
|
19440
19676
|
if (!target) continue;
|
|
19441
19677
|
const oldType = target.getAttribute("type");
|
|
19442
19678
|
if (oldType === "autoMin" && threshold.type === "min" || oldType === "autoMax" && threshold.type === "max")
|
|
@@ -19746,7 +19982,7 @@ function chartCacheValues(cache3) {
|
|
|
19746
19982
|
out[point.index ?? out.length] = numeric2 && text3.trim() !== "" && Number.isFinite(Number(text3)) ? Number(text3) : text3;
|
|
19747
19983
|
}
|
|
19748
19984
|
const size = Math.max(cache3.pointCount ?? 0, out.length);
|
|
19749
|
-
for (let
|
|
19985
|
+
for (let index3 = 0; index3 < size; index3++) if (out[index3] === void 0) out[index3] = "";
|
|
19750
19986
|
return out;
|
|
19751
19987
|
}
|
|
19752
19988
|
var chartSourceValues = (source2) => chartCacheValues(source2?.cache ?? source2?.levels?.[0]);
|
|
@@ -19881,8 +20117,8 @@ function parseCache(node) {
|
|
|
19881
20117
|
type: node.localName === "numCache" || node.localName === "numLit" ? "number" : "string",
|
|
19882
20118
|
points: children(node, "pt", NS.c).map((pt) => {
|
|
19883
20119
|
const point = { value: cChild(pt, "v")?.textContent ?? "" };
|
|
19884
|
-
const
|
|
19885
|
-
if (Number.isInteger(
|
|
20120
|
+
const index3 = Number(attribute(pt, "idx") ?? Number.NaN);
|
|
20121
|
+
if (Number.isInteger(index3) && index3 >= 0) point.index = index3;
|
|
19886
20122
|
const formatCode2 = attribute(pt, "formatCode");
|
|
19887
20123
|
if (formatCode2 !== void 0) point.formatCode = formatCode2;
|
|
19888
20124
|
return point;
|
|
@@ -20108,11 +20344,11 @@ var POINT = /* @__PURE__ */ new Set([
|
|
|
20108
20344
|
]);
|
|
20109
20345
|
function parseDataPoint(context, element2) {
|
|
20110
20346
|
reportUnmodelled(context, element2, POINT);
|
|
20111
|
-
const
|
|
20347
|
+
const index3 = cNumber(context, element2, "idx");
|
|
20112
20348
|
return assignDefined(
|
|
20113
20349
|
{},
|
|
20114
20350
|
{
|
|
20115
|
-
index:
|
|
20351
|
+
index: index3 !== void 0 && Number.isInteger(index3) && index3 >= 0 ? index3 : void 0,
|
|
20116
20352
|
invertIfNegative: cBool(context, element2, "invertIfNegative"),
|
|
20117
20353
|
bubble3D: cBool(context, element2, "bubble3D"),
|
|
20118
20354
|
explosion: cNumber(context, element2, "explosion"),
|
|
@@ -20649,8 +20885,8 @@ var SCHEME_INDEX = {
|
|
|
20649
20885
|
function legacyColor(color) {
|
|
20650
20886
|
if (color?.kind === "srgb") return color.value ? { rgb: color.value.toUpperCase() } : void 0;
|
|
20651
20887
|
if (color?.kind === "scheme") {
|
|
20652
|
-
const
|
|
20653
|
-
return
|
|
20888
|
+
const index3 = SCHEME_INDEX[color.value];
|
|
20889
|
+
return index3 === void 0 ? void 0 : { theme: index3 };
|
|
20654
20890
|
}
|
|
20655
20891
|
return void 0;
|
|
20656
20892
|
}
|
|
@@ -21587,14 +21823,14 @@ var PersonRegistry = class {
|
|
|
21587
21823
|
return `${XML_HEADER}<personList xmlns="${NS.tc}" xmlns:x="${NS.x}">${people}</personList>`;
|
|
21588
21824
|
}
|
|
21589
21825
|
};
|
|
21590
|
-
function vmlShape(comment,
|
|
21826
|
+
function vmlShape(comment, index3, id) {
|
|
21591
21827
|
const { row: row2, col } = comment.address;
|
|
21592
21828
|
const anchor = `${col + 1}, 15, ${Math.max(0, row2 - 1)}, 10, ${col + 3}, 15, ${row2 + 3}, 4`;
|
|
21593
|
-
return `<v:shape id="_x0000_s${id}" type="#_x0000_t202" style="position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;z-index:${
|
|
21829
|
+
return `<v:shape id="_x0000_s${id}" type="#_x0000_t202" style="position:absolute;margin-left:59.25pt;margin-top:1.5pt;width:108pt;height:59.25pt;z-index:${index3 + 1};visibility:hidden" fillcolor="#ffffe1" o:insetmode="auto"><v:fill color2="#ffffe1"/><v:shadow on="t" color="black" obscured="t"/><v:path o:connecttype="none"/><v:textbox style="mso-direction-alt:auto"><div style="text-align:left"></div></v:textbox><x:ClientData ObjectType="Note"><x:MoveWithCells/><x:SizeWithCells/><x:Anchor>${anchor}</x:Anchor><x:AutoFill>False</x:AutoFill><x:Row>${row2}</x:Row><x:Column>${col}</x:Column></x:ClientData></v:shape>`;
|
|
21594
21830
|
}
|
|
21595
21831
|
var NOTE_SHAPETYPE = '<v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202" path="m,l,21600r21600,l21600,xe"><v:stroke joinstyle="miter"/><v:path gradientshapeok="t" o:connecttype="rect"/></v:shapetype>';
|
|
21596
21832
|
function vmlXml(comments, layout2) {
|
|
21597
|
-
const shapes = comments.map((comment,
|
|
21833
|
+
const shapes = comments.map((comment, index3) => vmlShape(comment, index3, layout2.ids[index3] ?? 0)).join("");
|
|
21598
21834
|
const data = layout2.blocks.join(",");
|
|
21599
21835
|
const base = layout2.base;
|
|
21600
21836
|
if (base && /<\/xml>\s*$/.test(base)) {
|
|
@@ -21625,8 +21861,8 @@ function commentParts(comments, sheetNumber, persons, sheetName, layout2) {
|
|
|
21625
21861
|
const id = guidFrom(`${sheetName}!${ref}:${comment.text}`);
|
|
21626
21862
|
const personId = persons.id(comment.author);
|
|
21627
21863
|
threaded += `<threadedComment ref="${ref}" personId="${personId}" id="${id}"><text>${escapeText2(comment.text)}</text></threadedComment>`;
|
|
21628
|
-
comment.replies.forEach((reply,
|
|
21629
|
-
const replyId = guidFrom(`${id}:reply:${
|
|
21864
|
+
comment.replies.forEach((reply, index3) => {
|
|
21865
|
+
const replyId = guidFrom(`${id}:reply:${index3}:${reply.text}`);
|
|
21630
21866
|
const dT = reply.date ? ` dT="${escapeAttr3(reply.date)}"` : "";
|
|
21631
21867
|
threaded += `<threadedComment ref="${ref}"${dT} personId="${persons.id(reply.author)}" id="${replyId}" parentId="${id}"><text>${escapeText2(reply.text)}</text></threadedComment>`;
|
|
21632
21868
|
});
|
|
@@ -21643,7 +21879,7 @@ Reply:
|
|
|
21643
21879
|
sorted2,
|
|
21644
21880
|
layout2 ?? {
|
|
21645
21881
|
blocks: [sheetNumber],
|
|
21646
|
-
ids: sorted2.map((_,
|
|
21882
|
+
ids: sorted2.map((_, index3) => 1024 * sheetNumber + index3 + 1)
|
|
21647
21883
|
}
|
|
21648
21884
|
);
|
|
21649
21885
|
const parts = { comments: commentsXml, vml };
|
|
@@ -22355,11 +22591,11 @@ var GRAY_VARIATIONS = [
|
|
|
22355
22591
|
{ tint: 8e4 }
|
|
22356
22592
|
];
|
|
22357
22593
|
var ACCENTS2 = ["accent1", "accent2", "accent3", "accent4", "accent5", "accent6"];
|
|
22358
|
-
function colorful(id,
|
|
22359
|
-
return { id, group: "colorful", index:
|
|
22594
|
+
function colorful(id, index3, base) {
|
|
22595
|
+
return { id, group: "colorful", index: index3, meth: "cycle", base, variations: COLORFUL_VARIATIONS };
|
|
22360
22596
|
}
|
|
22361
|
-
function mono(id,
|
|
22362
|
-
return { id, group: "monochromatic", index:
|
|
22597
|
+
function mono(id, index3, accent, meth) {
|
|
22598
|
+
return { id, group: "monochromatic", index: index3, meth, base: [accent], variations: [] };
|
|
22363
22599
|
}
|
|
22364
22600
|
var CHART_COLOR_PALETTES = [
|
|
22365
22601
|
colorful(10, 1, ACCENTS2),
|
|
@@ -22403,9 +22639,9 @@ function chartPaletteSeriesColorChoice(palette, i2, n2) {
|
|
|
22403
22639
|
const round3 = Math.floor(i2 / palette.base.length);
|
|
22404
22640
|
transform6 = (palette.variations.length ? palette.variations[round3 % palette.variations.length] : {}) ?? {};
|
|
22405
22641
|
} else {
|
|
22406
|
-
const
|
|
22642
|
+
const index3 = palette.meth === "withinLinearReversed" ? n2 - 1 - i2 : i2;
|
|
22407
22643
|
base = palette.base[0];
|
|
22408
|
-
transform6 = withinLinearTransform(
|
|
22644
|
+
transform6 = withinLinearTransform(index3, n2);
|
|
22409
22645
|
}
|
|
22410
22646
|
if (!base) throw new RangeError("A chart palette must have a base color");
|
|
22411
22647
|
return {
|
|
@@ -22454,18 +22690,18 @@ function chartColorPalettePatch(chart, id) {
|
|
|
22454
22690
|
const previous = findChartColorPalette(chart.colorPalette ?? 10);
|
|
22455
22691
|
if (!next) return void 0;
|
|
22456
22692
|
const radial = chart.chartType === "pie" || chart.chartType === "doughnut";
|
|
22457
|
-
const series = chart.series.map((series2,
|
|
22693
|
+
const series = chart.series.map((series2, index3) => {
|
|
22458
22694
|
const copy = structuredClone(series2);
|
|
22459
22695
|
if (!previous) return copy;
|
|
22460
|
-
const previousChoice = chartPaletteSeriesColorChoice(previous,
|
|
22461
|
-
const nextChoice = chartPaletteSeriesColorChoice(next,
|
|
22696
|
+
const previousChoice = chartPaletteSeriesColorChoice(previous, index3, chart.series.length);
|
|
22697
|
+
const nextChoice = chartPaletteSeriesColorChoice(next, index3, chart.series.length);
|
|
22462
22698
|
const fill = recolorGradient(copy.fill, previousChoice, nextChoice);
|
|
22463
22699
|
if (fill) copy.fill = fill;
|
|
22464
22700
|
if (sameChartColor(
|
|
22465
22701
|
series2.drawingColor,
|
|
22466
|
-
chartPaletteSeriesColorChoice(previous,
|
|
22702
|
+
chartPaletteSeriesColorChoice(previous, index3, chart.series.length)
|
|
22467
22703
|
)) {
|
|
22468
|
-
copy.drawingColor = chartPaletteSeriesColorChoice(next,
|
|
22704
|
+
copy.drawingColor = chartPaletteSeriesColorChoice(next, index3, chart.series.length);
|
|
22469
22705
|
delete copy.color;
|
|
22470
22706
|
}
|
|
22471
22707
|
if (radial && copy.pointColors) {
|
|
@@ -22573,8 +22809,8 @@ var DEFAULT_THEME_COLORS = [
|
|
|
22573
22809
|
"0563C1",
|
|
22574
22810
|
"954F72"
|
|
22575
22811
|
];
|
|
22576
|
-
function themeColor(theme2,
|
|
22577
|
-
const hex = theme2.colors[
|
|
22812
|
+
function themeColor(theme2, index3) {
|
|
22813
|
+
const hex = theme2.colors[index3] ?? DEFAULT_THEME_COLORS[index3];
|
|
22578
22814
|
return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
|
|
22579
22815
|
}
|
|
22580
22816
|
|
|
@@ -22670,18 +22906,18 @@ function mixColors(a2, b, t, rounding = "nearest") {
|
|
|
22670
22906
|
}
|
|
22671
22907
|
|
|
22672
22908
|
// xlsx/edit/chart-series-target.ts
|
|
22673
|
-
function chartSeriesAt(chart,
|
|
22674
|
-
const target = isSeriesPosition(chart,
|
|
22675
|
-
if (!target) throw new RangeError(`No chart series at index ${String(
|
|
22909
|
+
function chartSeriesAt(chart, index3) {
|
|
22910
|
+
const target = isSeriesPosition(chart, index3) ? chart.series.find((_, position) => position === index3) : void 0;
|
|
22911
|
+
if (!target) throw new RangeError(`No chart series at index ${String(index3)}`);
|
|
22676
22912
|
return target;
|
|
22677
22913
|
}
|
|
22678
|
-
function cloneChartSeriesForEdit(chart,
|
|
22679
|
-
chartSeriesAt(chart,
|
|
22914
|
+
function cloneChartSeriesForEdit(chart, index3) {
|
|
22915
|
+
chartSeriesAt(chart, index3);
|
|
22680
22916
|
const series = structuredClone(chart.series);
|
|
22681
|
-
return { series, target: series.find((_, position) => position ===
|
|
22917
|
+
return { series, target: series.find((_, position) => position === index3) };
|
|
22682
22918
|
}
|
|
22683
|
-
function isSeriesPosition(chart,
|
|
22684
|
-
return typeof
|
|
22919
|
+
function isSeriesPosition(chart, index3) {
|
|
22920
|
+
return typeof index3 === "number" && Number.isSafeInteger(index3) && index3 >= 0 && index3 < chart.series.length;
|
|
22685
22921
|
}
|
|
22686
22922
|
|
|
22687
22923
|
// xlsx/edit/chart-series-fill.ts
|
|
@@ -22697,8 +22933,8 @@ function chartDrawingColor(color) {
|
|
|
22697
22933
|
if (!Number.isFinite(tint) || tint < -1 || tint > 1) return void 0;
|
|
22698
22934
|
return tint !== 0 ? withDrawingColorBrightness(choice, tint * 100) : choice;
|
|
22699
22935
|
}
|
|
22700
|
-
function chartSeriesFillPatch(chart,
|
|
22701
|
-
const current = chartSeriesAt(chart,
|
|
22936
|
+
function chartSeriesFillPatch(chart, index3, color) {
|
|
22937
|
+
const current = chartSeriesAt(chart, index3);
|
|
22702
22938
|
const choice = color === null ? void 0 : chartDrawingColor(color);
|
|
22703
22939
|
if (color !== null && !choice) throw new RangeError("Invalid chart fill color");
|
|
22704
22940
|
const previous = current.fill?.kind === "solid" ? current.fill.color : current.drawingColor;
|
|
@@ -22710,27 +22946,27 @@ function chartSeriesFillPatch(chart, index2, color) {
|
|
|
22710
22946
|
) ?? []
|
|
22711
22947
|
)
|
|
22712
22948
|
);
|
|
22713
|
-
return replaceSeriesPaint(chart,
|
|
22949
|
+
return replaceSeriesPaint(chart, index3, choice);
|
|
22714
22950
|
}
|
|
22715
|
-
function chartSeriesSolidFillPatch(chart,
|
|
22716
|
-
const current = chartSeriesAt(chart,
|
|
22951
|
+
function chartSeriesSolidFillPatch(chart, index3) {
|
|
22952
|
+
const current = chartSeriesAt(chart, index3);
|
|
22717
22953
|
if (!current.fill || current.fill.kind === "solid") return void 0;
|
|
22718
22954
|
const choice = current.fill.kind === "gradient" ? current.fill.stops[0]?.color : void 0;
|
|
22719
22955
|
return replaceSeriesPaint(
|
|
22720
22956
|
chart,
|
|
22721
|
-
|
|
22957
|
+
index3,
|
|
22722
22958
|
choice ?? current.drawingColor ?? chartDrawingColor(current.color) ?? chartPaletteSeriesColorChoice(
|
|
22723
22959
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
22724
|
-
|
|
22960
|
+
index3,
|
|
22725
22961
|
chart.series.length
|
|
22726
22962
|
)
|
|
22727
22963
|
);
|
|
22728
22964
|
}
|
|
22729
|
-
function replaceSeriesPaint(chart,
|
|
22730
|
-
const current = chartSeriesAt(chart,
|
|
22965
|
+
function replaceSeriesPaint(chart, index3, choice) {
|
|
22966
|
+
const current = chartSeriesAt(chart, index3);
|
|
22731
22967
|
if (!Object.keys(current.pointColors ?? {}).length && !Object.keys(current.pointFills ?? {}).length && (!choice ? current.fill?.kind === "none" : !current.fill && sameChartColor(current.drawingColor, choice)))
|
|
22732
22968
|
return void 0;
|
|
22733
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
22969
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
22734
22970
|
delete next.fill;
|
|
22735
22971
|
delete next.color;
|
|
22736
22972
|
delete next.drawingColor;
|
|
@@ -22874,18 +23110,18 @@ var PackageWriter = class {
|
|
|
22874
23110
|
var rank2 = (name) => name === "_rels/.rels" ? 0 : name.startsWith("docProps/") ? 1 : name === "xl/workbook.xml" ? 2 : 3;
|
|
22875
23111
|
|
|
22876
23112
|
// xlsx/write/chart-colors.ts
|
|
22877
|
-
function chartSeriesFill(chart, series,
|
|
23113
|
+
function chartSeriesFill(chart, series, index3) {
|
|
22878
23114
|
const imported = series.fill && drawingFillXml(series.fill);
|
|
22879
23115
|
if (imported) return imported;
|
|
22880
|
-
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series,
|
|
23116
|
+
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series, index3))}</a:solidFill>`;
|
|
22881
23117
|
}
|
|
22882
|
-
function chartSeriesDrawingFill(chart, series,
|
|
23118
|
+
function chartSeriesDrawingFill(chart, series, index3) {
|
|
22883
23119
|
if (series.fill && drawingFillXml(series.fill)) return series.fill;
|
|
22884
|
-
return { kind: "solid", color: chartSeriesColor(chart, series,
|
|
23120
|
+
return { kind: "solid", color: chartSeriesColor(chart, series, index3) };
|
|
22885
23121
|
}
|
|
22886
|
-
function chartSeriesColor(chart, series,
|
|
23122
|
+
function chartSeriesColor(chart, series, index3) {
|
|
22887
23123
|
const palette = findChartColorPalette(chart.colorPalette ?? 10);
|
|
22888
|
-
return series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(palette ?? findChartColorPalette(10),
|
|
23124
|
+
return series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(palette ?? findChartColorPalette(10), index3, chart.series.length);
|
|
22889
23125
|
}
|
|
22890
23126
|
function recolorMarker(marker3, previous, next) {
|
|
22891
23127
|
for (const paint of [marker3, first(marker3, "ln", NS.a)]) {
|
|
@@ -22903,10 +23139,10 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
22903
23139
|
const palette = findChartColorPalette(model.colorPalette ?? 10);
|
|
22904
23140
|
const lineLike = ["line", "scatter", "radar"].includes(model.chartType);
|
|
22905
23141
|
const markerOnly = model.chartType === "scatter" && first(plot2, "scatterStyle", NS.c)?.getAttribute("val") === "marker";
|
|
22906
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
22907
|
-
const series = model.series[
|
|
23142
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
23143
|
+
const series = model.series[index3];
|
|
22908
23144
|
if (!series) return;
|
|
22909
|
-
const old = before.series[
|
|
23145
|
+
const old = before.series[index3];
|
|
22910
23146
|
if (old?.effectsXml !== series.effectsXml) {
|
|
22911
23147
|
let shape2 = first(ser, "spPr", NS.c);
|
|
22912
23148
|
if (!shape2 && series.effectsXml) {
|
|
@@ -22952,12 +23188,12 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
22952
23188
|
paint = doc.createElementNS(NS.a, "a:ln");
|
|
22953
23189
|
spPr.appendChild(paint);
|
|
22954
23190
|
}
|
|
22955
|
-
setDrawingFillXml(paint, chartSeriesFill(model, series,
|
|
23191
|
+
setDrawingFillXml(paint, chartSeriesFill(model, series, index3));
|
|
22956
23192
|
}
|
|
22957
23193
|
if (previousPalette && palette && before.colorPalette !== model.colorPalette) {
|
|
22958
23194
|
const marker3 = first(first(ser, "marker", NS.c), "spPr", NS.c);
|
|
22959
|
-
const previous = chartPaletteSeriesColorChoice(previousPalette,
|
|
22960
|
-
const next = chartPaletteSeriesColorChoice(palette,
|
|
23195
|
+
const previous = chartPaletteSeriesColorChoice(previousPalette, index3, model.series.length);
|
|
23196
|
+
const next = chartPaletteSeriesColorChoice(palette, index3, model.series.length);
|
|
22961
23197
|
recolorMarker(marker3, previous, next);
|
|
22962
23198
|
for (const point of children(ser, "dPt", NS.c))
|
|
22963
23199
|
recolorMarker(first(first(point, "marker", NS.c), "spPr", NS.c), previous, next);
|
|
@@ -23052,7 +23288,7 @@ var FIRST_AXIS = 500000001;
|
|
|
23052
23288
|
var SECOND_AXIS = 500000002;
|
|
23053
23289
|
function source(kind, formula, values2) {
|
|
23054
23290
|
const points = values2.flatMap(
|
|
23055
|
-
(value2,
|
|
23291
|
+
(value2, index3) => value2 === null || value2 === "" ? [] : [{ index: index3, value: String(value2) }]
|
|
23056
23292
|
);
|
|
23057
23293
|
return {
|
|
23058
23294
|
kind: formula ? kind === "str" ? "strRef" : "numRef" : kind === "str" ? "strLit" : "numLit",
|
|
@@ -23085,9 +23321,9 @@ function dataPoints(series) {
|
|
|
23085
23321
|
return /^\d+$/.test(key) && paint ? [{ index: Number(key), spPr: { fill: paint } }] : [];
|
|
23086
23322
|
});
|
|
23087
23323
|
}
|
|
23088
|
-
function seriesModel(chart, series,
|
|
23324
|
+
function seriesModel(chart, series, index3) {
|
|
23089
23325
|
const type = chart.chartType;
|
|
23090
|
-
const out = { index:
|
|
23326
|
+
const out = { index: index3, order: index3, dataPoints: dataPoints(series) };
|
|
23091
23327
|
if (series.nameRef)
|
|
23092
23328
|
out.tx = {
|
|
23093
23329
|
reference: source("str", series.nameRef, series.name === void 0 ? [] : [series.name])
|
|
@@ -23096,7 +23332,7 @@ function seriesModel(chart, series, index2) {
|
|
|
23096
23332
|
const lineLike = type === "line" || type === "scatter" || type === "radar";
|
|
23097
23333
|
const effectsXml = effects(series);
|
|
23098
23334
|
if (type !== "pie" && type !== "doughnut" || series.fill || series.color || series.drawingColor || effectsXml) {
|
|
23099
|
-
const fill = chartSeriesDrawingFill(chart, series,
|
|
23335
|
+
const fill = chartSeriesDrawingFill(chart, series, index3);
|
|
23100
23336
|
const shape2 = lineLike ? { line: { widthEmu: 28575, cap: "rnd", fill } } : { fill };
|
|
23101
23337
|
if (effectsXml) shape2.effectsXml = effectsXml;
|
|
23102
23338
|
out.spPr = shape2;
|
|
@@ -23220,7 +23456,7 @@ function style(chart) {
|
|
|
23220
23456
|
return id > 100 ? { c14Style: id, style: id - 100 } : { style: id };
|
|
23221
23457
|
}
|
|
23222
23458
|
function chartSpaceFromObject(chart) {
|
|
23223
|
-
const series = chart.series.map((entry3,
|
|
23459
|
+
const series = chart.series.map((entry3, index3) => seriesModel(chart, entry3, index3));
|
|
23224
23460
|
const [group, chartAxes] = plot(chart, series);
|
|
23225
23461
|
const space = {
|
|
23226
23462
|
roundedCorners: false,
|
|
@@ -23261,8 +23497,8 @@ function patchChartReferences(xml, chart) {
|
|
|
23261
23497
|
changed = true;
|
|
23262
23498
|
}
|
|
23263
23499
|
};
|
|
23264
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
23265
|
-
const model = chart.series[
|
|
23500
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
23501
|
+
const model = chart.series[index3];
|
|
23266
23502
|
if (!model) return;
|
|
23267
23503
|
setRef(first(ser, "tx", NS.c), model.nameRef);
|
|
23268
23504
|
setRef(first(ser, "cat", NS.c) ?? first(ser, "xVal", NS.c), model.categoriesRef);
|
|
@@ -23569,14 +23805,14 @@ function shiftSpan(start, end, shift2) {
|
|
|
23569
23805
|
const e = end >= max ? max : end < at ? end : end > last ? end - n2 : at - 1;
|
|
23570
23806
|
return s > e ? void 0 : { start: s, end: e };
|
|
23571
23807
|
}
|
|
23572
|
-
function shiftIndex(
|
|
23808
|
+
function shiftIndex(index3, shift2) {
|
|
23573
23809
|
const { at, count: count2 } = shift2;
|
|
23574
|
-
if (
|
|
23575
|
-
if (count2 > 0) return
|
|
23576
|
-
return
|
|
23810
|
+
if (index3 < at) return index3;
|
|
23811
|
+
if (count2 > 0) return index3 + count2 > axisMax(shift2.axis) ? void 0 : index3 + count2;
|
|
23812
|
+
return index3 < at - count2 ? void 0 : index3 + count2;
|
|
23577
23813
|
}
|
|
23578
|
-
function shiftIndexClamped(
|
|
23579
|
-
const moved = shiftIndex(
|
|
23814
|
+
function shiftIndexClamped(index3, shift2) {
|
|
23815
|
+
const moved = shiftIndex(index3, shift2);
|
|
23580
23816
|
if (moved !== void 0) return moved;
|
|
23581
23817
|
return shift2.count > 0 ? axisMax(shift2.axis) : shift2.at;
|
|
23582
23818
|
}
|
|
@@ -24067,9 +24303,9 @@ function readSourceStyles(xml) {
|
|
|
24067
24303
|
(node) => inlineFragment(outerXml(node))
|
|
24068
24304
|
);
|
|
24069
24305
|
const dxfKeys = /* @__PURE__ */ new Map();
|
|
24070
|
-
parseStyles(xml, []).dxfs.forEach((dxf,
|
|
24306
|
+
parseStyles(xml, []).dxfs.forEach((dxf, index3) => {
|
|
24071
24307
|
const key = styleKey(dxf);
|
|
24072
|
-
if (!dxfKeys.has(key)) dxfKeys.set(key,
|
|
24308
|
+
if (!dxfKeys.has(key)) dxfKeys.set(key, index3);
|
|
24073
24309
|
});
|
|
24074
24310
|
const result2 = { numFmts, dxfXml, dxfKeys };
|
|
24075
24311
|
const tableStyles = xFirst(root, "tableStyles");
|
|
@@ -24177,7 +24413,7 @@ var StyleWriter = class {
|
|
|
24177
24413
|
});
|
|
24178
24414
|
const seen = /* @__PURE__ */ new Set();
|
|
24179
24415
|
const unique2 = named2.filter((entry3) => !seen.has(entry3.name) && seen.add(entry3.name));
|
|
24180
|
-
const xfIdOf = new Map(unique2.map((entry3,
|
|
24416
|
+
const xfIdOf = new Map(unique2.map((entry3, index3) => [entry3.name, index3]));
|
|
24181
24417
|
const base = this.workbook.styles[0] ?? defaultCellStyle();
|
|
24182
24418
|
this.fonts.id(fontXml(base.font));
|
|
24183
24419
|
this.borders.id(borderXml({}));
|
|
@@ -24186,7 +24422,7 @@ var StyleWriter = class {
|
|
|
24186
24422
|
(style2) => this.xf(style2, xfIdOf.get(style2.cellStyleName ?? "Normal") ?? 0)
|
|
24187
24423
|
);
|
|
24188
24424
|
const cellStyles = unique2.map(
|
|
24189
|
-
(entry3,
|
|
24425
|
+
(entry3, index3) => el("cellStyle", { name: entry3.name, xfId: index3, builtinId: entry3.builtinId })
|
|
24190
24426
|
);
|
|
24191
24427
|
const custom = [...this.numFmts].filter(([code]) => builtinFormatIdOf(code) === void 0).sort((a2, b) => a2[1] - b[1]);
|
|
24192
24428
|
let out = `${XML_HEADER}<styleSheet xmlns="${NS.x}" xmlns:mc="${NS.mc}" mc:Ignorable="x14ac" xmlns:x14ac="${NS.x14ac}">`;
|
|
@@ -24351,13 +24587,13 @@ function definedNamesOf(workbook) {
|
|
|
24351
24587
|
const names = workbook.definedNames.filter(
|
|
24352
24588
|
(name) => name.name && (name.localSheet === void 0 || name.localSheet >= 0 && name.localSheet < workbook.sheets.length)
|
|
24353
24589
|
);
|
|
24354
|
-
workbook.sheets.forEach((sheet,
|
|
24590
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
24355
24591
|
const area = sheet.pageSetup?.printArea;
|
|
24356
|
-
if (!area || names.some((n2) => n2.name === "_xlnm.Print_Area" && n2.localSheet ===
|
|
24592
|
+
if (!area || names.some((n2) => n2.name === "_xlnm.Print_Area" && n2.localSheet === index3)) return;
|
|
24357
24593
|
names.push({
|
|
24358
24594
|
name: "_xlnm.Print_Area",
|
|
24359
24595
|
formula: `${quoteSheetName(sheet.name)}!${absoluteRange(area)}`,
|
|
24360
|
-
localSheet:
|
|
24596
|
+
localSheet: index3
|
|
24361
24597
|
});
|
|
24362
24598
|
});
|
|
24363
24599
|
return names;
|
|
@@ -24802,8 +25038,8 @@ function extent(values2) {
|
|
|
24802
25038
|
function sparklineValues(group, values2) {
|
|
24803
25039
|
return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
|
|
24804
25040
|
}
|
|
24805
|
-
function sparklineScale(group, all2,
|
|
24806
|
-
const own = extent(sparklineValues(group, all2[
|
|
25041
|
+
function sparklineScale(group, all2, index3) {
|
|
25042
|
+
const own = extent(sparklineValues(group, all2[index3]?.values ?? []));
|
|
24807
25043
|
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
24808
25044
|
const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
|
|
24809
25045
|
const end = (type, manual, key) => {
|
|
@@ -24921,17 +25157,17 @@ var MAX_POINTS = 1e4;
|
|
|
24921
25157
|
var hostIndex = /* @__PURE__ */ new WeakMap();
|
|
24922
25158
|
function hosts(sheet) {
|
|
24923
25159
|
const groups = sheetSparklineGroups(sheet);
|
|
24924
|
-
let
|
|
24925
|
-
if (!
|
|
24926
|
-
|
|
25160
|
+
let index3 = hostIndex.get(groups);
|
|
25161
|
+
if (!index3) {
|
|
25162
|
+
index3 = /* @__PURE__ */ new Map();
|
|
24927
25163
|
for (const group of groups)
|
|
24928
25164
|
group.sparklines.forEach((line3, i2) => {
|
|
24929
25165
|
const key = cellKey(line3.host.start.row, line3.host.start.col);
|
|
24930
|
-
if (!
|
|
25166
|
+
if (!index3.has(key)) index3.set(key, { group, index: i2 });
|
|
24931
25167
|
});
|
|
24932
|
-
hostIndex.set(groups,
|
|
25168
|
+
hostIndex.set(groups, index3);
|
|
24933
25169
|
}
|
|
24934
|
-
return
|
|
25170
|
+
return index3;
|
|
24935
25171
|
}
|
|
24936
25172
|
function hasSparklineAt(sheet, row2, col) {
|
|
24937
25173
|
return hosts(sheet).has(cellKey(row2, col));
|
|
@@ -24997,10 +25233,10 @@ function sparklineViewAt(workbook, sheetIndex2, row2, col) {
|
|
|
24997
25233
|
if (!sheet) return void 0;
|
|
24998
25234
|
const entry3 = hosts(sheet).get(cellKey(row2, col));
|
|
24999
25235
|
if (!entry3) return void 0;
|
|
25000
|
-
const { group, index:
|
|
25236
|
+
const { group, index: index3 } = entry3;
|
|
25001
25237
|
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
25002
|
-
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[
|
|
25003
|
-
const at = needsGroup ?
|
|
25238
|
+
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index3]] });
|
|
25239
|
+
const at = needsGroup ? index3 : 0;
|
|
25004
25240
|
return sparklineView(
|
|
25005
25241
|
group,
|
|
25006
25242
|
data[at] ?? { values: [] },
|
|
@@ -25165,9 +25401,9 @@ function sourceColumnsForPatch(root, table2, names) {
|
|
|
25165
25401
|
const byName = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
25166
25402
|
const tracked = table2.partName !== void 0 || table2.columns.some((c2) => c2.sourceId !== void 0);
|
|
25167
25403
|
const used = /* @__PURE__ */ new Set();
|
|
25168
|
-
return names.map((name,
|
|
25169
|
-
const id = table2.columns[
|
|
25170
|
-
const match2 = id !== void 0 ? byId2.get(id) : tracked ? void 0 : source2.length === names.length ? source2[
|
|
25404
|
+
return names.map((name, index3) => {
|
|
25405
|
+
const id = table2.columns[index3]?.sourceId;
|
|
25406
|
+
const match2 = id !== void 0 ? byId2.get(id) : tracked ? void 0 : source2.length === names.length ? source2[index3] : byName.get(name.toLowerCase());
|
|
25171
25407
|
if (!match2 || used.has(match2)) return void 0;
|
|
25172
25408
|
used.add(match2);
|
|
25173
25409
|
return match2;
|
|
@@ -25184,12 +25420,12 @@ function patchAutoFilter(doc, root, table2, before, names) {
|
|
|
25184
25420
|
filter2.setAttribute("ref", formatRange(range));
|
|
25185
25421
|
const list = xKid(root, "tableColumns");
|
|
25186
25422
|
const original = list ? xKids(list, "tableColumn") : [];
|
|
25187
|
-
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2,
|
|
25423
|
+
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2, index3) => [c2, index3]));
|
|
25188
25424
|
for (const column of xKids(filter2, "filterColumn")) {
|
|
25189
25425
|
const old = original[Number(column.getAttribute("colId") ?? "0")];
|
|
25190
|
-
const
|
|
25191
|
-
if (
|
|
25192
|
-
else column.setAttribute("colId", num2(
|
|
25426
|
+
const index3 = old ? current.get(old) : void 0;
|
|
25427
|
+
if (index3 === void 0) filter2.removeChild(column);
|
|
25428
|
+
else column.setAttribute("colId", num2(index3));
|
|
25193
25429
|
}
|
|
25194
25430
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
25195
25431
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
@@ -25234,11 +25470,11 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
25234
25470
|
for (const column of sourceColumns) list.removeChild(column);
|
|
25235
25471
|
let nextId = Math.max(0, ...ids) + 1;
|
|
25236
25472
|
const totalsRow = table2.range.end.row;
|
|
25237
|
-
names.forEach((name,
|
|
25238
|
-
const column = picked[
|
|
25473
|
+
names.forEach((name, index3) => {
|
|
25474
|
+
const column = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
25239
25475
|
if (!column.getAttribute("id")) column.setAttribute("id", num2(nextId++));
|
|
25240
25476
|
column.setAttribute("name", name);
|
|
25241
|
-
const model = table2.columns[
|
|
25477
|
+
const model = table2.columns[index3];
|
|
25242
25478
|
const fn = table2.totalsRow ? model?.totalsRowFunction : void 0;
|
|
25243
25479
|
setOrRemove(column, "totalsRowFunction", fn);
|
|
25244
25480
|
setOrRemove(column, "totalsRowLabel", table2.totalsRow ? model?.totalsRowLabel : void 0);
|
|
@@ -25252,7 +25488,7 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
25252
25488
|
);
|
|
25253
25489
|
if (fn !== "custom") setChildText(doc, column, "totalsRowFormula", void 0, []);
|
|
25254
25490
|
else {
|
|
25255
|
-
const cellFormula = sheet.rows.get(totalsRow)?.get(table2.range.start.col +
|
|
25491
|
+
const cellFormula = sheet.rows.get(totalsRow)?.get(table2.range.start.col + index3)?.formula;
|
|
25256
25492
|
if (cellFormula)
|
|
25257
25493
|
setChildText(
|
|
25258
25494
|
doc,
|
|
@@ -25333,11 +25569,11 @@ function tableXml(table2, id, names) {
|
|
|
25333
25569
|
const range = formatRange(table2.range);
|
|
25334
25570
|
const filterEnd = { ...table2.range.end, row: table2.range.end.row - (table2.totalsRow ? 1 : 0) };
|
|
25335
25571
|
const filter2 = table2.headerRow && !table2.totalsRow ? `<autoFilter ref="${range}"/>` : table2.headerRow ? `<autoFilter ref="${formatRange({ start: table2.range.start, end: filterEnd })}"/>` : "";
|
|
25336
|
-
const columns = names.map((name,
|
|
25337
|
-
const column = table2.columns[
|
|
25572
|
+
const columns = names.map((name, index3) => {
|
|
25573
|
+
const column = table2.columns[index3];
|
|
25338
25574
|
const calculated = column?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText2(addFuturePrefixes(column.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
25339
25575
|
const values2 = attrs({
|
|
25340
|
-
id:
|
|
25576
|
+
id: index3 + 1,
|
|
25341
25577
|
name,
|
|
25342
25578
|
totalsRowFunction: table2.totalsRow ? column?.totalsRowFunction : void 0,
|
|
25343
25579
|
totalsRowLabel: table2.totalsRow ? column?.totalsRowLabel : void 0
|
|
@@ -25376,27 +25612,27 @@ function totalsRowFormulas(sheet, table2, names) {
|
|
|
25376
25612
|
const out = /* @__PURE__ */ new Map();
|
|
25377
25613
|
if (!table2.totalsRow) return out;
|
|
25378
25614
|
const row2 = table2.range.end.row;
|
|
25379
|
-
names.forEach((name,
|
|
25380
|
-
const code = SUBTOTAL_CODES[table2.columns[
|
|
25615
|
+
names.forEach((name, index3) => {
|
|
25616
|
+
const code = SUBTOTAL_CODES[table2.columns[index3]?.totalsRowFunction ?? ""];
|
|
25381
25617
|
if (code === void 0) return;
|
|
25382
|
-
const col = table2.range.start.col +
|
|
25618
|
+
const col = table2.range.start.col + index3;
|
|
25383
25619
|
const escaped = name.replace(/['#[\]]/g, "'$&");
|
|
25384
25620
|
const formula = `SUBTOTAL(${code},${table2.displayName || table2.name}[${escaped}])`;
|
|
25385
25621
|
if (sheet.rows.get(row2)?.get(col)?.formula !== formula) out.set(`${row2}:${col}`, formula);
|
|
25386
25622
|
});
|
|
25387
25623
|
return out;
|
|
25388
25624
|
}
|
|
25389
|
-
function resolveTableNames(table2, before,
|
|
25625
|
+
function resolveTableNames(table2, before, index3) {
|
|
25390
25626
|
const display = table2.displayName || table2.name;
|
|
25391
|
-
const displayName = before && before.displayName === display ? display : safeTableName(display,
|
|
25392
|
-
const name = before && before.name === table2.name ? table2.name : table2.name === display ? displayName : safeTableName(table2.name,
|
|
25627
|
+
const displayName = before && before.displayName === display ? display : safeTableName(display, index3);
|
|
25628
|
+
const name = before && before.name === table2.name ? table2.name : table2.name === display ? displayName : safeTableName(table2.name, index3);
|
|
25393
25629
|
return { name, displayName };
|
|
25394
25630
|
}
|
|
25395
|
-
function safeTableName(name,
|
|
25631
|
+
function safeTableName(name, index3) {
|
|
25396
25632
|
const valid = /^[A-Za-z_\\][A-Za-z0-9_.\\]*$/.test(name) && !/^[A-Za-z]{1,3}\d+$/.test(name) && !/^[RrCc]$/.test(name) && !/^[Rr]\d*[Cc]\d*$/.test(name) && name.length <= 255;
|
|
25397
25633
|
if (valid) return name;
|
|
25398
25634
|
const cleaned = name.replace(/[^A-Za-z0-9_.]/g, "_");
|
|
25399
|
-
return `Table_${cleaned ||
|
|
25635
|
+
return `Table_${cleaned || index3}`;
|
|
25400
25636
|
}
|
|
25401
25637
|
|
|
25402
25638
|
// xlsx/write/sheet-parts.ts
|
|
@@ -25409,7 +25645,7 @@ function sourceRelIds(source2, partName) {
|
|
|
25409
25645
|
if (legacy) out.legacy = legacy;
|
|
25410
25646
|
return out;
|
|
25411
25647
|
}
|
|
25412
|
-
function writeComments(ctx, sheet,
|
|
25648
|
+
function writeComments(ctx, sheet, index3, partName, rels) {
|
|
25413
25649
|
const { writer, source: source2 } = ctx;
|
|
25414
25650
|
const name = (pattern) => writer.uniqueName(pattern, ctx.reserved);
|
|
25415
25651
|
const fromSource = source2 && sheet.partName && source2.has(sheet.partName);
|
|
@@ -25454,8 +25690,8 @@ function writeComments(ctx, sheet, index2, partName, rels) {
|
|
|
25454
25690
|
}
|
|
25455
25691
|
}
|
|
25456
25692
|
const own = base ? vmlIdmapBlocks(base) : [];
|
|
25457
|
-
const layout2 = vmlAllocatorFor(ctx, source2).allocate(sheet.comments.length,
|
|
25458
|
-
const parts = commentParts(sheet.comments,
|
|
25693
|
+
const layout2 = vmlAllocatorFor(ctx, source2).allocate(sheet.comments.length, index3 + 1, own);
|
|
25694
|
+
const parts = commentParts(sheet.comments, index3 + 1, ctx.persons, sheet.name, {
|
|
25459
25695
|
...layout2,
|
|
25460
25696
|
...base ? { base } : {}
|
|
25461
25697
|
});
|
|
@@ -25477,11 +25713,11 @@ function sourceVmlPart(source2, sheetPart) {
|
|
|
25477
25713
|
}
|
|
25478
25714
|
function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
25479
25715
|
const ids = [];
|
|
25480
|
-
for (const [
|
|
25716
|
+
for (const [index3, original] of sheet.tables.entries()) {
|
|
25481
25717
|
const { writer, source: source2 } = ctx;
|
|
25482
25718
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
25483
25719
|
const before = sourceXml && original.partName ? parseTable(sourceXml, original.partName) : void 0;
|
|
25484
|
-
const { name, displayName } = resolveTableNames(original, before,
|
|
25720
|
+
const { name, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
25485
25721
|
const table2 = name === original.name && displayName === original.displayName ? original : { ...original, name, displayName };
|
|
25486
25722
|
const { names, headerText: forced } = resolveTableColumns(sheet, table2);
|
|
25487
25723
|
for (const [key, text3] of forced) headerText.set(key, text3);
|
|
@@ -25763,7 +25999,7 @@ var REGENERATED = /* @__PURE__ */ new Set([
|
|
|
25763
25999
|
]);
|
|
25764
26000
|
var NS_XR2 = "http://schemas.microsoft.com/office/spreadsheetml/2015/revision2";
|
|
25765
26001
|
var NS_XR3 = "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3";
|
|
25766
|
-
function writeWorksheet(ctx, sheet,
|
|
26002
|
+
function writeWorksheet(ctx, sheet, index3, partName) {
|
|
25767
26003
|
const { writer, source: source2 } = ctx;
|
|
25768
26004
|
const rels = new RelationshipSet();
|
|
25769
26005
|
let sourceDrawing;
|
|
@@ -25786,7 +26022,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
25786
26022
|
const tableParts = writeTables(ctx, sheet, partName, rels, headerText, formulas);
|
|
25787
26023
|
blocks.set("sheetPr", sheetPrXml(sheet));
|
|
25788
26024
|
blocks.set("dimension", dimensionXml(sheet));
|
|
25789
|
-
blocks.set("sheetViews", sheetViewsXml(sheet,
|
|
26025
|
+
blocks.set("sheetViews", sheetViewsXml(sheet, index3 === ctx.workbook.activeSheet));
|
|
25790
26026
|
blocks.set("sheetFormatPr", sheetFormatXml(sheet));
|
|
25791
26027
|
blocks.set("cols", colsXml(sheet, ctx.workbook.styles.length));
|
|
25792
26028
|
blocks.set(
|
|
@@ -25825,7 +26061,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
25825
26061
|
);
|
|
25826
26062
|
blocks.set("headerFooter", page.headerFooter);
|
|
25827
26063
|
blocks.set("drawing", writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing));
|
|
25828
|
-
blocks.set("legacyDrawing", writeComments(ctx, sheet,
|
|
26064
|
+
blocks.set("legacyDrawing", writeComments(ctx, sheet, index3, partName, rels));
|
|
25829
26065
|
blocks.set("tableParts", tableParts);
|
|
25830
26066
|
ctx.pivots?.writeSheet(writer, sheet, partName, rels);
|
|
25831
26067
|
blocks.set("extLst", conditionalExtensionsXml(sheet));
|
|
@@ -25850,12 +26086,12 @@ function pivotCacheData(pivot) {
|
|
|
25850
26086
|
const items = pivot.fields.map(() => []);
|
|
25851
26087
|
const indices = pivot.fields.map(() => /* @__PURE__ */ new Map());
|
|
25852
26088
|
for (const record of pivot.records)
|
|
25853
|
-
pivot.fields.forEach((_field,
|
|
25854
|
-
const value2 = record[
|
|
26089
|
+
pivot.fields.forEach((_field, index3) => {
|
|
26090
|
+
const value2 = record[index3] ?? null;
|
|
25855
26091
|
const key = pivotValueKey(value2);
|
|
25856
|
-
if (!indices[
|
|
25857
|
-
indices[
|
|
25858
|
-
items[
|
|
26092
|
+
if (!indices[index3].has(key)) {
|
|
26093
|
+
indices[index3].set(key, items[index3].length);
|
|
26094
|
+
items[index3].push(value2);
|
|
25859
26095
|
}
|
|
25860
26096
|
});
|
|
25861
26097
|
return { items, indices };
|
|
@@ -25870,8 +26106,8 @@ function valueXml(value2) {
|
|
|
25870
26106
|
}
|
|
25871
26107
|
function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
25872
26108
|
const source2 = sparklineDataRange(workbook, 0, pivot.source);
|
|
25873
|
-
const fields = pivot.fields.map((name,
|
|
25874
|
-
const items = data.items[
|
|
26109
|
+
const fields = pivot.fields.map((name, index3) => {
|
|
26110
|
+
const items = data.items[index3];
|
|
25875
26111
|
const types = new Set(
|
|
25876
26112
|
items.map((value2) => value2 === null || value2 === "" ? "blank" : typeof value2)
|
|
25877
26113
|
);
|
|
@@ -25883,7 +26119,7 @@ function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
|
25883
26119
|
}
|
|
25884
26120
|
function pivotCacheRecordsXml(pivot, data) {
|
|
25885
26121
|
const records = pivot.records.map(
|
|
25886
|
-
(record) => `<r>${pivot.fields.map((_field,
|
|
26122
|
+
(record) => `<r>${pivot.fields.map((_field, index3) => `<x v="${data.indices[index3].get(pivotValueKey(record[index3] ?? null))}"/>`).join("")}</r>`
|
|
25887
26123
|
).join("");
|
|
25888
26124
|
return `${XML_HEADER}<pivotCacheRecords xmlns="${NS.x}" count="${pivot.records.length}">${records}</pivotCacheRecords>`;
|
|
25889
26125
|
}
|
|
@@ -25893,6 +26129,19 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25893
26129
|
const grid = pivotGrid(pivot);
|
|
25894
26130
|
const row2 = pivot.fields.indexOf(pivot.rowField);
|
|
25895
26131
|
const second = pivot.secondRowField ? pivot.fields.indexOf(pivot.secondRowField) : -1;
|
|
26132
|
+
const page = pivot.pageFilter ? pivot.fields.indexOf(pivot.pageFilter.field) : -1;
|
|
26133
|
+
const pageItems = page >= 0 ? pivotItems(pivot, pivot.pageFilter.field) : [];
|
|
26134
|
+
const axisItems = (field, visible) => page >= 0 ? pivotItems(pivot, field) : visible;
|
|
26135
|
+
const rowItemsFull = axisItems(pivot.rowField, grid.rowItems);
|
|
26136
|
+
const secondRowItemsFull = pivot.secondRowField ? axisItems(pivot.secondRowField, grid.secondRowItems) : [];
|
|
26137
|
+
const columnItemsFull = pivot.columnField ? axisItems(pivot.columnField, grid.columnItems) : [];
|
|
26138
|
+
const itemIndices = (visible, full) => {
|
|
26139
|
+
const indices = new Map(full.map((item, index3) => [pivotValueKey(item), index3]));
|
|
26140
|
+
return visible.map((v) => indices.get(pivotValueKey(v)));
|
|
26141
|
+
};
|
|
26142
|
+
const rowIndicesFull = itemIndices(grid.rowItems, rowItemsFull), secondRowIndicesFull = itemIndices(grid.secondRowItems ?? [], secondRowItemsFull), columnIndicesFull = itemIndices(grid.columnItems, columnItemsFull);
|
|
26143
|
+
const rowEntries = page >= 0 && grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, [rowIndicesFull, secondRowIndicesFull]) : grid.rowEntries;
|
|
26144
|
+
const pageOffset = page >= 0 ? 2 : 0;
|
|
25896
26145
|
const col = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
25897
26146
|
const measures = pivotMeasures(pivot);
|
|
25898
26147
|
const multiple = measures.length > 1;
|
|
@@ -25900,32 +26149,34 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25900
26149
|
const compact3 = pivot.layout === "compact";
|
|
25901
26150
|
const outline = pivot.layout === "compact" || pivot.layout === "outline";
|
|
25902
26151
|
const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
|
|
25903
|
-
const fields = pivot.fields.map((_field,
|
|
25904
|
-
const items2 =
|
|
25905
|
-
const subtotal = !(
|
|
25906
|
-
const repeated = pivot.repeatLabels && (
|
|
25907
|
-
return `<pivotField${attrs({ axis:
|
|
26152
|
+
const fields = pivot.fields.map((_field, index3) => {
|
|
26153
|
+
const items2 = index3 === page ? pageItems : index3 === row2 ? rowItemsFull : index3 === second ? secondRowItemsFull : index3 === col ? columnItemsFull : void 0;
|
|
26154
|
+
const subtotal = !(index3 === row2 && pivot.subtotals === false);
|
|
26155
|
+
const repeated = pivot.repeatLabels && (index3 === row2 || index3 === second) ? '<extLst><ext uri="{2946ED86-A175-432a-8AC1-64E0C546D7DE}"><x14:pivotField xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" fillDownLabels="1"/></ext></extLst>' : "";
|
|
26156
|
+
return `<pivotField${attrs({ axis: index3 === page ? "axisPage" : index3 === row2 || index3 === second ? "axisRow" : index3 === col ? "axisCol" : void 0, dataField: measures.some((measure) => pivot.fields.indexOf(measure.field) === index3) ? true : void 0, compact: compact3, outline, showAll: false, subtotalTop: index3 === row2 ? top : void 0, defaultSubtotal: subtotal ? void 0 : false })}>${items2 ? `<items count="${items2.length + Number(subtotal)}">${items2.map((item) => `<item x="${cache3.indices[index3].get(pivotValueKey(item))}"/>`).join("")}${subtotal ? '<item t="default"/>' : ""}</items>` : ""}${repeated}</pivotField>`;
|
|
25908
26157
|
}).join("");
|
|
25909
|
-
const items = (count2) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
25910
|
-
const header = grid.firstHeaderRow
|
|
26158
|
+
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
26159
|
+
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : multiple && col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
25911
26160
|
const rowIndices = rowsAxis && pivot.valuesPosition === "first" ? [-2, row2, second] : rowsAxis && pivot.valuesPosition === "between" ? [row2, -2, second] : [row2, ...second >= 0 ? [second] : [], ...rowsAxis ? [-2] : []];
|
|
25912
26161
|
let previous = [];
|
|
25913
|
-
const rowItems =
|
|
26162
|
+
const rowItems = rowEntries?.map((entry3) => {
|
|
25914
26163
|
let prefix = 0;
|
|
25915
26164
|
if (entry3.type === "default" && rowsAxis && pivot.valuesPosition === "first") prefix = 1;
|
|
25916
26165
|
else if (!entry3.type)
|
|
25917
26166
|
while (prefix < entry3.indices.length - 1 && entry3.indices[prefix] === previous[prefix])
|
|
25918
26167
|
prefix++;
|
|
25919
26168
|
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
25920
|
-
return `<i${attrs({ t: entry3.type, r: prefix || void 0, i: entry3.measure || void 0 })}>${entry3.indices.slice(prefix).map((
|
|
25921
|
-
}).join("") ?? items(grid.rowItems.length);
|
|
25922
|
-
let body = `<location${attrs({ ref: formatRange(pivot.location), firstHeaderRow: header, firstDataRow: grid.firstDataRow, firstDataCol: grid.rowLabelColumns ?? 1 })}/><pivotFields count="${pivot.fields.length}">${fields}</pivotFields><rowFields count="${rowIndices.length}">${rowIndices.map((
|
|
26169
|
+
return `<i${attrs({ t: entry3.type, r: prefix || void 0, i: entry3.measure || void 0 })}>${entry3.indices.slice(prefix).map((index3) => `<x${attrs({ v: index3 || void 0 })}/>`).join("")}</i>`;
|
|
26170
|
+
}).join("") ?? items(grid.rowItems.length, rowIndicesFull);
|
|
26171
|
+
let body = `<location${attrs({ ref: formatRange({ ...pivot.location, start: { ...pivot.location.start, row: pivot.location.start.row + pageOffset } }), firstHeaderRow: header, firstDataRow: grid.firstDataRow - pageOffset, rowPageCount: page >= 0 ? 1 : void 0, colPageCount: page >= 0 ? 1 : void 0, firstDataCol: grid.rowLabelColumns ?? 1 })}/><pivotFields count="${pivot.fields.length}">${fields}</pivotFields><rowFields count="${rowIndices.length}">${rowIndices.map((index3) => `<field x="${index3}"/>`).join("")}</rowFields><rowItems count="${grid.rowEntries?.length ?? grid.rowItems.length + 1}">${rowItems}</rowItems>`;
|
|
25923
26172
|
if (multiple && !rowsAxis)
|
|
25924
|
-
body += `<colFields count="${col >= 0 ? 2 : 1}">${col >= 0 ? `<field x="${col}"/>` : ""}<field x="-2"/></colFields>${pivotValueAxisItems(measures.length, col >= 0 ? grid.columnItems.length : void 0)}`;
|
|
26173
|
+
body += `<colFields count="${col >= 0 ? 2 : 1}">${col >= 0 ? `<field x="${col}"/>` : ""}<field x="-2"/></colFields>${pivotValueAxisItems(measures.length, col >= 0 ? grid.columnItems.length : void 0, columnIndicesFull)}`;
|
|
25925
26174
|
else if (col >= 0)
|
|
25926
|
-
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length)}</colItems>`;
|
|
26175
|
+
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length, columnIndicesFull)}</colItems>`;
|
|
25927
26176
|
else
|
|
25928
|
-
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
26177
|
+
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : page >= 0 ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
26178
|
+
if (page >= 0)
|
|
26179
|
+
body += `<pageFields count="1"><pageField${attrs({ fld: page, hier: -1, item: pivot.pageFilter.item !== void 0 ? pageItems.findIndex((item) => pivotValueKey(item) === pivotValueKey(pivot.pageFilter.item)) : void 0 })}/></pageFields>`;
|
|
25929
26180
|
body += `<dataFields count="${measures.length}">${measures.map((measure) => `<dataField${attrs({ name: encodeEscapes(measure.caption), fld: pivot.fields.indexOf(measure.field), subtotal: measure.aggregate, baseField: 0, baseItem: 0 })}/>`).join("")}</dataFields>`;
|
|
25930
26181
|
const doc = parseXml(
|
|
25931
26182
|
pivot.sourceXml ?? `<pivotTableDefinition xmlns="${NS.x}" dataCaption="Values" updatedVersion="6" minRefreshableVersion="3" createdVersion="6"><pivotTableStyleInfo name="PivotStyleLight16" showRowHeaders="1" showColHeaders="1" showRowStripes="0" showColStripes="0" showLastColumn="1"/></pivotTableDefinition>`
|
|
@@ -25980,7 +26231,8 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25980
26231
|
"rowItems",
|
|
25981
26232
|
"colFields",
|
|
25982
26233
|
"colItems",
|
|
25983
|
-
"dataFields"
|
|
26234
|
+
"dataFields",
|
|
26235
|
+
"pageFields"
|
|
25984
26236
|
]);
|
|
25985
26237
|
for (const child3 of elements(root)) if (replaced.has(child3.localName)) root.removeChild(child3);
|
|
25986
26238
|
const replacement = parseXml(`<root xmlns="${NS.x}">${body}</root>`).documentElement;
|
|
@@ -26165,8 +26417,8 @@ async function saveXlsx(workbook) {
|
|
|
26165
26417
|
return void 0;
|
|
26166
26418
|
});
|
|
26167
26419
|
const sheetRefs = [];
|
|
26168
|
-
workbook.sheets.forEach((sheet,
|
|
26169
|
-
let partName = partNames[
|
|
26420
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
26421
|
+
let partName = partNames[index3];
|
|
26170
26422
|
const sourceType = partName && source2?.has(partName) ? source2.contentType(partName) : void 0;
|
|
26171
26423
|
const special = sourceType ? SHEET_TYPES[sourceType] : void 0;
|
|
26172
26424
|
if (!partName) {
|
|
@@ -26177,11 +26429,11 @@ async function saveXlsx(workbook) {
|
|
|
26177
26429
|
claimed.add(partName);
|
|
26178
26430
|
}
|
|
26179
26431
|
if (special) writer.carry(partName);
|
|
26180
|
-
else writeWorksheet(ctx, sheet,
|
|
26432
|
+
else writeWorksheet(ctx, sheet, index3, partName);
|
|
26181
26433
|
sheetRefs.push({
|
|
26182
26434
|
name: sheet.name,
|
|
26183
26435
|
sheetId: sheet.sheetId,
|
|
26184
|
-
state: states[
|
|
26436
|
+
state: states[index3] ?? "visible",
|
|
26185
26437
|
relId: rels.add(special ?? RELATIONSHIP_TYPES.worksheet, relativeTarget(bookPart, partName))
|
|
26186
26438
|
});
|
|
26187
26439
|
});
|
|
@@ -26243,9 +26495,9 @@ async function saveXlsx(workbook) {
|
|
|
26243
26495
|
}
|
|
26244
26496
|
|
|
26245
26497
|
// xlsx/edit/context.ts
|
|
26246
|
-
function sheetAt(workbook,
|
|
26247
|
-
const sheet = Number.isInteger(
|
|
26248
|
-
if (!sheet) throw new RangeError(`No sheet at index ${
|
|
26498
|
+
function sheetAt(workbook, index3) {
|
|
26499
|
+
const sheet = Number.isInteger(index3) ? workbook.sheets[index3] : void 0;
|
|
26500
|
+
if (!sheet) throw new RangeError(`No sheet at index ${index3}`);
|
|
26249
26501
|
return sheet;
|
|
26250
26502
|
}
|
|
26251
26503
|
function baseStyleId(sheet, row2, col) {
|
|
@@ -26479,7 +26731,7 @@ function rewriteFormulas(workbook, rewrite2, formulaCells) {
|
|
|
26479
26731
|
else bySheet.set(cell.sheet, [cell]);
|
|
26480
26732
|
}
|
|
26481
26733
|
workbook.sheets.forEach(
|
|
26482
|
-
(sheet,
|
|
26734
|
+
(sheet, index3) => rewriteSheetFormulas(sheet, rewrite2, bySheet ? bySheet.get(index3) ?? [] : void 0)
|
|
26483
26735
|
);
|
|
26484
26736
|
for (const definedName of workbook.definedNames) {
|
|
26485
26737
|
const local = definedName.localSheet === void 0 ? void 0 : workbook.sheets[definedName.localSheet];
|
|
@@ -26498,11 +26750,11 @@ function rewriteSheetFormulas(sheet, rewrite2, formulaCells) {
|
|
|
26498
26750
|
{
|
|
26499
26751
|
const name = sheet.name;
|
|
26500
26752
|
for (const table2 of sheet.tables)
|
|
26501
|
-
for (const [
|
|
26753
|
+
for (const [index3, column] of table2.columns.entries())
|
|
26502
26754
|
if (column.calculatedColumnFormula !== void 0)
|
|
26503
26755
|
column.calculatedColumnFormula = safe(rewrite2, column.calculatedColumnFormula, name, {
|
|
26504
26756
|
row: table2.range.start.row + (table2.headerRow ? 1 : 0),
|
|
26505
|
-
col: table2.range.start.col +
|
|
26757
|
+
col: table2.range.start.col + index3
|
|
26506
26758
|
});
|
|
26507
26759
|
if (formulaCells) {
|
|
26508
26760
|
for (const at of formulaCells) {
|
|
@@ -26578,8 +26830,8 @@ function syncTableHeader(ctx, sheet, row2, col, formulaCells) {
|
|
|
26578
26830
|
const newName = uniqueHeaders([...others, text3]).at(-1);
|
|
26579
26831
|
column.name = newName;
|
|
26580
26832
|
if (newName !== text3) writeValue(sheet, row2, col, newName);
|
|
26581
|
-
const
|
|
26582
|
-
const cells = formulaCells && (formulaCells.some((cell) => cell.sheet ===
|
|
26833
|
+
const index3 = ctx.workbook.sheets.indexOf(sheet);
|
|
26834
|
+
const cells = formulaCells && (formulaCells.some((cell) => cell.sheet === index3 && cell.row === row2 && cell.col === col) ? formulaCells : [...formulaCells, { sheet: index3, row: row2, col }]);
|
|
26583
26835
|
rewriteFormulas(
|
|
26584
26836
|
ctx.workbook,
|
|
26585
26837
|
(formula, formulaSheet, at) => renameTableColumnInFormula(
|
|
@@ -26592,7 +26844,7 @@ function syncTableHeader(ctx, sheet, row2, col, formulaCells) {
|
|
|
26592
26844
|
cells
|
|
26593
26845
|
);
|
|
26594
26846
|
}
|
|
26595
|
-
function writeScopes(sheet,
|
|
26847
|
+
function writeScopes(sheet, index3, range, parts = []) {
|
|
26596
26848
|
const r = normalizeRange(range);
|
|
26597
26849
|
const touchesHeader = sheet.tables.some(
|
|
26598
26850
|
(t) => t.headerRow && rangesIntersect(
|
|
@@ -26600,9 +26852,9 @@ function writeScopes(sheet, index2, range, parts = []) {
|
|
|
26600
26852
|
cellRange(t.range.start.row, t.range.start.col, t.range.start.row, t.range.end.col)
|
|
26601
26853
|
)
|
|
26602
26854
|
);
|
|
26603
|
-
if (touchesHeader) return [{ kind: "refs" }, { kind: "cells", sheet:
|
|
26604
|
-
const scopes = [{ kind: "cells", sheet:
|
|
26605
|
-
if (parts.length) scopes.push({ kind: "parts", sheet:
|
|
26855
|
+
if (touchesHeader) return [{ kind: "refs" }, { kind: "cells", sheet: index3, ranges: [r] }];
|
|
26856
|
+
const scopes = [{ kind: "cells", sheet: index3, ranges: [r] }];
|
|
26857
|
+
if (parts.length) scopes.push({ kind: "parts", sheet: index3, parts });
|
|
26606
26858
|
return scopes;
|
|
26607
26859
|
}
|
|
26608
26860
|
function writeInput(ctx, sheet, row2, col, text3) {
|
|
@@ -26900,10 +27152,10 @@ function patchRangeWith(sheet, range, patcher) {
|
|
|
26900
27152
|
pruneCell(sheet, row2, col);
|
|
26901
27153
|
});
|
|
26902
27154
|
}
|
|
26903
|
-
function formatScopes(
|
|
26904
|
-
const cells = { kind: "cells", sheet:
|
|
27155
|
+
function formatScopes(index3, ranges) {
|
|
27156
|
+
const cells = { kind: "cells", sheet: index3, ranges };
|
|
26905
27157
|
const whole = ranges.some((r) => isWholeColumns(r) || isWholeRows(r));
|
|
26906
|
-
return whole ? [cells, { kind: "parts", sheet:
|
|
27158
|
+
return whole ? [cells, { kind: "parts", sheet: index3, parts: ["columns", "rowInfo"] }] : [cells];
|
|
26907
27159
|
}
|
|
26908
27160
|
function applyStyle(ctx, s, ranges, patch3) {
|
|
26909
27161
|
const sheet = sheetAt(ctx.workbook, s);
|
|
@@ -26946,8 +27198,8 @@ var LISTS = [
|
|
|
26946
27198
|
function listMatch(text3) {
|
|
26947
27199
|
const lower2 = text3.toLowerCase();
|
|
26948
27200
|
for (const list of LISTS) {
|
|
26949
|
-
const
|
|
26950
|
-
if (
|
|
27201
|
+
const index3 = list.findIndex((item) => item.toLowerCase() === lower2);
|
|
27202
|
+
if (index3 >= 0) return { list, index: index3 };
|
|
26951
27203
|
}
|
|
26952
27204
|
return void 0;
|
|
26953
27205
|
}
|
|
@@ -27159,9 +27411,9 @@ function removeValidationArea(rules, area) {
|
|
|
27159
27411
|
}
|
|
27160
27412
|
|
|
27161
27413
|
// xlsx/edit/conditional-formats.ts
|
|
27162
|
-
function formatAt(sheet,
|
|
27163
|
-
const format = sheet.conditionalFormats[
|
|
27164
|
-
if (!format) throw new RangeError(`No conditional format at index ${
|
|
27414
|
+
function formatAt(sheet, index3) {
|
|
27415
|
+
const format = sheet.conditionalFormats[index3];
|
|
27416
|
+
if (!format) throw new RangeError(`No conditional format at index ${index3}`);
|
|
27165
27417
|
return format;
|
|
27166
27418
|
}
|
|
27167
27419
|
function rulesByPriority(sheet) {
|
|
@@ -27172,9 +27424,9 @@ function renumber(rules) {
|
|
|
27172
27424
|
rule.priority = i2 + 1;
|
|
27173
27425
|
});
|
|
27174
27426
|
}
|
|
27175
|
-
function replaceConditionalFormat(ctx, s,
|
|
27427
|
+
function replaceConditionalFormat(ctx, s, index3, format) {
|
|
27176
27428
|
const sheet = sheetAt(ctx.workbook, s);
|
|
27177
|
-
formatAt(sheet,
|
|
27429
|
+
formatAt(sheet, index3);
|
|
27178
27430
|
if (!format.ranges.length || !format.rules.length)
|
|
27179
27431
|
throw new Error("A conditional format needs at least one range and one rule.");
|
|
27180
27432
|
ctx.run(
|
|
@@ -27184,21 +27436,21 @@ function replaceConditionalFormat(ctx, s, index2, format) {
|
|
|
27184
27436
|
() => {
|
|
27185
27437
|
const next = structuredClone(format);
|
|
27186
27438
|
next.ranges = next.ranges.map(normalizeRange);
|
|
27187
|
-
sheet.conditionalFormats[
|
|
27439
|
+
sheet.conditionalFormats[index3] = next;
|
|
27188
27440
|
renumber(rulesByPriority(sheet));
|
|
27189
27441
|
},
|
|
27190
27442
|
{ sheet: s, ranges: format.ranges }
|
|
27191
27443
|
);
|
|
27192
27444
|
}
|
|
27193
|
-
function removeConditionalFormat(ctx, s,
|
|
27445
|
+
function removeConditionalFormat(ctx, s, index3) {
|
|
27194
27446
|
const sheet = sheetAt(ctx.workbook, s);
|
|
27195
|
-
const format = formatAt(sheet,
|
|
27447
|
+
const format = formatAt(sheet, index3);
|
|
27196
27448
|
ctx.run(
|
|
27197
27449
|
"Delete rule",
|
|
27198
27450
|
"format",
|
|
27199
27451
|
[{ kind: "sheet", sheet: s }],
|
|
27200
27452
|
() => {
|
|
27201
|
-
sheet.conditionalFormats.splice(
|
|
27453
|
+
sheet.conditionalFormats.splice(index3, 1);
|
|
27202
27454
|
renumber(rulesByPriority(sheet));
|
|
27203
27455
|
},
|
|
27204
27456
|
{ sheet: s, ranges: format.ranges }
|
|
@@ -27362,20 +27614,20 @@ function pasteConditionalFormats(sheet, dest, cells, transpose2, skipBlanks, cut
|
|
|
27362
27614
|
// xlsx/edit/annotations.ts
|
|
27363
27615
|
function setComment(ctx, s, at, text3, author) {
|
|
27364
27616
|
const sheet = sheetAt(ctx.workbook, s);
|
|
27365
|
-
const
|
|
27617
|
+
const index3 = sheet.comments.findIndex(
|
|
27366
27618
|
(c2) => c2.address.row === at.row && c2.address.col === at.col
|
|
27367
27619
|
);
|
|
27368
|
-
if (
|
|
27620
|
+
if (index3 < 0 && text3 === void 0) return;
|
|
27369
27621
|
ctx.run(
|
|
27370
|
-
text3 === void 0 ? "Delete comment" :
|
|
27622
|
+
text3 === void 0 ? "Delete comment" : index3 < 0 ? "New comment" : "Edit comment",
|
|
27371
27623
|
"annotations",
|
|
27372
27624
|
[{ kind: "sheet", sheet: s }],
|
|
27373
27625
|
() => {
|
|
27374
27626
|
if (text3 === void 0) {
|
|
27375
|
-
sheet.comments.splice(
|
|
27627
|
+
sheet.comments.splice(index3, 1);
|
|
27376
27628
|
return;
|
|
27377
27629
|
}
|
|
27378
|
-
const existing = sheet.comments[
|
|
27630
|
+
const existing = sheet.comments[index3];
|
|
27379
27631
|
if (existing) {
|
|
27380
27632
|
existing.text = text3;
|
|
27381
27633
|
existing.author = author;
|
|
@@ -29293,7 +29545,7 @@ function replaceAll(ctx, query, replacement) {
|
|
|
29293
29545
|
)
|
|
29294
29546
|
);
|
|
29295
29547
|
const uniqueScopes = scopes.filter(
|
|
29296
|
-
(scope,
|
|
29548
|
+
(scope, index3) => scope.kind !== "refs" || scopes.findIndex((entry3) => entry3.kind === "refs") === index3
|
|
29297
29549
|
);
|
|
29298
29550
|
return ctx.run(
|
|
29299
29551
|
"Replace",
|
|
@@ -29822,9 +30074,9 @@ function setDocumentProperties(ctx, patch3) {
|
|
|
29822
30074
|
}
|
|
29823
30075
|
|
|
29824
30076
|
// xlsx/edit/drawings.ts
|
|
29825
|
-
function drawingAt(ctx, s,
|
|
29826
|
-
const drawing = sheetAt(ctx.workbook, s).drawings[
|
|
29827
|
-
if (!drawing) throw new RangeError(`No drawing at index ${
|
|
30077
|
+
function drawingAt(ctx, s, index3) {
|
|
30078
|
+
const drawing = sheetAt(ctx.workbook, s).drawings[index3];
|
|
30079
|
+
if (!drawing) throw new RangeError(`No drawing at index ${index3} on sheet ${s}`);
|
|
29828
30080
|
return drawing;
|
|
29829
30081
|
}
|
|
29830
30082
|
function checkAnchor(anchor) {
|
|
@@ -29835,8 +30087,8 @@ function checkAnchor(anchor) {
|
|
|
29835
30087
|
if (anchor.ext && !(anchor.ext.cx >= 0 && anchor.ext.cy >= 0))
|
|
29836
30088
|
throw new RangeError("A drawing extent cannot be negative.");
|
|
29837
30089
|
}
|
|
29838
|
-
function setDrawingAnchor(ctx, s,
|
|
29839
|
-
const drawing = drawingAt(ctx, s,
|
|
30090
|
+
function setDrawingAnchor(ctx, s, index3, anchor) {
|
|
30091
|
+
const drawing = drawingAt(ctx, s, index3);
|
|
29840
30092
|
checkAnchor(anchor);
|
|
29841
30093
|
ctx.run(
|
|
29842
30094
|
"Move object",
|
|
@@ -29848,15 +30100,15 @@ function setDrawingAnchor(ctx, s, index2, anchor) {
|
|
|
29848
30100
|
{ sheet: s }
|
|
29849
30101
|
);
|
|
29850
30102
|
}
|
|
29851
|
-
function deleteDrawing(ctx, s,
|
|
29852
|
-
drawingAt(ctx, s,
|
|
30103
|
+
function deleteDrawing(ctx, s, index3) {
|
|
30104
|
+
drawingAt(ctx, s, index3);
|
|
29853
30105
|
const sheet = sheetAt(ctx.workbook, s);
|
|
29854
30106
|
ctx.run(
|
|
29855
30107
|
"Delete object",
|
|
29856
30108
|
"annotations",
|
|
29857
30109
|
[{ kind: "sheet", sheet: s }],
|
|
29858
30110
|
() => {
|
|
29859
|
-
sheet.drawings.splice(
|
|
30111
|
+
sheet.drawings.splice(index3, 1);
|
|
29860
30112
|
},
|
|
29861
30113
|
{ sheet: s }
|
|
29862
30114
|
);
|
|
@@ -29917,8 +30169,8 @@ function patchSparklineNode(node, patch3) {
|
|
|
29917
30169
|
if (old) node.replaceChild(replacement, old);
|
|
29918
30170
|
else {
|
|
29919
30171
|
const before = elements(node).find((child3) => {
|
|
29920
|
-
const
|
|
29921
|
-
return
|
|
30172
|
+
const index3 = COLORS2.indexOf(child3.localName);
|
|
30173
|
+
return index3 > COLORS2.indexOf(key) || child3.localName === "f" || child3.localName === "sparklines";
|
|
29922
30174
|
});
|
|
29923
30175
|
node.insertBefore(replacement, before ?? null);
|
|
29924
30176
|
}
|
|
@@ -29946,8 +30198,8 @@ function editSparklineXml(sheet, edit) {
|
|
|
29946
30198
|
function appendSparklineXml(sheet, groupXml2) {
|
|
29947
30199
|
const source2 = [...sheet.preserved.get("extLst") ?? []];
|
|
29948
30200
|
const found = source2.findIndex((xml) => xml.includes("sparklineGroups"));
|
|
29949
|
-
const
|
|
29950
|
-
const doc = parseXml(source2[
|
|
30201
|
+
const index3 = found >= 0 ? found : 0;
|
|
30202
|
+
const doc = parseXml(source2[index3] ?? `<extLst xmlns="${NS.x}"/>`);
|
|
29951
30203
|
const root = doc.documentElement;
|
|
29952
30204
|
let ext = children(root, "ext", NS.x).find(
|
|
29953
30205
|
(node) => node.getAttribute("uri")?.toUpperCase() === URI2.toUpperCase()
|
|
@@ -29974,7 +30226,7 @@ function appendSparklineXml(sheet, groupXml2) {
|
|
|
29974
30226
|
fresh.setAttributeNS(revision, "xr2:uid", `{${globalThis.crypto.randomUUID().toUpperCase()}}`);
|
|
29975
30227
|
}
|
|
29976
30228
|
groups.appendChild(fresh);
|
|
29977
|
-
source2[
|
|
30229
|
+
source2[index3] = buildXml(root);
|
|
29978
30230
|
return source2;
|
|
29979
30231
|
}
|
|
29980
30232
|
|
|
@@ -30252,6 +30504,7 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
30252
30504
|
valueField: options.valueField,
|
|
30253
30505
|
aggregate: aggregate3,
|
|
30254
30506
|
valueCaption: pivotCaption(aggregate3, options.valueField),
|
|
30507
|
+
...options.pageFilter !== void 0 ? { pageFilter: structuredClone(options.pageFilter) } : {},
|
|
30255
30508
|
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
30256
30509
|
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
30257
30510
|
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
@@ -30287,6 +30540,10 @@ function refreshPivotTable(ctx, s, name, patch3 = {}) {
|
|
|
30287
30540
|
if (patch3.layout !== void 0) next.layout = patch3.layout;
|
|
30288
30541
|
if (patch3.subtotalPosition !== void 0) next.subtotalPosition = patch3.subtotalPosition;
|
|
30289
30542
|
if (patch3.valuesAxis !== void 0) next.valuesAxis = patch3.valuesAxis;
|
|
30543
|
+
if (patch3.pageFilter !== void 0) {
|
|
30544
|
+
if (patch3.pageFilter === null) delete next.pageFilter;
|
|
30545
|
+
else next.pageFilter = structuredClone(patch3.pageFilter);
|
|
30546
|
+
}
|
|
30290
30547
|
if (patch3.valuesPosition !== void 0) next.valuesPosition = patch3.valuesPosition;
|
|
30291
30548
|
else if (patch3.valuesAxis === "columns" || patch3.secondRowField === "")
|
|
30292
30549
|
delete next.valuesPosition;
|
|
@@ -30381,22 +30638,22 @@ function applyCellStyle(ctx, s, ranges, name) {
|
|
|
30381
30638
|
function sortGradientStops(stops) {
|
|
30382
30639
|
return stops.slice().sort((a2, b) => a2.position - b.position);
|
|
30383
30640
|
}
|
|
30384
|
-
function removeGradientStop(stops,
|
|
30385
|
-
return stops.length <= 2 ? void 0 : stops.filter((_, i2) => i2 !==
|
|
30641
|
+
function removeGradientStop(stops, index3) {
|
|
30642
|
+
return stops.length <= 2 ? void 0 : stops.filter((_, i2) => i2 !== index3);
|
|
30386
30643
|
}
|
|
30387
30644
|
|
|
30388
30645
|
// xlsx/edit/chart-series-transparency.ts
|
|
30389
|
-
function chartSeriesSolidColor(chart,
|
|
30390
|
-
const series = chart.series[
|
|
30646
|
+
function chartSeriesSolidColor(chart, index3) {
|
|
30647
|
+
const series = chart.series[index3];
|
|
30391
30648
|
if (!series || series.fill && series.fill.kind !== "solid") return void 0;
|
|
30392
30649
|
return series.fill?.kind === "solid" ? series.fill.color : series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(
|
|
30393
30650
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
30394
|
-
|
|
30651
|
+
index3,
|
|
30395
30652
|
chart.series.length
|
|
30396
30653
|
);
|
|
30397
30654
|
}
|
|
30398
|
-
function chartSeriesTransparency(chart,
|
|
30399
|
-
const color = chartSeriesSolidColor(chart,
|
|
30655
|
+
function chartSeriesTransparency(chart, index3) {
|
|
30656
|
+
const color = chartSeriesSolidColor(chart, index3);
|
|
30400
30657
|
if (!color) return void 0;
|
|
30401
30658
|
const resolved = resolveDrawingColor(
|
|
30402
30659
|
color,
|
|
@@ -30405,11 +30662,11 @@ function chartSeriesTransparency(chart, index2) {
|
|
|
30405
30662
|
);
|
|
30406
30663
|
return resolved ? Math.round((1 - resolved.alpha) * 1e5) / 1e3 : void 0;
|
|
30407
30664
|
}
|
|
30408
|
-
function chartSeriesTransparencyPatch(chart,
|
|
30665
|
+
function chartSeriesTransparencyPatch(chart, index3, percent2) {
|
|
30409
30666
|
if (!Number.isFinite(percent2) || percent2 < 0 || percent2 > 100)
|
|
30410
30667
|
throw new RangeError("Chart transparency must be from 0 to 100");
|
|
30411
|
-
const current = chartSeriesAt(chart,
|
|
30412
|
-
const color = chartSeriesSolidColor(chart,
|
|
30668
|
+
const current = chartSeriesAt(chart, index3);
|
|
30669
|
+
const color = chartSeriesSolidColor(chart, index3);
|
|
30413
30670
|
if (!color) return void 0;
|
|
30414
30671
|
const choice = structuredClone(color);
|
|
30415
30672
|
choice.transforms = choice.transforms.filter(
|
|
@@ -30419,7 +30676,7 @@ function chartSeriesTransparencyPatch(chart, index2, percent2) {
|
|
|
30419
30676
|
choice.transforms.push({ name: "alpha", value: String(Math.round((100 - percent2) * 1e3)) });
|
|
30420
30677
|
if (sameChartColor(choice, color) && !Object.keys(current.pointColors ?? {}).length && !Object.keys(current.pointFills ?? {}).length)
|
|
30421
30678
|
return void 0;
|
|
30422
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
30679
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
30423
30680
|
delete next.fill;
|
|
30424
30681
|
delete next.color;
|
|
30425
30682
|
delete next.pointColors;
|
|
@@ -30429,8 +30686,8 @@ function chartSeriesTransparencyPatch(chart, index2, percent2) {
|
|
|
30429
30686
|
}
|
|
30430
30687
|
|
|
30431
30688
|
// xlsx/edit/chart-series-gradient.ts
|
|
30432
|
-
function chartGradientStopTransparency(fill,
|
|
30433
|
-
const color = fill.stops[
|
|
30689
|
+
function chartGradientStopTransparency(fill, index3) {
|
|
30690
|
+
const color = fill.stops[index3]?.color;
|
|
30434
30691
|
const value2 = color && resolveDrawingColor(color, { scheme: () => "#000000" }, { transformOrder: "document" });
|
|
30435
30692
|
return value2 ? Math.round((1 - value2.alpha) * 1e5) / 1e3 : 0;
|
|
30436
30693
|
}
|
|
@@ -30438,19 +30695,19 @@ function percent(value2) {
|
|
|
30438
30695
|
if (!Number.isFinite(value2) || value2 < 0 || value2 > 100)
|
|
30439
30696
|
throw new RangeError("Gradient value must be from 0 to 100");
|
|
30440
30697
|
}
|
|
30441
|
-
function chartSeriesGradientPatch(chart,
|
|
30442
|
-
const current = chartSeriesAt(chart,
|
|
30698
|
+
function chartSeriesGradientPatch(chart, index3, edit) {
|
|
30699
|
+
const current = chartSeriesAt(chart, index3);
|
|
30443
30700
|
const result2 = chartGradientFillEdit(
|
|
30444
30701
|
current.fill,
|
|
30445
30702
|
edit,
|
|
30446
|
-
chartSeriesSolidColor(chart,
|
|
30703
|
+
chartSeriesSolidColor(chart, index3) ?? chartPaletteSeriesColorChoice(
|
|
30447
30704
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
30448
|
-
|
|
30705
|
+
index3,
|
|
30449
30706
|
chart.series.length
|
|
30450
30707
|
)
|
|
30451
30708
|
);
|
|
30452
30709
|
if (!result2) return void 0;
|
|
30453
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
30710
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
30454
30711
|
next.fill = result2.fill;
|
|
30455
30712
|
delete next.color;
|
|
30456
30713
|
delete next.drawingColor;
|
|
@@ -30646,18 +30903,18 @@ function addChart(ctx, s, chart) {
|
|
|
30646
30903
|
{ sheet: s }
|
|
30647
30904
|
);
|
|
30648
30905
|
}
|
|
30649
|
-
function updateChart(ctx, s,
|
|
30906
|
+
function updateChart(ctx, s, index3, patch3) {
|
|
30650
30907
|
assertBarClusterOptions(patch3);
|
|
30651
30908
|
const sheet = sheetAt(ctx.workbook, s);
|
|
30652
|
-
const chart = sheet.drawings[
|
|
30653
|
-
if (!chart || chart.kind !== "chart") throw new RangeError(`No chart at index ${
|
|
30909
|
+
const chart = sheet.drawings[index3];
|
|
30910
|
+
if (!chart || chart.kind !== "chart") throw new RangeError(`No chart at index ${index3}`);
|
|
30654
30911
|
const formatting = patch3.elementFills ? chartWithElementFills(chart, patch3.elementFills).formatting : void 0;
|
|
30655
30912
|
ctx.run(
|
|
30656
30913
|
"Edit chart",
|
|
30657
30914
|
"annotations",
|
|
30658
30915
|
[{ kind: "sheet", sheet: s }],
|
|
30659
30916
|
() => {
|
|
30660
|
-
const live = sheet.drawings[
|
|
30917
|
+
const live = sheet.drawings[index3];
|
|
30661
30918
|
const changes = structuredClone(patch3);
|
|
30662
30919
|
delete changes.elementFills;
|
|
30663
30920
|
if (formatting) live.formatting = formatting;
|
|
@@ -30775,9 +31032,9 @@ function applyTotalsRow(sheet, table2) {
|
|
|
30775
31032
|
|
|
30776
31033
|
// xlsx/edit/table-edits.ts
|
|
30777
31034
|
function tableIndex(sheet, ref) {
|
|
30778
|
-
const
|
|
30779
|
-
if (!sheet.tables[
|
|
30780
|
-
return
|
|
31035
|
+
const index3 = typeof ref === "number" ? ref : sheet.tables.findIndex((t) => t.name.toLowerCase() === ref.toLowerCase());
|
|
31036
|
+
if (!sheet.tables[index3]) throw new RangeError(`No table ${String(ref)} on ${sheet.name}`);
|
|
31037
|
+
return index3;
|
|
30781
31038
|
}
|
|
30782
31039
|
var TABLE_NAME = /^[A-Za-z_\\][A-Za-z0-9_.\\]*$/;
|
|
30783
31040
|
function validateTableName(workbook, name, self) {
|
|
@@ -30939,8 +31196,8 @@ function updateTable(ctx, s, ref, patch3) {
|
|
|
30939
31196
|
if (patch3.columns.length !== width) throw new Error("Give one column per table column.");
|
|
30940
31197
|
const before = table2.columns;
|
|
30941
31198
|
table2.columns = structuredClone(patch3.columns);
|
|
30942
|
-
for (const [
|
|
30943
|
-
const sourceId = before[
|
|
31199
|
+
for (const [index3, column] of table2.columns.entries()) {
|
|
31200
|
+
const sourceId = before[index3]?.sourceId;
|
|
30944
31201
|
if (column.sourceId === void 0 && sourceId !== void 0) column.sourceId = sourceId;
|
|
30945
31202
|
}
|
|
30946
31203
|
}
|
|
@@ -31197,8 +31454,8 @@ function setPageBreak(ctx, s, axis, before, present = true) {
|
|
|
31197
31454
|
const sheet = sheetAt(ctx.workbook, s);
|
|
31198
31455
|
const key = axis === "row" ? "rowBreaks" : "colBreaks";
|
|
31199
31456
|
const source2 = sheet.preserved.get(key) ?? [`<${key} xmlns="${NS.x}"/>`];
|
|
31200
|
-
const result2 = source2.flatMap((xml,
|
|
31201
|
-
const next = patch2(xml, before, present &&
|
|
31457
|
+
const result2 = source2.flatMap((xml, index3) => {
|
|
31458
|
+
const next = patch2(xml, before, present && index3 === 0, axis);
|
|
31202
31459
|
return next ? [next] : [];
|
|
31203
31460
|
});
|
|
31204
31461
|
ctx.run(
|
|
@@ -31341,16 +31598,16 @@ function setDefinedName(ctx, name) {
|
|
|
31341
31598
|
entry3.formula = entry3.formula.replace(/^=/, "");
|
|
31342
31599
|
ctx.run("Define name", "names", [{ kind: "meta" }], () => {
|
|
31343
31600
|
const { definedNames } = ctx.workbook;
|
|
31344
|
-
const
|
|
31345
|
-
if (
|
|
31601
|
+
const index3 = definedNames.findIndex((n2) => sameName(n2, name.name, name.localSheet));
|
|
31602
|
+
if (index3 >= 0) definedNames[index3] = entry3;
|
|
31346
31603
|
else definedNames.push(entry3);
|
|
31347
31604
|
});
|
|
31348
31605
|
}
|
|
31349
31606
|
function deleteDefinedName(ctx, name, localSheet) {
|
|
31350
|
-
const
|
|
31351
|
-
if (
|
|
31607
|
+
const index3 = ctx.workbook.definedNames.findIndex((n2) => sameName(n2, name, localSheet));
|
|
31608
|
+
if (index3 < 0) return;
|
|
31352
31609
|
ctx.run("Delete name", "names", [{ kind: "meta" }], () => {
|
|
31353
|
-
ctx.workbook.definedNames.splice(
|
|
31610
|
+
ctx.workbook.definedNames.splice(index3, 1);
|
|
31354
31611
|
});
|
|
31355
31612
|
}
|
|
31356
31613
|
|
|
@@ -31388,7 +31645,7 @@ function normalizeDigestAlgorithmName(name) {
|
|
|
31388
31645
|
|
|
31389
31646
|
// digest/base64.ts
|
|
31390
31647
|
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
31391
|
-
var VALUES = new Map([...ALPHABET].map((char,
|
|
31648
|
+
var VALUES = new Map([...ALPHABET].map((char, index3) => [char, index3]));
|
|
31392
31649
|
function encodeBase64(bytes) {
|
|
31393
31650
|
let out = "";
|
|
31394
31651
|
for (let i2 = 0; i2 < bytes.length; i2 += 3) {
|
|
@@ -31410,7 +31667,7 @@ function decodeBase64(text3) {
|
|
|
31410
31667
|
const out = new Uint8Array(Math.floor(body.length * 3 / 4));
|
|
31411
31668
|
let bits = 0;
|
|
31412
31669
|
let buffer = 0;
|
|
31413
|
-
let
|
|
31670
|
+
let index3 = 0;
|
|
31414
31671
|
for (const char of body) {
|
|
31415
31672
|
const value2 = VALUES.get(char);
|
|
31416
31673
|
if (value2 === void 0) return void 0;
|
|
@@ -31418,7 +31675,7 @@ function decodeBase64(text3) {
|
|
|
31418
31675
|
bits += 6;
|
|
31419
31676
|
if (bits >= 8) {
|
|
31420
31677
|
bits -= 8;
|
|
31421
|
-
out[
|
|
31678
|
+
out[index3++] = buffer >> bits & 255;
|
|
31422
31679
|
}
|
|
31423
31680
|
}
|
|
31424
31681
|
return out;
|
|
@@ -31807,7 +32064,7 @@ function i(x, y, z) {
|
|
|
31807
32064
|
}
|
|
31808
32065
|
var T = Array.from(
|
|
31809
32066
|
{ length: 64 },
|
|
31810
|
-
(_,
|
|
32067
|
+
(_, index3) => Math.floor(Math.abs(Math.sin(index3 + 1)) * 2 ** 32)
|
|
31811
32068
|
);
|
|
31812
32069
|
var SHIFTS = [
|
|
31813
32070
|
[7, 12, 17, 22],
|
|
@@ -33565,14 +33822,14 @@ var AxisMetrics = class {
|
|
|
33565
33822
|
constructor(defaultSize, count2, overrides) {
|
|
33566
33823
|
this.defaultSize = defaultSize;
|
|
33567
33824
|
this.count = count2;
|
|
33568
|
-
const sorted2 = [...overrides].filter(([
|
|
33825
|
+
const sorted2 = [...overrides].filter(([index3, size]) => index3 >= 0 && index3 < count2 && size !== defaultSize).sort((a2, b) => a2[0] - b[0]);
|
|
33569
33826
|
this.indices = [];
|
|
33570
33827
|
this.sizes = [];
|
|
33571
33828
|
this.prefix = [];
|
|
33572
33829
|
let delta = 0;
|
|
33573
|
-
for (const [
|
|
33574
|
-
if (this.indices.at(-1) ===
|
|
33575
|
-
this.indices.push(
|
|
33830
|
+
for (const [index3, size] of sorted2) {
|
|
33831
|
+
if (this.indices.at(-1) === index3) continue;
|
|
33832
|
+
this.indices.push(index3);
|
|
33576
33833
|
this.sizes.push(Math.max(0, size));
|
|
33577
33834
|
this.prefix.push(delta);
|
|
33578
33835
|
delta += Math.max(0, size) - defaultSize;
|
|
@@ -33589,24 +33846,24 @@ var AxisMetrics = class {
|
|
|
33589
33846
|
prefix;
|
|
33590
33847
|
totalDelta;
|
|
33591
33848
|
/** Number of custom entries strictly before `index` (binary search). */
|
|
33592
|
-
rank(
|
|
33849
|
+
rank(index3) {
|
|
33593
33850
|
let lo = 0;
|
|
33594
33851
|
let hi = this.indices.length;
|
|
33595
33852
|
while (lo < hi) {
|
|
33596
33853
|
const mid = lo + hi >> 1;
|
|
33597
|
-
if ((this.indices[mid] ?? 0) <
|
|
33854
|
+
if ((this.indices[mid] ?? 0) < index3) lo = mid + 1;
|
|
33598
33855
|
else hi = mid;
|
|
33599
33856
|
}
|
|
33600
33857
|
return lo;
|
|
33601
33858
|
}
|
|
33602
|
-
size(
|
|
33603
|
-
if (
|
|
33604
|
-
const k = this.rank(
|
|
33605
|
-
return this.indices[k] ===
|
|
33859
|
+
size(index3) {
|
|
33860
|
+
if (index3 < 0 || index3 >= this.count) return 0;
|
|
33861
|
+
const k = this.rank(index3);
|
|
33862
|
+
return this.indices[k] === index3 ? this.sizes[k] ?? 0 : this.defaultSize;
|
|
33606
33863
|
}
|
|
33607
33864
|
/** Offset of the leading edge of `index` (`index` may equal `count` for the axis end). */
|
|
33608
|
-
start(
|
|
33609
|
-
const i2 = Math.max(0, Math.min(
|
|
33865
|
+
start(index3) {
|
|
33866
|
+
const i2 = Math.max(0, Math.min(index3, this.count));
|
|
33610
33867
|
const k = this.rank(i2);
|
|
33611
33868
|
const before = k < this.indices.length ? this.prefix[k] ?? 0 : this.totalDelta;
|
|
33612
33869
|
return i2 * this.defaultSize + before;
|
|
@@ -33641,13 +33898,13 @@ var AxisMetrics = class {
|
|
|
33641
33898
|
return Math.min(line3, this.count - 1);
|
|
33642
33899
|
}
|
|
33643
33900
|
/** The first line at or after `index` with a non-zero size (or `count - 1`). */
|
|
33644
|
-
firstVisible(
|
|
33645
|
-
for (let i2 = Math.max(0,
|
|
33901
|
+
firstVisible(index3) {
|
|
33902
|
+
for (let i2 = Math.max(0, index3); i2 < this.count; i2++) if (this.size(i2) > 0) return i2;
|
|
33646
33903
|
return this.count - 1;
|
|
33647
33904
|
}
|
|
33648
33905
|
/** The last line at or before `index` with a non-zero size (or 0). */
|
|
33649
|
-
lastVisible(
|
|
33650
|
-
for (let i2 = Math.min(
|
|
33906
|
+
lastVisible(index3) {
|
|
33907
|
+
for (let i2 = Math.min(index3, this.count - 1); i2 >= 0; i2--) if (this.size(i2) > 0) return i2;
|
|
33651
33908
|
return 0;
|
|
33652
33909
|
}
|
|
33653
33910
|
/** Largest custom-entry index, or -1. */
|
|
@@ -33864,10 +34121,10 @@ function remapSheets(workbook, map) {
|
|
|
33864
34121
|
});
|
|
33865
34122
|
}
|
|
33866
34123
|
var visibleCount = (workbook) => workbook.sheets.filter((s) => s.state === "visible").length;
|
|
33867
|
-
function nearestVisible(workbook,
|
|
33868
|
-
for (let i2 =
|
|
34124
|
+
function nearestVisible(workbook, index3) {
|
|
34125
|
+
for (let i2 = index3; i2 < workbook.sheets.length; i2++)
|
|
33869
34126
|
if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
33870
|
-
for (let i2 =
|
|
34127
|
+
for (let i2 = index3 - 1; i2 >= 0; i2--) if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
33871
34128
|
return 0;
|
|
33872
34129
|
}
|
|
33873
34130
|
function addSheet(ctx, name, at) {
|
|
@@ -33876,24 +34133,24 @@ function addSheet(ctx, name, at) {
|
|
|
33876
34133
|
const sheetName = name ?? nextSheetName(workbook, ctx.defaultSheetBase);
|
|
33877
34134
|
const problem = validateSheetName(workbook, sheetName);
|
|
33878
34135
|
if (problem) throw new Error(problem);
|
|
33879
|
-
const
|
|
34136
|
+
const index3 = Math.max(0, Math.min(at ?? workbook.sheets.length, workbook.sheets.length));
|
|
33880
34137
|
return ctx.run(
|
|
33881
34138
|
"Insert sheet",
|
|
33882
34139
|
"sheets",
|
|
33883
34140
|
[{ kind: "workbook" }],
|
|
33884
34141
|
() => {
|
|
33885
|
-
workbook.sheets.splice(
|
|
33886
|
-
remapSheets(workbook, (i2) => i2 >=
|
|
33887
|
-
workbook.activeSheet =
|
|
33888
|
-
return
|
|
34142
|
+
workbook.sheets.splice(index3, 0, createWorksheet(sheetName, nextSheetId(workbook)));
|
|
34143
|
+
remapSheets(workbook, (i2) => i2 >= index3 ? i2 + 1 : i2);
|
|
34144
|
+
workbook.activeSheet = index3;
|
|
34145
|
+
return index3;
|
|
33889
34146
|
},
|
|
33890
|
-
{ sheet:
|
|
34147
|
+
{ sheet: index3, structural: true }
|
|
33891
34148
|
);
|
|
33892
34149
|
}
|
|
33893
|
-
function deleteSheet(ctx,
|
|
34150
|
+
function deleteSheet(ctx, index3) {
|
|
33894
34151
|
const { workbook } = ctx;
|
|
33895
34152
|
assertUnlocked(workbook);
|
|
33896
|
-
const sheet = sheetAt(workbook,
|
|
34153
|
+
const sheet = sheetAt(workbook, index3);
|
|
33897
34154
|
if (sheet.state === "visible" && visibleCount(workbook) <= 1)
|
|
33898
34155
|
throw new Error("A workbook must contain at least one visible sheet.");
|
|
33899
34156
|
if (workbook.sheets.some(
|
|
@@ -33908,26 +34165,26 @@ function deleteSheet(ctx, index2) {
|
|
|
33908
34165
|
[{ kind: "workbook" }],
|
|
33909
34166
|
() => {
|
|
33910
34167
|
const tables = sheet.tables.map((t) => t.name);
|
|
33911
|
-
workbook.sheets.splice(
|
|
33912
|
-
remapSheets(workbook, (i2) => i2 ===
|
|
34168
|
+
workbook.sheets.splice(index3, 1);
|
|
34169
|
+
remapSheets(workbook, (i2) => i2 === index3 ? void 0 : i2 > index3 ? i2 - 1 : i2);
|
|
33913
34170
|
rewriteFormulas(workbook, (formula) => deleteSheetInFormula(formula, sheet.name, tables));
|
|
33914
|
-
if (workbook.activeSheet >
|
|
33915
|
-
else if (workbook.activeSheet ===
|
|
34171
|
+
if (workbook.activeSheet > index3) workbook.activeSheet--;
|
|
34172
|
+
else if (workbook.activeSheet === index3)
|
|
33916
34173
|
workbook.activeSheet = nearestVisible(
|
|
33917
34174
|
workbook,
|
|
33918
|
-
Math.min(
|
|
34175
|
+
Math.min(index3, workbook.sheets.length - 1)
|
|
33919
34176
|
);
|
|
33920
34177
|
},
|
|
33921
34178
|
{ structural: true }
|
|
33922
34179
|
);
|
|
33923
34180
|
}
|
|
33924
|
-
function renameSheet(ctx,
|
|
34181
|
+
function renameSheet(ctx, index3, name) {
|
|
33925
34182
|
const { workbook } = ctx;
|
|
33926
34183
|
assertUnlocked(workbook);
|
|
33927
|
-
const sheet = sheetAt(workbook,
|
|
34184
|
+
const sheet = sheetAt(workbook, index3);
|
|
33928
34185
|
const old = sheet.name;
|
|
33929
34186
|
if (old === name) return;
|
|
33930
|
-
const problem = validateSheetName(workbook, name,
|
|
34187
|
+
const problem = validateSheetName(workbook, name, index3);
|
|
33931
34188
|
if (problem) throw new Error(problem);
|
|
33932
34189
|
ctx.run(
|
|
33933
34190
|
"Rename sheet",
|
|
@@ -33937,7 +34194,7 @@ function renameSheet(ctx, index2, name) {
|
|
|
33937
34194
|
rewriteFormulas(workbook, (formula) => renameSheetInFormula(formula, old, name));
|
|
33938
34195
|
sheet.name = name;
|
|
33939
34196
|
},
|
|
33940
|
-
{ sheet:
|
|
34197
|
+
{ sheet: index3, structural: true, calc: { kind: "rename", from: old, to: name } }
|
|
33941
34198
|
);
|
|
33942
34199
|
}
|
|
33943
34200
|
function moveSheet(ctx, from, to) {
|
|
@@ -33980,8 +34237,8 @@ function uniqueTableName(workbook, base, extra) {
|
|
|
33980
34237
|
const stem = base.replace(/_\d+$/, "") || "Table";
|
|
33981
34238
|
for (let n2 = 2; ; n2++) if (!taken.has(`${stem}_${n2}`.toLowerCase())) return `${stem}_${n2}`;
|
|
33982
34239
|
}
|
|
33983
|
-
function namesForCopy(workbook,
|
|
33984
|
-
const local = workbook.definedNames.filter((n2) => n2.localSheet ===
|
|
34240
|
+
function namesForCopy(workbook, index3, from, to) {
|
|
34241
|
+
const local = workbook.definedNames.filter((n2) => n2.localSheet === index3);
|
|
33985
34242
|
const taken = new Set(local.map((n2) => n2.name.toLowerCase()));
|
|
33986
34243
|
const global = workbook.definedNames.filter(
|
|
33987
34244
|
(n2) => n2.localSheet === void 0 && !taken.has(n2.name.toLowerCase()) && renameSheetInFormula(n2.formula, from, to) !== n2.formula
|
|
@@ -33991,11 +34248,11 @@ function namesForCopy(workbook, index2, from, to) {
|
|
|
33991
34248
|
formula: renameSheetInFormula(n2.formula, from, to)
|
|
33992
34249
|
}));
|
|
33993
34250
|
}
|
|
33994
|
-
function duplicateSheet(ctx,
|
|
34251
|
+
function duplicateSheet(ctx, index3) {
|
|
33995
34252
|
const { workbook } = ctx;
|
|
33996
34253
|
assertUnlocked(workbook);
|
|
33997
|
-
const sheet = sheetAt(workbook,
|
|
33998
|
-
const at =
|
|
34254
|
+
const sheet = sheetAt(workbook, index3);
|
|
34255
|
+
const at = index3 + 1;
|
|
33999
34256
|
return ctx.run(
|
|
34000
34257
|
"Duplicate sheet",
|
|
34001
34258
|
"sheets",
|
|
@@ -34033,7 +34290,7 @@ function duplicateSheet(ctx, index2) {
|
|
|
34033
34290
|
);
|
|
34034
34291
|
rewriteSheetFormulas(copy, rewrite2);
|
|
34035
34292
|
for (const drawing of copy.drawings) if (drawing.kind === "chart") delete drawing.partName;
|
|
34036
|
-
const copiedNames = namesForCopy(workbook,
|
|
34293
|
+
const copiedNames = namesForCopy(workbook, index3, sheet.name, copy.name);
|
|
34037
34294
|
for (const name of copiedNames) name.formula = rewrite2(name.formula);
|
|
34038
34295
|
workbook.sheets.splice(at, 0, copy);
|
|
34039
34296
|
remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
|
|
@@ -34044,9 +34301,9 @@ function duplicateSheet(ctx, index2) {
|
|
|
34044
34301
|
{ sheet: at, structural: true }
|
|
34045
34302
|
);
|
|
34046
34303
|
}
|
|
34047
|
-
function setSheetState(ctx,
|
|
34304
|
+
function setSheetState(ctx, index3, state) {
|
|
34048
34305
|
const { workbook } = ctx;
|
|
34049
|
-
const sheet = sheetAt(workbook,
|
|
34306
|
+
const sheet = sheetAt(workbook, index3);
|
|
34050
34307
|
if (sheet.state === state) return;
|
|
34051
34308
|
assertUnlocked(workbook);
|
|
34052
34309
|
if (state !== "visible") {
|
|
@@ -34056,26 +34313,26 @@ function setSheetState(ctx, index2, state) {
|
|
|
34056
34313
|
ctx.run(
|
|
34057
34314
|
state === "visible" ? "Unhide sheet" : "Hide sheet",
|
|
34058
34315
|
"sheets",
|
|
34059
|
-
[{ kind: "sheet", sheet:
|
|
34316
|
+
[{ kind: "sheet", sheet: index3 }, { kind: "meta" }],
|
|
34060
34317
|
() => {
|
|
34061
34318
|
sheet.state = state;
|
|
34062
|
-
if (state !== "visible" && workbook.activeSheet ===
|
|
34063
|
-
workbook.activeSheet = nearestVisible(workbook,
|
|
34319
|
+
if (state !== "visible" && workbook.activeSheet === index3)
|
|
34320
|
+
workbook.activeSheet = nearestVisible(workbook, index3);
|
|
34064
34321
|
},
|
|
34065
|
-
{ sheet:
|
|
34322
|
+
{ sheet: index3, structural: true }
|
|
34066
34323
|
);
|
|
34067
34324
|
}
|
|
34068
|
-
function setTabColor(ctx,
|
|
34069
|
-
const sheet = sheetAt(ctx.workbook,
|
|
34325
|
+
function setTabColor(ctx, index3, color) {
|
|
34326
|
+
const sheet = sheetAt(ctx.workbook, index3);
|
|
34070
34327
|
ctx.run(
|
|
34071
34328
|
"Tab color",
|
|
34072
34329
|
"sheets",
|
|
34073
|
-
[{ kind: "sheet", sheet:
|
|
34330
|
+
[{ kind: "sheet", sheet: index3 }],
|
|
34074
34331
|
() => {
|
|
34075
34332
|
if (color) sheet.tabColor = { ...color };
|
|
34076
34333
|
else Reflect.deleteProperty(sheet, "tabColor");
|
|
34077
34334
|
},
|
|
34078
|
-
{ sheet:
|
|
34335
|
+
{ sheet: index3 }
|
|
34079
34336
|
);
|
|
34080
34337
|
}
|
|
34081
34338
|
|
|
@@ -34489,20 +34746,20 @@ function createEditSession(workbook, options = {}) {
|
|
|
34489
34746
|
setSheetView: (s, patch3) => setSheetView(ctx, s, patch3),
|
|
34490
34747
|
setDefinedName: (name) => setDefinedName(ctx, name),
|
|
34491
34748
|
deleteDefinedName: (name, localSheet) => deleteDefinedName(ctx, name, localSheet),
|
|
34492
|
-
setDrawingAnchor: (s,
|
|
34749
|
+
setDrawingAnchor: (s, index3, anchor) => setDrawingAnchor(ctx, s, index3, anchor),
|
|
34493
34750
|
createPivotTable: (s, destination, options2) => createPivotTable(ctx, s, destination, options2),
|
|
34494
34751
|
refreshPivotTable: (s, name, patch3) => refreshPivotTable(ctx, s, name, patch3),
|
|
34495
34752
|
deletePivotTable: (s, name) => deletePivotTable(ctx, s, name),
|
|
34496
|
-
deleteDrawing: (s,
|
|
34753
|
+
deleteDrawing: (s, index3) => deleteDrawing(ctx, s, index3),
|
|
34497
34754
|
createSparklineGroup: (s, source2, locations, patch3) => createSparklineGroup(ctx, s, source2, locations, patch3),
|
|
34498
34755
|
setSparklineGroups: (s, ranges, patch3) => setSparklineGroups(ctx, s, ranges, patch3),
|
|
34499
34756
|
setSparklineDateRange: (s, ranges, source2) => setSparklineDateRange(ctx, s, ranges, source2),
|
|
34500
34757
|
deleteSparklines: (s, ranges, wholeGroups) => deleteSparklines(ctx, s, ranges, wholeGroups),
|
|
34501
34758
|
addChart: (s, chart) => addChart(ctx, s, chart),
|
|
34502
|
-
updateChart: (s,
|
|
34759
|
+
updateChart: (s, index3, patch3) => updateChart(ctx, s, index3, patch3),
|
|
34503
34760
|
addImage: (s, bytes, type, anchor, name) => addImage(ctx, s, bytes, type, anchor, name),
|
|
34504
|
-
replaceConditionalFormat: (s,
|
|
34505
|
-
removeConditionalFormat: (s,
|
|
34761
|
+
replaceConditionalFormat: (s, index3, cf) => replaceConditionalFormat(ctx, s, index3, cf),
|
|
34762
|
+
removeConditionalFormat: (s, index3) => removeConditionalFormat(ctx, s, index3),
|
|
34506
34763
|
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
34507
34764
|
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
34508
34765
|
updateTable: (s, table2, patch3) => updateTable(ctx, s, table2, patch3),
|
|
@@ -34746,12 +35003,12 @@ function mergeDxf(acc, next) {
|
|
|
34746
35003
|
return out;
|
|
34747
35004
|
}
|
|
34748
35005
|
function iconIndex(value2, cuts, list) {
|
|
34749
|
-
let
|
|
35006
|
+
let index3 = 0;
|
|
34750
35007
|
for (let i2 = 1; i2 < cuts.length; i2++) {
|
|
34751
35008
|
const cut = cuts[i2] ?? Infinity;
|
|
34752
|
-
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut)
|
|
35009
|
+
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut) index3 = i2;
|
|
34753
35010
|
}
|
|
34754
|
-
return
|
|
35011
|
+
return index3;
|
|
34755
35012
|
}
|
|
34756
35013
|
function scaleColor(value2, cuts, colors) {
|
|
34757
35014
|
if (!cuts.length || cuts.length !== colors.length) return void 0;
|
|
@@ -35130,10 +35387,10 @@ function createConditionalFormatEvaluator(workbook, sheetIndex2, evaluate, optio
|
|
|
35130
35387
|
}
|
|
35131
35388
|
if (rule.type === "iconSet") {
|
|
35132
35389
|
if (result2.icon || typeof value2 !== "number") return false;
|
|
35133
|
-
const
|
|
35390
|
+
const index3 = iconIndex(value2, thresholds(entry3, rule.thresholds), rule.thresholds);
|
|
35134
35391
|
result2.icon = {
|
|
35135
35392
|
set: rule.iconSet,
|
|
35136
|
-
index: rule.reverse ? rule.thresholds.length - 1 -
|
|
35393
|
+
index: rule.reverse ? rule.thresholds.length - 1 - index3 : index3
|
|
35137
35394
|
};
|
|
35138
35395
|
if (rule.showValue === false) result2.hideValue = true;
|
|
35139
35396
|
return true;
|
|
@@ -35265,19 +35522,19 @@ var filled = (sheet, row2, col) => {
|
|
|
35265
35522
|
const cell = sheet.rows.get(row2)?.get(col);
|
|
35266
35523
|
return cell !== void 0 && (cell.value !== null && cell.value !== "" || cell.formula !== void 0);
|
|
35267
35524
|
};
|
|
35268
|
-
function step(
|
|
35269
|
-
for (let i2 =
|
|
35270
|
-
return
|
|
35525
|
+
function step(index3, dir, max, hidden) {
|
|
35526
|
+
for (let i2 = index3 + dir; i2 >= 0 && i2 <= max; i2 += dir) if (!hidden(i2)) return i2;
|
|
35527
|
+
return index3;
|
|
35271
35528
|
}
|
|
35272
35529
|
function edge(dir, max, hidden) {
|
|
35273
35530
|
const start = dir > 0 ? max : 0;
|
|
35274
35531
|
if (!hidden(start)) return start;
|
|
35275
35532
|
return step(start, dir > 0 ? -1 : 1, max, hidden);
|
|
35276
35533
|
}
|
|
35277
|
-
function jump(
|
|
35278
|
-
const next = step(
|
|
35279
|
-
if (next ===
|
|
35280
|
-
if (filledSet.has(
|
|
35534
|
+
function jump(index3, dir, max, hidden, filledSet) {
|
|
35535
|
+
const next = step(index3, dir, max, hidden);
|
|
35536
|
+
if (next === index3) return index3;
|
|
35537
|
+
if (filledSet.has(index3) && filledSet.has(next)) {
|
|
35281
35538
|
let at = next;
|
|
35282
35539
|
for (; ; ) {
|
|
35283
35540
|
const after = step(at, dir, max, hidden);
|
|
@@ -35285,7 +35542,7 @@ function jump(index2, dir, max, hidden, filledSet) {
|
|
|
35285
35542
|
at = after;
|
|
35286
35543
|
}
|
|
35287
35544
|
}
|
|
35288
|
-
const candidates = [...filledSet].filter((i2) => (dir > 0 ? i2 >
|
|
35545
|
+
const candidates = [...filledSet].filter((i2) => (dir > 0 ? i2 > index3 : i2 < index3) && !hidden(i2));
|
|
35289
35546
|
if (!candidates.length) return edge(dir, max, hidden);
|
|
35290
35547
|
return dir > 0 ? Math.min(...candidates) : Math.max(...candidates);
|
|
35291
35548
|
}
|
|
@@ -35390,7 +35647,7 @@ function autoFitColumnWidth(sheet, workbook, col, measure, mdw = DEFAULT_MAX_DIG
|
|
|
35390
35647
|
// chart/render/chart-colors.ts
|
|
35391
35648
|
function chartColorScheme(theme2) {
|
|
35392
35649
|
const slots = Object.fromEntries(
|
|
35393
|
-
THEME_SLOTS.map((slot2,
|
|
35650
|
+
THEME_SLOTS.map((slot2, index3) => [slot2, `#${themeColor(theme2, index3) ?? "000000"}`])
|
|
35394
35651
|
);
|
|
35395
35652
|
return {
|
|
35396
35653
|
...slots,
|
|
@@ -35409,8 +35666,8 @@ function modulateLuminance(hex, lumMod, lumOff = 0) {
|
|
|
35409
35666
|
const out = hslToRgb(hsl.h, hsl.s, l);
|
|
35410
35667
|
return rgbToUpperHex([out.r, out.g, out.b]);
|
|
35411
35668
|
}
|
|
35412
|
-
function autoSeriesColor(theme2,
|
|
35413
|
-
const i2 = Math.max(0, Math.floor(
|
|
35669
|
+
function autoSeriesColor(theme2, index3) {
|
|
35670
|
+
const i2 = Math.max(0, Math.floor(index3));
|
|
35414
35671
|
return chartPaletteSeriesColor(findChartColorPalette(10), i2, i2 + 1, chartColorScheme(theme2));
|
|
35415
35672
|
}
|
|
35416
35673
|
|
|
@@ -35562,10 +35819,10 @@ function resolveChartStyleDefinition(style2, resolve2) {
|
|
|
35562
35819
|
var NATIVE_COINCIDENT_STOP_RAMP = 1 / 256;
|
|
35563
35820
|
function spreadCoincidentStops(stops) {
|
|
35564
35821
|
const out = [];
|
|
35565
|
-
for (const [
|
|
35566
|
-
const source2 = stops[
|
|
35822
|
+
for (const [index3, stop] of stops.entries()) {
|
|
35823
|
+
const source2 = stops[index3 - 1];
|
|
35567
35824
|
const previous = out.at(-1);
|
|
35568
|
-
const next = stops[
|
|
35825
|
+
const next = stops[index3 + 1];
|
|
35569
35826
|
if (!source2 || !previous || stop.offset !== source2.offset || stop.color === source2.color && (stop.opacity ?? 1) === (source2.opacity ?? 1)) {
|
|
35570
35827
|
out.push(stop);
|
|
35571
35828
|
continue;
|
|
@@ -35815,9 +36072,9 @@ function resolveRef(ref, evaluateRef) {
|
|
|
35815
36072
|
return void 0;
|
|
35816
36073
|
}
|
|
35817
36074
|
}
|
|
35818
|
-
function seriesName(series,
|
|
36075
|
+
function seriesName(series, index3, evaluateRef) {
|
|
35819
36076
|
const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText2).filter((t) => t !== "").join(" ");
|
|
35820
|
-
return fromRef || series.name || `Series${
|
|
36077
|
+
return fromRef || series.name || `Series${index3 + 1}`;
|
|
35821
36078
|
}
|
|
35822
36079
|
function chartSummaryView(chart, theme2, options = {}) {
|
|
35823
36080
|
const evaluateRef = options.evaluateRef ?? (() => []);
|
|
@@ -35887,8 +36144,8 @@ function chartSummaryView(chart, theme2, options = {}) {
|
|
|
35887
36144
|
const points = chart.series[seriesIndex]?.pointColors;
|
|
35888
36145
|
if (points) s.pointColors = s.values.map((_, i2) => drawingColor(points[i2]) ?? s.color);
|
|
35889
36146
|
});
|
|
35890
|
-
series.forEach((s,
|
|
35891
|
-
const source2 = chart.series[
|
|
36147
|
+
series.forEach((s, index3) => {
|
|
36148
|
+
const source2 = chart.series[index3];
|
|
35892
36149
|
if (s.gradient && !radial && s.pointColors) {
|
|
35893
36150
|
for (let i2 = 0; i2 < s.pointColors.length; i2++)
|
|
35894
36151
|
if (!source2.pointColors?.[i2]) delete s.pointColors[i2];
|
|
@@ -36042,15 +36299,15 @@ function chartGradientPaint(model, width = 1024, height = 768) {
|
|
|
36042
36299
|
fillColor: paint(entry3.gradient, part, { width, height, shape: "rect" })
|
|
36043
36300
|
};
|
|
36044
36301
|
}
|
|
36045
|
-
const series = model.series.map((source2,
|
|
36302
|
+
const series = model.series.map((source2, index3) => {
|
|
36046
36303
|
const view = { ...source2 };
|
|
36047
|
-
if (source2.shadow) view.shadowFilter = shadowPaint(source2.shadow, `s${
|
|
36304
|
+
if (source2.shadow) view.shadowFilter = shadowPaint(source2.shadow, `s${index3}-shadow`);
|
|
36048
36305
|
const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
|
|
36049
|
-
if (source2.gradient) view.color = paint(source2.gradient, `s${
|
|
36306
|
+
if (source2.gradient) view.color = paint(source2.gradient, `s${index3}`, bounds);
|
|
36050
36307
|
if (source2.pointGradients) {
|
|
36051
36308
|
view.pointColors = [...source2.pointColors ?? []];
|
|
36052
36309
|
for (const [key, gradient] of Object.entries(source2.pointGradients))
|
|
36053
|
-
view.pointColors[Number(key)] = paint(gradient, `s${
|
|
36310
|
+
view.pointColors[Number(key)] = paint(gradient, `s${index3}-p${key}`, bounds);
|
|
36054
36311
|
}
|
|
36055
36312
|
return view;
|
|
36056
36313
|
});
|
|
@@ -36702,8 +36959,8 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36702
36959
|
hardLines.push(line3);
|
|
36703
36960
|
for (const run2 of paragraph2.runs) {
|
|
36704
36961
|
const pieces = run2.text.split("\n");
|
|
36705
|
-
for (const [
|
|
36706
|
-
if (
|
|
36962
|
+
for (const [index3, piece] of pieces.entries()) {
|
|
36963
|
+
if (index3) {
|
|
36707
36964
|
line3 = { ...paragraph2, runs: [] };
|
|
36708
36965
|
hardLines.push(line3);
|
|
36709
36966
|
}
|
|
@@ -36727,11 +36984,11 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36727
36984
|
{ breakWords: true }
|
|
36728
36985
|
);
|
|
36729
36986
|
const { spaceBefore, spaceAfter, ...properties2 } = line3;
|
|
36730
|
-
return wrapped.map((runs,
|
|
36987
|
+
return wrapped.map((runs, index3) => ({
|
|
36731
36988
|
...properties2,
|
|
36732
36989
|
runs,
|
|
36733
|
-
...
|
|
36734
|
-
...
|
|
36990
|
+
...index3 === 0 && spaceBefore ? { spaceBefore } : {},
|
|
36991
|
+
...index3 === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
|
|
36735
36992
|
}));
|
|
36736
36993
|
});
|
|
36737
36994
|
const metrics = lines.map((line3) => {
|
|
@@ -36776,9 +37033,9 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36776
37033
|
);
|
|
36777
37034
|
let baseline = 8 + (metrics[0]?.size ?? base.size ?? 14) + (vertical[0]?.before ?? 0) + (vertical[0]?.leading ?? 0);
|
|
36778
37035
|
const spans2 = [];
|
|
36779
|
-
for (const [
|
|
36780
|
-
if (
|
|
36781
|
-
baseline += vertical[
|
|
37036
|
+
for (const [index3, line3] of metrics.entries()) {
|
|
37037
|
+
if (index3)
|
|
37038
|
+
baseline += vertical[index3 - 1].descent + vertical[index3 - 1].after + vertical[index3].before + vertical[index3].ascent;
|
|
36782
37039
|
let x = line3.align === "l" ? (width - boxWidth) / 2 + 4 : line3.align === "r" ? (width + boxWidth) / 2 - 4 - line3.width : (width - line3.width) / 2;
|
|
36783
37040
|
for (const run2 of line3.runs) {
|
|
36784
37041
|
spans2.push(
|
|
@@ -37169,19 +37426,19 @@ function chunks(indices, size, capacity, breaks) {
|
|
|
37169
37426
|
const out = [];
|
|
37170
37427
|
let line3 = [];
|
|
37171
37428
|
let extent2 = 0;
|
|
37172
|
-
for (const
|
|
37429
|
+
for (const index3 of indices) {
|
|
37173
37430
|
let manual = false;
|
|
37174
|
-
while (cursor < sorted2.length && sorted2[cursor] <=
|
|
37431
|
+
while (cursor < sorted2.length && sorted2[cursor] <= index3) {
|
|
37175
37432
|
cursor++;
|
|
37176
37433
|
manual = true;
|
|
37177
37434
|
}
|
|
37178
|
-
if (line3.length && (manual || extent2 + size(
|
|
37435
|
+
if (line3.length && (manual || extent2 + size(index3) > capacity + 1e-3)) {
|
|
37179
37436
|
out.push(line3);
|
|
37180
37437
|
line3 = [];
|
|
37181
37438
|
extent2 = 0;
|
|
37182
37439
|
}
|
|
37183
|
-
line3.push(
|
|
37184
|
-
extent2 += size(
|
|
37440
|
+
line3.push(index3);
|
|
37441
|
+
extent2 += size(index3);
|
|
37185
37442
|
}
|
|
37186
37443
|
if (line3.length) out.push(line3);
|
|
37187
37444
|
return out;
|
|
@@ -37383,4 +37640,4 @@ function createPrintMergeIndex(merges, rows, columns) {
|
|
|
37383
37640
|
};
|
|
37384
37641
|
}
|
|
37385
37642
|
|
|
37386
|
-
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CHART_FILL_PARTS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_ANCHOR_EXTENT_EMU, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, MIN_TWO_CELL_PIXELS, OVERFLOW_TEXT, PERCENT_SCALE, PIVOT_AGGREGATES, PRINT_MARGINS, PRINT_PAPER_INCHES, PRINT_TITLES_NAME, REFERENCE_COLORS, THEME_SLOTS, TIME_PERIODS, acceptsReference, activeParam, addFuturePrefixes, anchorKind, anchorToPixelBox, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, callAtCaret, categoryTotals, cellError, cellInputText, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartBarSpacing, chartColorPalettePatch, chartColorScheme, chartDrawingColor, chartElementFill, chartElementFillPatch, chartElementGradientPatch, chartElementSolidFillPatch, chartElementTransparency, chartElementTransparencyPatch, chartGradientStopTransparency, chartSeriesFillPatch, chartSeriesGradientPatch, chartSeriesSolidColor, chartSeriesSolidFillPatch, chartSeriesTransparency, chartSeriesTransparencyPatch, chartView, chartWithElementFills, closeParens, coloredReferences, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createPrintMergeIndex, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatPrintTitleSpan, formatRange, formatRefSpec, formatSelectionStat, formatValue, formulaBarText, functionMatches, generalAlignment, getCell, getCellAt, getValue, hasSparklineAt, hls240ToRgb, inTimePeriod, insideString, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isFormulaText, isOverflowTarget, isSpilledCell, keyToAddress, layoutRemoteSelections, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mergeWouldDiscard, mixColors, modernPasswordHash, modulateLuminance, moveReferencesInFormula, nameAtCaret, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberInputText, numberToText, overflowExtent, pageHeaderFooter, paginateWorksheet, parseAddress, parseCellInput, parseFormula, parseHeaderFooter, parseHex, parseHtmlTable, parseNumberText, parsePrintTitleSpan, parseR1C1Range, parseRange, parseTsv, patchStyle, percentile, pictureAnchorAt, pivotGrid, pivotSourceData, pivotTableAt, pixelBoxToAnchor, pixelSizeToExtent, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, printRange, printTitles, printTitlesFormula, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, readSparklineGroup, readSparklineGroups, readSparklineValues, referenceSpans, referenceTarget, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, renderHeaderFooter, renderHeaderFooterRuns, replaceText, resolveColor, resolvePasteOptions, resolveSparklineRange, rgbToHls240, rotationDegrees, rowsToRefit, sameChartColor, saveXlsx, scaleColor, selectedSparklineGroups, selectionStats, serialToDate, sheetByName, sheetPageBreaks, sheetSparklineGroups, shiftFormula, shiftRange, shiftSpan, sparklineScale, sparklineValues, sparklineView, sparklineViewAt, spillAnchorOf, splice, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, syntaxParams, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, toggleAbsolute, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|
|
37643
|
+
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CHART_FILL_PARTS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_ANCHOR_EXTENT_EMU, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, MIN_TWO_CELL_PIXELS, OVERFLOW_TEXT, PERCENT_SCALE, PIVOT_AGGREGATES, PRINT_MARGINS, PRINT_PAPER_INCHES, PRINT_TITLES_NAME, REFERENCE_COLORS, THEME_SLOTS, TIME_PERIODS, acceptsReference, activeParam, addFuturePrefixes, anchorKind, anchorToPixelBox, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, callAtCaret, categoryTotals, cellError, cellInputText, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartBarSpacing, chartColorPalettePatch, chartColorScheme, chartDrawingColor, chartElementFill, chartElementFillPatch, chartElementGradientPatch, chartElementSolidFillPatch, chartElementTransparency, chartElementTransparencyPatch, chartGradientStopTransparency, chartSeriesFillPatch, chartSeriesGradientPatch, chartSeriesSolidColor, chartSeriesSolidFillPatch, chartSeriesTransparency, chartSeriesTransparencyPatch, chartView, chartWithElementFills, closeParens, coloredReferences, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createPrintMergeIndex, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatPrintTitleSpan, formatRange, formatRefSpec, formatSelectionStat, formatValue, formulaBarText, functionMatches, generalAlignment, getCell, getCellAt, getValue, hasSparklineAt, hls240ToRgb, inTimePeriod, insideString, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isFormulaText, isOverflowTarget, isSpilledCell, keyToAddress, layoutRemoteSelections, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mergeWouldDiscard, mixColors, modernPasswordHash, modulateLuminance, moveReferencesInFormula, nameAtCaret, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberInputText, numberToText, overflowExtent, pageHeaderFooter, paginateWorksheet, parseAddress, parseCellInput, parseFormula, parseHeaderFooter, parseHex, parseHtmlTable, parseNumberText, parsePrintTitleSpan, parseR1C1Range, parseRange, parseTsv, patchStyle, percentile, pictureAnchorAt, pivotGrid, pivotItemLabel as pivotPageItemLabel, pivotPageItems, pivotSourceData, pivotTableAt, pixelBoxToAnchor, pixelSizeToExtent, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, printRange, printTitles, printTitlesFormula, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, readSparklineGroup, readSparklineGroups, readSparklineValues, referenceSpans, referenceTarget, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, renderHeaderFooter, renderHeaderFooterRuns, replaceText, resolveColor, resolvePasteOptions, resolveSparklineRange, rgbToHls240, rotationDegrees, rowsToRefit, sameChartColor, saveXlsx, scaleColor, selectedSparklineGroups, selectionStats, serialToDate, sheetByName, sheetPageBreaks, sheetSparklineGroups, shiftFormula, shiftRange, shiftSpan, sparklineScale, sparklineValues, sparklineView, sparklineViewAt, spillAnchorOf, splice, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, syntaxParams, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, toggleAbsolute, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|