ooxml-core 1.9.0 → 1.11.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-EX4WBIQQ.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
- package/dist/automation/index.cjs +3236 -2258
- package/dist/automation/index.mjs +3236 -2258
- package/dist/{chunk-SWF7KVL5.cjs → chunk-2UVH6RHI.cjs} +1608 -1163
- package/dist/{chunk-M76PHYRR.mjs → chunk-7DSZI7S6.mjs} +1 -1
- package/dist/{chunk-AT66SA5M.cjs → chunk-7QZGRB3T.cjs} +28 -10
- package/dist/chunk-ANZ4Q6I3.cjs +21 -0
- package/dist/{chunk-CPKNMQLX.cjs → chunk-AWIDASUW.cjs} +25 -2
- package/dist/{chunk-SVQZXP3F.mjs → chunk-CBNKBVX5.mjs} +25 -2
- package/dist/{chunk-FIELY5PI.mjs → chunk-EC2W2MDY.mjs} +30 -2
- package/dist/chunk-EGTRL3QJ.mjs +19 -0
- package/dist/chunk-GXHKNSZX.mjs +9 -0
- package/dist/{chunk-OXHMZS7B.mjs → chunk-HCXUI5UC.mjs} +943 -273
- 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-IGOA57LE.mjs → chunk-U2DF3EGK.mjs} +1 -1
- package/dist/{chunk-OB277ZGE.mjs → chunk-UAY26XOI.mjs} +27 -9
- package/dist/{chunk-WSO4T2LJ.mjs → chunk-W5ARCUJB.mjs} +26 -3
- package/dist/chunk-XZPZHXV4.cjs +12 -0
- package/dist/{chunk-LCS3J3QI.mjs → chunk-YB5SRNFS.mjs} +717 -272
- package/dist/docx/layout/adapt-table.d.ts +2 -2
- 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 +554 -83
- package/dist/docx/layout/index.mjs +554 -84
- 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/nested-frame-profile.d.ts +9 -0
- package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -0
- package/dist/docx/layout/page-cursor.d.ts +2 -0
- package/dist/docx/layout/page-cursor.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +20 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/table-border-layout.d.ts +16 -0
- package/dist/docx/layout/table-border-layout.d.ts.map +1 -0
- package/dist/docx/layout/table-cell-layout.d.ts +3 -2
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-content.d.ts +4 -0
- package/dist/docx/layout/table-content.d.ts.map +1 -0
- package/dist/docx/layout/table-footnotes.d.ts +5 -0
- package/dist/docx/layout/table-footnotes.d.ts.map +1 -1
- package/dist/docx/layout/table-frames.d.ts +4 -0
- package/dist/docx/layout/table-frames.d.ts.map +1 -0
- package/dist/docx/layout/table-layout.d.ts +8 -3
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-note-completion.d.ts +5 -0
- package/dist/docx/layout/table-note-completion.d.ts.map +1 -0
- package/dist/docx/layout/table-note-stories.d.ts +6 -0
- package/dist/docx/layout/table-note-stories.d.ts.map +1 -0
- package/dist/pptx/automation/index.cjs +801 -296
- 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-BLodkuXE.d.ts → elements-DD3UGOMd.d.ts} +27 -3248
- package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-B4cnSPNz.d.ts → index-BZrFyNtU.d.ts} +113 -5
- package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-BZh-IMkN.d.ts → index-DdX02BSm.d.ts} +19 -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 +801 -296
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +1 -0
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +2 -2
- package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +19 -18
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +3 -2
- 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/remap-text.cjs +2 -2
- package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
- package/dist/pptx/editor/render/remap-text.mjs +1 -1
- 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 +1091 -296
- 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 +590 -122
- package/dist/teams/index.mjs +590 -122
- package/dist/visio/date-cache.d.ts +3 -0
- package/dist/visio/date-cache.d.ts.map +1 -0
- 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 +501 -220
- package/dist/visio/index.d.ts +1 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +501 -220
- package/dist/visio/model.d.ts +6 -0
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/shape-metadata.d.ts.map +1 -1
- 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-fraction.d.ts +3 -0
- package/dist/visio/text-field-fraction.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-numeric.d.ts +1 -1
- package/dist/visio/text-field-numeric.d.ts.map +1 -1
- package/dist/visio/text-field-source.d.ts +6 -0
- package/dist/visio/text-field-source.d.ts.map +1 -0
- package/dist/visio/text-field-system-date.d.ts +4 -0
- package/dist/visio/text-field-system-date.d.ts.map +1 -0
- package/dist/visio/text-fields.d.ts +1 -0
- package/dist/visio/text-fields.d.ts.map +1 -1
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +514 -221
- package/dist/visio/ui/index.mjs +514 -221
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/visio/ui/text-field-catalog.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1362 -659
- package/dist/xlsx/index.mjs +1361 -660
- package/dist/xlsx/load/index.cjs +1091 -430
- package/dist/xlsx/load/index.mjs +1091 -430
- package/dist/xlsx/model-pivots.d.ts +31 -2
- 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 +3 -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/hierarchy-first.d.ts +21 -0
- package/dist/xlsx/pivot/hierarchy-first.d.ts.map +1 -0
- package/dist/xlsx/pivot/hierarchy.d.ts +2 -4
- package/dist/xlsx/pivot/hierarchy.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 +13 -0
- package/dist/xlsx/pivot/measures.d.ts.map +1 -0
- 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 +12 -0
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -0
- 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 +640 -137
- package/dist/xlsx/ui/index.mjs +640 -137
- package/package.json +2 -2
- package/dist/PptxHandler-AT7FVG5Q.mjs +0 -2
- package/dist/PptxHandler-VFSCECPL.cjs +0 -11
- package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +0 -1
- package/dist/pptx/chunks/index-BZh-IMkN.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts +0 -2970
- package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BLodkuXE.d.ts.map +0 -1
package/dist/xlsx/index.cjs
CHANGED
|
@@ -282,7 +282,7 @@ function createWorksheet(name, sheetId) {
|
|
|
282
282
|
function createWorkbook(options = {}) {
|
|
283
283
|
const names = options.sheets?.length ? options.sheets : ["Sheet1"];
|
|
284
284
|
return {
|
|
285
|
-
sheets: names.map((name,
|
|
285
|
+
sheets: names.map((name, index3) => createWorksheet(name, index3 + 1)),
|
|
286
286
|
styles: [defaultCellStyle()],
|
|
287
287
|
namedStyles: [{ name: "Normal", style: defaultCellStyle(), builtinId: 0 }],
|
|
288
288
|
definedNames: [],
|
|
@@ -304,7 +304,7 @@ function validateSheetName(workbook, name, exceptIndex = -1) {
|
|
|
304
304
|
return "A sheet name cannot start or end with an apostrophe.";
|
|
305
305
|
if (name.toLowerCase() === "history") return '"History" is reserved by Excel.';
|
|
306
306
|
const clash = workbook.sheets.findIndex(
|
|
307
|
-
(sheet,
|
|
307
|
+
(sheet, index3) => index3 !== exceptIndex && sheet.name.toLowerCase() === name.toLowerCase()
|
|
308
308
|
);
|
|
309
309
|
return clash >= 0 ? "That name is already taken." : void 0;
|
|
310
310
|
}
|
|
@@ -343,10 +343,10 @@ function internStyle(workbook, style2) {
|
|
|
343
343
|
const known = cache3.get(key);
|
|
344
344
|
if (known !== void 0 && workbook.styles[known] && styleKey(workbook.styles[known]) === key)
|
|
345
345
|
return known;
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
348
|
-
cache3.set(key,
|
|
349
|
-
return
|
|
346
|
+
const index3 = workbook.styles.findIndex((candidate) => styleKey(candidate) === key);
|
|
347
|
+
if (index3 >= 0) {
|
|
348
|
+
cache3.set(key, index3);
|
|
349
|
+
return index3;
|
|
350
350
|
}
|
|
351
351
|
workbook.styles.push(style2);
|
|
352
352
|
cache3.set(key, workbook.styles.length - 1);
|
|
@@ -1752,10 +1752,10 @@ var MONTH_NAMES = [
|
|
|
1752
1752
|
function monthFromName(name) {
|
|
1753
1753
|
const lower2 = name.toLowerCase();
|
|
1754
1754
|
if (lower2.length < 3) return void 0;
|
|
1755
|
-
const
|
|
1755
|
+
const index3 = MONTH_NAMES.findIndex(
|
|
1756
1756
|
(m) => m.startsWith(lower2) || lower2.length > 3 && lower2 === m
|
|
1757
1757
|
);
|
|
1758
|
-
return
|
|
1758
|
+
return index3 < 0 ? void 0 : index3 + 1;
|
|
1759
1759
|
}
|
|
1760
1760
|
function fullYear(text3) {
|
|
1761
1761
|
const y = Number(text3);
|
|
@@ -3010,10 +3010,10 @@ var MONTHS2 = [
|
|
|
3010
3010
|
function monthFromName2(name) {
|
|
3011
3011
|
const lower2 = name.toLowerCase();
|
|
3012
3012
|
if (lower2.length < 3) return void 0;
|
|
3013
|
-
const
|
|
3014
|
-
if (
|
|
3015
|
-
const full = new Date(Date.UTC(2e3,
|
|
3016
|
-
return lower2.length === 3 || full.startsWith(lower2) || lower2 === "sept" ?
|
|
3013
|
+
const index3 = MONTHS2.findIndex((m) => lower2.startsWith(m));
|
|
3014
|
+
if (index3 < 0) return void 0;
|
|
3015
|
+
const full = new Date(Date.UTC(2e3, index3, 1)).toLocaleString("en-US", { month: "long", timeZone: "UTC" }).toLowerCase();
|
|
3016
|
+
return lower2.length === 3 || full.startsWith(lower2) || lower2 === "sept" ? index3 + 1 : void 0;
|
|
3017
3017
|
}
|
|
3018
3018
|
var NUMBER_RE3 = /^(\d+(?:,\d{3,})+|\d*)(\.\d*)?(?:e([+-]?\d+))?$/i;
|
|
3019
3019
|
var TIME_RE2 = /^(\d{1,4})(?::(\d+))?(?::(\d+(?:\.\d*)?))?(?:\s+(am|pm|a|p))?$/i;
|
|
@@ -3781,11 +3781,11 @@ function sort(args, ctx) {
|
|
|
3781
3781
|
if (byCol) m = transpose(m);
|
|
3782
3782
|
const indexes2 = args.length > 1 && args[1] !== null ? ctx.toMatrix(args[1] ?? null).flat().map((v) => Math.trunc(num(v))) : [1];
|
|
3783
3783
|
const orders = args.length > 2 && args[2] !== null ? ctx.toMatrix(args[2] ?? null).flat().map((v) => num(v)) : [1];
|
|
3784
|
-
const keys = indexes2.map((
|
|
3785
|
-
if (
|
|
3784
|
+
const keys = indexes2.map((index3, k) => {
|
|
3785
|
+
if (index3 < 1 || index3 > m.cols) fail(ERR.VALUE);
|
|
3786
3786
|
const order = orders[Math.min(k, orders.length - 1)] ?? 1;
|
|
3787
3787
|
if (order !== 1 && order !== -1) fail(ERR.VALUE);
|
|
3788
|
-
return { values: m.data.map((row2) => row2[
|
|
3788
|
+
return { values: m.data.map((row2) => row2[index3 - 1] ?? null), descending: order === -1 };
|
|
3789
3789
|
});
|
|
3790
3790
|
const sorted2 = new Matrix(sortRows(m.data, keys));
|
|
3791
3791
|
return byCol ? transpose(sorted2) : sorted2;
|
|
@@ -3913,14 +3913,14 @@ var ARRAY_FUNCTIONS = [
|
|
|
3913
3913
|
const cols = optInt(ctx, args, 1, 1);
|
|
3914
3914
|
const min = args.length > 2 && args[2] !== null ? num(ctx.toScalar(args[2] ?? null)) : 0;
|
|
3915
3915
|
const max = args.length > 3 && args[3] !== null ? num(ctx.toScalar(args[3] ?? null)) : 1;
|
|
3916
|
-
const
|
|
3916
|
+
const integer2 = args.length > 4 && args[4] !== null && toBool(ctx.toScalar(args[4] ?? null));
|
|
3917
3917
|
if (rows < 1 || cols < 1) return ERR.CALC;
|
|
3918
3918
|
if (min > max) fail(ERR.VALUE);
|
|
3919
3919
|
const random = () => ctx.frame.host.random();
|
|
3920
3920
|
return Matrix.build(
|
|
3921
3921
|
rows,
|
|
3922
3922
|
cols,
|
|
3923
|
-
() =>
|
|
3923
|
+
() => integer2 ? Math.ceil(min) + Math.floor(random() * (Math.floor(max) - Math.ceil(min) + 1)) : min + random() * (max - min)
|
|
3924
3924
|
);
|
|
3925
3925
|
},
|
|
3926
3926
|
["any"],
|
|
@@ -3975,8 +3975,8 @@ function modes(values2) {
|
|
|
3975
3975
|
function kth(values2, k, largest) {
|
|
3976
3976
|
const n2 = values2.length;
|
|
3977
3977
|
if (n2 === 0 || !(k >= 1) || k > n2) fail(ERR.NUM);
|
|
3978
|
-
const
|
|
3979
|
-
return sorted(values2)[
|
|
3978
|
+
const index3 = Math.floor(largest ? n2 + 1 - k : k) - 1;
|
|
3979
|
+
return sorted(values2)[index3];
|
|
3980
3980
|
}
|
|
3981
3981
|
function extreme(values2, max) {
|
|
3982
3982
|
if (values2.length === 0) return 0;
|
|
@@ -4116,13 +4116,13 @@ function fieldIndex(table2, field) {
|
|
|
4116
4116
|
const value2 = scalar(field);
|
|
4117
4117
|
if (isError(value2)) fail(value2);
|
|
4118
4118
|
if (typeof value2 === "number") {
|
|
4119
|
-
const
|
|
4120
|
-
if (
|
|
4121
|
-
return
|
|
4119
|
+
const index4 = Math.trunc(value2) - 1;
|
|
4120
|
+
if (index4 < 0 || index4 >= table2.headers.length) fail(ERR.VALUE);
|
|
4121
|
+
return index4;
|
|
4122
4122
|
}
|
|
4123
|
-
const
|
|
4124
|
-
if (
|
|
4125
|
-
return
|
|
4123
|
+
const index3 = table2.headers.indexOf(label(value2).toLowerCase());
|
|
4124
|
+
if (index3 < 0) fail(ERR.VALUE);
|
|
4125
|
+
return index3;
|
|
4126
4126
|
}
|
|
4127
4127
|
function recordFilter(table2, criteria) {
|
|
4128
4128
|
const [head, ...rows] = criteria;
|
|
@@ -5408,8 +5408,8 @@ function cumulative(args, principal) {
|
|
|
5408
5408
|
|
|
5409
5409
|
// xlsx/formula/functions/bonds.ts
|
|
5410
5410
|
var C9 = "Financial";
|
|
5411
|
-
var basisOf = (args,
|
|
5412
|
-
const basis = args.length >
|
|
5411
|
+
var basisOf = (args, index3) => {
|
|
5412
|
+
const basis = args.length > index3 && args[index3] !== null ? int(args[index3]) : 0;
|
|
5413
5413
|
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5414
5414
|
return basis;
|
|
5415
5415
|
};
|
|
@@ -5591,9 +5591,9 @@ var AMORLINC = {
|
|
|
5591
5591
|
}
|
|
5592
5592
|
const fraction = purchase === firstPeriod ? 1 : basis === 1 ? (firstPeriod - purchase) / (isLeapYear(serialToYmd(purchase, ctx.date1904).year) ? 366 : 365) : yearFrac(purchase, firstPeriod, basis, ctx);
|
|
5593
5593
|
const first2 = Math.min(cost - salvage, annual * fraction);
|
|
5594
|
-
const
|
|
5595
|
-
if (
|
|
5596
|
-
return Math.max(0, Math.min(annual, cost - salvage - first2 - (
|
|
5594
|
+
const index3 = Math.trunc(period);
|
|
5595
|
+
if (index3 === 0) return first2;
|
|
5596
|
+
return Math.max(0, Math.min(annual, cost - salvage - first2 - (index3 - 1) * annual));
|
|
5597
5597
|
}
|
|
5598
5598
|
),
|
|
5599
5599
|
missingRequiredError: "#N/A"
|
|
@@ -5820,8 +5820,8 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5820
5820
|
|
|
5821
5821
|
// xlsx/formula/functions/securities.ts
|
|
5822
5822
|
var C11 = "Financial";
|
|
5823
|
-
var basisOf2 = (args,
|
|
5824
|
-
const basis = args.length >
|
|
5823
|
+
var basisOf2 = (args, index3) => {
|
|
5824
|
+
const basis = args.length > index3 && args[index3] !== null ? int(args[index3]) : 0;
|
|
5825
5825
|
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
5826
5826
|
return basis;
|
|
5827
5827
|
};
|
|
@@ -6187,8 +6187,8 @@ function resolveStructured(ref, frame) {
|
|
|
6187
6187
|
const totalsRow = table2.totalsRow ? range.end.row : -1;
|
|
6188
6188
|
const columnOf = (name) => {
|
|
6189
6189
|
const lower2 = name.toLowerCase();
|
|
6190
|
-
const
|
|
6191
|
-
return
|
|
6190
|
+
const index3 = table2.columns.findIndex((c3) => c3.name.toLowerCase() === lower2);
|
|
6191
|
+
return index3 < 0 ? -1 : range.start.col + index3;
|
|
6192
6192
|
};
|
|
6193
6193
|
let c1 = range.start.col;
|
|
6194
6194
|
let c2 = range.end.col;
|
|
@@ -6433,8 +6433,8 @@ var INFO_FUNCTIONS = [
|
|
|
6433
6433
|
const v = args[0];
|
|
6434
6434
|
if (v === void 0) return ctx.sheet + 1;
|
|
6435
6435
|
if (v instanceof RefValue) return (v.areas[0]?.sheet ?? ctx.sheet) + 1;
|
|
6436
|
-
const
|
|
6437
|
-
return
|
|
6436
|
+
const index3 = sheetIndex(ctx.frame.host, str(v));
|
|
6437
|
+
return index3 < 0 ? ERR.NA : index3 + 1;
|
|
6438
6438
|
},
|
|
6439
6439
|
["any"]
|
|
6440
6440
|
),
|
|
@@ -6992,14 +6992,14 @@ function shape(value2) {
|
|
|
6992
6992
|
if (value2 instanceof Matrix) return { rows: value2.rows, cols: value2.cols };
|
|
6993
6993
|
return { rows: 1, cols: 1 };
|
|
6994
6994
|
}
|
|
6995
|
-
function line(ctx, value2, axis,
|
|
6995
|
+
function line(ctx, value2, axis, index3) {
|
|
6996
6996
|
if (value2 instanceof RefValue) {
|
|
6997
6997
|
const area = value2.areas[0];
|
|
6998
6998
|
if (!area || value2.areas.length !== 1) fail(ERR.VALUE);
|
|
6999
6999
|
const { start, end } = area.range;
|
|
7000
7000
|
const bounds = ctx.frame.host.bounds(area.sheet);
|
|
7001
7001
|
if (axis === "col") {
|
|
7002
|
-
const col = start.col +
|
|
7002
|
+
const col = start.col + index3;
|
|
7003
7003
|
const length2 = Math.max(0, Math.min(end.row, bounds.rows - 1) - start.row + 1);
|
|
7004
7004
|
return {
|
|
7005
7005
|
length: length2,
|
|
@@ -7007,7 +7007,7 @@ function line(ctx, value2, axis, index2) {
|
|
|
7007
7007
|
get: (i2) => ctx.readCell(area.sheet, start.row + i2, col)
|
|
7008
7008
|
};
|
|
7009
7009
|
}
|
|
7010
|
-
const row2 = start.row +
|
|
7010
|
+
const row2 = start.row + index3;
|
|
7011
7011
|
const length = Math.max(0, Math.min(end.col, bounds.cols - 1) - start.col + 1);
|
|
7012
7012
|
return {
|
|
7013
7013
|
length,
|
|
@@ -7016,8 +7016,8 @@ function line(ctx, value2, axis, index2) {
|
|
|
7016
7016
|
};
|
|
7017
7017
|
}
|
|
7018
7018
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
7019
|
-
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2,
|
|
7020
|
-
return { length: m.cols, get: (i2) => m.get(
|
|
7019
|
+
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2, index3) };
|
|
7020
|
+
return { length: m.cols, get: (i2) => m.get(index3, i2) };
|
|
7021
7021
|
}
|
|
7022
7022
|
function vectorOf(ctx, value2) {
|
|
7023
7023
|
const { rows, cols } = shape(value2);
|
|
@@ -7411,24 +7411,24 @@ function cellOf(value2, row2, col) {
|
|
|
7411
7411
|
if (value2 instanceof Matrix) return value2.get(row2, col);
|
|
7412
7412
|
return value2;
|
|
7413
7413
|
}
|
|
7414
|
-
function sliceOf(value2, axis,
|
|
7414
|
+
function sliceOf(value2, axis, index3) {
|
|
7415
7415
|
const { rows } = shape(value2);
|
|
7416
7416
|
if (value2 instanceof RefValue) {
|
|
7417
7417
|
const area = value2.areas[0];
|
|
7418
7418
|
if (!area) fail(ERR.REF);
|
|
7419
7419
|
const { start, end } = area.range;
|
|
7420
7420
|
const range = axis === "row" ? {
|
|
7421
|
-
start: { row: start.row +
|
|
7422
|
-
end: { row: start.row +
|
|
7421
|
+
start: { row: start.row + index3, col: start.col },
|
|
7422
|
+
end: { row: start.row + index3, col: end.col }
|
|
7423
7423
|
} : {
|
|
7424
|
-
start: { row: start.row, col: start.col +
|
|
7425
|
-
end: { row: end.row, col: start.col +
|
|
7424
|
+
start: { row: start.row, col: start.col + index3 },
|
|
7425
|
+
end: { row: end.row, col: start.col + index3 }
|
|
7426
7426
|
};
|
|
7427
7427
|
return new RefValue([{ sheet: area.sheet, range }]);
|
|
7428
7428
|
}
|
|
7429
7429
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
7430
|
-
if (axis === "row") return new Matrix([m.data[
|
|
7431
|
-
return new Matrix(Array.from({ length: rows }, (_, r) => [m.get(r,
|
|
7430
|
+
if (axis === "row") return new Matrix([m.data[index3] ?? []]);
|
|
7431
|
+
return new Matrix(Array.from({ length: rows }, (_, r) => [m.get(r, index3)]));
|
|
7432
7432
|
}
|
|
7433
7433
|
function lookupValue(args) {
|
|
7434
7434
|
const v = scalar(args[0]);
|
|
@@ -7444,15 +7444,15 @@ function lookupArray(value2) {
|
|
|
7444
7444
|
function vhlookup(args, ctx, vertical) {
|
|
7445
7445
|
const lookup2 = blankAsZero(args);
|
|
7446
7446
|
const table2 = lookupArray(args[1] ?? null);
|
|
7447
|
-
const
|
|
7447
|
+
const index3 = int(args[2]);
|
|
7448
7448
|
const approximate2 = args.length < 4 ? true : bool(args[3]);
|
|
7449
7449
|
const { rows, cols } = shape(table2);
|
|
7450
|
-
if (
|
|
7451
|
-
if (
|
|
7450
|
+
if (index3 < 1) fail(ERR.VALUE);
|
|
7451
|
+
if (index3 > (vertical ? cols : rows)) fail(ERR.REF);
|
|
7452
7452
|
const keys = line(ctx, table2, vertical ? "col" : "row", 0);
|
|
7453
7453
|
const at = approximate2 ? findAscending(keys, lookup2) : findExact(keys, lookup2, true);
|
|
7454
7454
|
if (at < 0) fail(ERR.NA);
|
|
7455
|
-
return vertical ? cellOf(table2, at,
|
|
7455
|
+
return vertical ? cellOf(table2, at, index3 - 1) : cellOf(table2, index3 - 1, at);
|
|
7456
7456
|
}
|
|
7457
7457
|
function match(args, ctx) {
|
|
7458
7458
|
const lookup2 = blankAsZero(args);
|
|
@@ -7651,27 +7651,27 @@ function valueKeys(value2, out) {
|
|
|
7651
7651
|
}
|
|
7652
7652
|
}
|
|
7653
7653
|
function positionsOf(block, key) {
|
|
7654
|
-
let
|
|
7655
|
-
if (!
|
|
7654
|
+
let index3 = indexes.get(block);
|
|
7655
|
+
if (!index3) {
|
|
7656
7656
|
const count2 = (uses.get(block) ?? 0) + 1;
|
|
7657
7657
|
uses.set(block, count2);
|
|
7658
7658
|
if (count2 < 2 || block.isPadded) return void 0;
|
|
7659
|
-
|
|
7659
|
+
index3 = /* @__PURE__ */ new Map();
|
|
7660
7660
|
const keys = [];
|
|
7661
7661
|
const cols = block.cols;
|
|
7662
7662
|
for (let r = 0; r < block.rows; r++) {
|
|
7663
7663
|
for (let c2 = 0; c2 < cols; c2++) {
|
|
7664
7664
|
valueKeys(block.get(r, c2), keys);
|
|
7665
7665
|
for (const k of keys) {
|
|
7666
|
-
const list =
|
|
7666
|
+
const list = index3.get(k);
|
|
7667
7667
|
if (list) list.push(r * cols + c2);
|
|
7668
|
-
else
|
|
7668
|
+
else index3.set(k, [r * cols + c2]);
|
|
7669
7669
|
}
|
|
7670
7670
|
}
|
|
7671
7671
|
}
|
|
7672
|
-
indexes.set(block,
|
|
7672
|
+
indexes.set(block, index3);
|
|
7673
7673
|
}
|
|
7674
|
-
return
|
|
7674
|
+
return index3.get(key) ?? [];
|
|
7675
7675
|
}
|
|
7676
7676
|
|
|
7677
7677
|
// xlsx/formula/functions/criteria.ts
|
|
@@ -8888,7 +8888,7 @@ function layout(ctx, args) {
|
|
|
8888
8888
|
}
|
|
8889
8889
|
return { y, x, column };
|
|
8890
8890
|
}
|
|
8891
|
-
var withConst = (args,
|
|
8891
|
+
var withConst = (args, index3) => omitted(args, index3) ? true : bool(args[index3]);
|
|
8892
8892
|
var row = (values2, width) => [
|
|
8893
8893
|
...values2,
|
|
8894
8894
|
...new Array(Math.max(0, width - values2.length)).fill(ERR.NA)
|
|
@@ -11202,7 +11202,7 @@ function compile(pattern, caseMode2, global) {
|
|
|
11202
11202
|
return fail(ERR.VALUE);
|
|
11203
11203
|
}
|
|
11204
11204
|
}
|
|
11205
|
-
var caseMode = (args,
|
|
11205
|
+
var caseMode = (args, index3) => optNum(args, index3, 0);
|
|
11206
11206
|
function encodeUrl(text3) {
|
|
11207
11207
|
return encodeURIComponent(text3).replace(
|
|
11208
11208
|
/[!'()*]/g,
|
|
@@ -11321,9 +11321,9 @@ function textAround(args, ctx, before) {
|
|
|
11321
11321
|
if (instance > 0) found.push({ at: text3.length, length: 0 });
|
|
11322
11322
|
else found.unshift({ at: 0, length: 0 });
|
|
11323
11323
|
}
|
|
11324
|
-
const
|
|
11325
|
-
const hit = found[
|
|
11326
|
-
if (!hit ||
|
|
11324
|
+
const index3 = instance > 0 ? instance - 1 : found.length + instance;
|
|
11325
|
+
const hit = found[index3];
|
|
11326
|
+
if (!hit || index3 < 0) return notFound;
|
|
11327
11327
|
return before ? text3.slice(0, hit.at) : text3.slice(hit.at + hit.length);
|
|
11328
11328
|
}
|
|
11329
11329
|
function splitText(text3, delimiters, insensitive, ignoreEmpty) {
|
|
@@ -11439,10 +11439,10 @@ var FUNCTION_CATALOG = Object.freeze(
|
|
|
11439
11439
|
);
|
|
11440
11440
|
|
|
11441
11441
|
// xlsx/formula/functions/types.ts
|
|
11442
|
-
var paramKind = (spec2,
|
|
11442
|
+
var paramKind = (spec2, index3) => {
|
|
11443
11443
|
const params = spec2.params;
|
|
11444
11444
|
if (!params || params.length === 0) return "value";
|
|
11445
|
-
return params[Math.min(
|
|
11445
|
+
return params[Math.min(index3, params.length - 1)] ?? "value";
|
|
11446
11446
|
};
|
|
11447
11447
|
|
|
11448
11448
|
// xlsx/formula/call.ts
|
|
@@ -12378,16 +12378,16 @@ var EngineHost = class {
|
|
|
12378
12378
|
}
|
|
12379
12379
|
/** Formulas by the area their spill or CSE array covers (spatial lookup for every read). */
|
|
12380
12380
|
footprintsBy() {
|
|
12381
|
-
let
|
|
12382
|
-
if (!
|
|
12383
|
-
|
|
12381
|
+
let index3 = this.footprintIndex;
|
|
12382
|
+
if (!index3) {
|
|
12383
|
+
index3 = new AreaIndex();
|
|
12384
12384
|
for (const node of this.footprints) {
|
|
12385
12385
|
const fp = node.spill ?? node.blockedSpill ?? node.arrayRange;
|
|
12386
|
-
if (fp)
|
|
12386
|
+
if (fp) index3.add({ sheet: node.sheet, range: fp }, node);
|
|
12387
12387
|
}
|
|
12388
|
-
this.footprintIndex =
|
|
12388
|
+
this.footprintIndex = index3;
|
|
12389
12389
|
}
|
|
12390
|
-
return
|
|
12390
|
+
return index3;
|
|
12391
12391
|
}
|
|
12392
12392
|
allNodes() {
|
|
12393
12393
|
const out = [];
|
|
@@ -12404,17 +12404,17 @@ var EngineHost = class {
|
|
|
12404
12404
|
|
|
12405
12405
|
// xlsx/formula/scc.ts
|
|
12406
12406
|
function stronglyConnected(nodes, successors) {
|
|
12407
|
-
const
|
|
12407
|
+
const index3 = /* @__PURE__ */ new Map();
|
|
12408
12408
|
const low = /* @__PURE__ */ new Map();
|
|
12409
12409
|
const onStack = /* @__PURE__ */ new Set();
|
|
12410
12410
|
const stack2 = [];
|
|
12411
12411
|
const out = [];
|
|
12412
12412
|
let counter = 0;
|
|
12413
12413
|
for (const root of nodes) {
|
|
12414
|
-
if (
|
|
12414
|
+
if (index3.has(root)) continue;
|
|
12415
12415
|
const work = [];
|
|
12416
12416
|
const open = (node) => {
|
|
12417
|
-
|
|
12417
|
+
index3.set(node, counter);
|
|
12418
12418
|
low.set(node, counter);
|
|
12419
12419
|
counter++;
|
|
12420
12420
|
stack2.push(node);
|
|
@@ -12426,9 +12426,9 @@ function stronglyConnected(nodes, successors) {
|
|
|
12426
12426
|
const frame = work[work.length - 1];
|
|
12427
12427
|
if (frame.i < frame.succ.length) {
|
|
12428
12428
|
const next = frame.succ[frame.i++];
|
|
12429
|
-
if (!
|
|
12429
|
+
if (!index3.has(next)) open(next);
|
|
12430
12430
|
else if (onStack.has(next)) {
|
|
12431
|
-
low.set(frame.node, Math.min(low.get(frame.node),
|
|
12431
|
+
low.set(frame.node, Math.min(low.get(frame.node), index3.get(next)));
|
|
12432
12432
|
}
|
|
12433
12433
|
continue;
|
|
12434
12434
|
}
|
|
@@ -12439,7 +12439,7 @@ function stronglyConnected(nodes, successors) {
|
|
|
12439
12439
|
parent.node,
|
|
12440
12440
|
Math.min(low.get(parent.node), low.get(frame.node))
|
|
12441
12441
|
);
|
|
12442
|
-
if (low.get(frame.node) ===
|
|
12442
|
+
if (low.get(frame.node) === index3.get(frame.node)) {
|
|
12443
12443
|
const component = [];
|
|
12444
12444
|
let member;
|
|
12445
12445
|
do {
|
|
@@ -13645,9 +13645,9 @@ function renameTableColumnInFormula(formula, tableName, oldName, newName, inside
|
|
|
13645
13645
|
if (!tokens2) return formula;
|
|
13646
13646
|
const escaped = newName.replace(/['#@[\]]/g, "'$&");
|
|
13647
13647
|
let changed = false;
|
|
13648
|
-
for (const [
|
|
13648
|
+
for (const [index3, token] of tokens2.entries()) {
|
|
13649
13649
|
if (token.kind !== "structured" || token.prefix) continue;
|
|
13650
|
-
if (token.value === "" && tokens2[
|
|
13650
|
+
if (token.value === "" && tokens2[index3 - 1]?.prefix) continue;
|
|
13651
13651
|
if (token.value === "" ? !insideTable : String(token.value).toLowerCase() !== tableName.toLowerCase())
|
|
13652
13652
|
continue;
|
|
13653
13653
|
const next = token.text.replace(
|
|
@@ -13671,13 +13671,13 @@ var abs = (row2, col, rowAbs = true) => `$${columnLabel(col)}${rowAbs ? "$" : ""
|
|
|
13671
13671
|
function a1For(ref, t) {
|
|
13672
13672
|
const { table: table2 } = t;
|
|
13673
13673
|
const { start, end } = table2.range;
|
|
13674
|
-
const
|
|
13674
|
+
const index3 = (name) => {
|
|
13675
13675
|
if (name === void 0) return void 0;
|
|
13676
13676
|
const i2 = table2.columns.findIndex((c3) => c3.name.toLowerCase() === name.toLowerCase());
|
|
13677
13677
|
return i2 < 0 ? -1 : start.col + i2;
|
|
13678
13678
|
};
|
|
13679
|
-
const c1 =
|
|
13680
|
-
const c2 =
|
|
13679
|
+
const c1 = index3(ref.column);
|
|
13680
|
+
const c2 = index3(ref.column2) ?? c1;
|
|
13681
13681
|
if (c1 === -1 || c2 === -1) return "#REF!";
|
|
13682
13682
|
const colLo = c1 ?? start.col;
|
|
13683
13683
|
const colHi = c2 ?? end.col;
|
|
@@ -13829,17 +13829,17 @@ function coloredReferences(text3) {
|
|
|
13829
13829
|
const seen = /* @__PURE__ */ new Map();
|
|
13830
13830
|
return referenceSpans(text3.slice(1), "").map((span3) => {
|
|
13831
13831
|
const key = span3.text.replace(/\$/g, "").toUpperCase();
|
|
13832
|
-
let
|
|
13833
|
-
if (
|
|
13834
|
-
|
|
13835
|
-
seen.set(key,
|
|
13832
|
+
let index3 = seen.get(key);
|
|
13833
|
+
if (index3 === void 0) {
|
|
13834
|
+
index3 = seen.size;
|
|
13835
|
+
seen.set(key, index3);
|
|
13836
13836
|
}
|
|
13837
13837
|
return {
|
|
13838
13838
|
start: span3.start + 1,
|
|
13839
13839
|
end: span3.end + 1,
|
|
13840
13840
|
text: span3.text,
|
|
13841
|
-
index:
|
|
13842
|
-
color: REFERENCE_COLORS[
|
|
13841
|
+
index: index3,
|
|
13842
|
+
color: REFERENCE_COLORS[index3 % REFERENCE_COLORS.length] ?? REFERENCE_COLORS[0]
|
|
13843
13843
|
};
|
|
13844
13844
|
});
|
|
13845
13845
|
}
|
|
@@ -14497,7 +14497,7 @@ var PartPatch = class {
|
|
|
14497
14497
|
const { root, children: children2 } = scan3(xml);
|
|
14498
14498
|
const kids2 = elements(rootElement);
|
|
14499
14499
|
if (kids2.length !== children2.length) throw new Error("Property part markup is not supported");
|
|
14500
|
-
kids2.forEach((kid,
|
|
14500
|
+
kids2.forEach((kid, index3) => this.spans.set(kid, children2[index3]));
|
|
14501
14501
|
this.root = root;
|
|
14502
14502
|
for (const attribute2 of Array.from(rootElement.attributes)) {
|
|
14503
14503
|
if (attribute2.name === "xmlns") this.defaultNs = attribute2.value;
|
|
@@ -14747,7 +14747,7 @@ function writeAppProperties(props, sourceXml) {
|
|
|
14747
14747
|
const patch3 = new PartPatch(xml, root);
|
|
14748
14748
|
const prior = readKnown(root, ns);
|
|
14749
14749
|
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
14750
|
-
FIELDS2.forEach(([field, local, kind],
|
|
14750
|
+
FIELDS2.forEach(([field, local, kind], index3) => {
|
|
14751
14751
|
const value2 = props[field];
|
|
14752
14752
|
const existing = first(root, local, ns.app);
|
|
14753
14753
|
if (value2 === void 0 || kind === "text" && value2 === "") {
|
|
@@ -14761,7 +14761,7 @@ function writeAppProperties(props, sourceXml) {
|
|
|
14761
14761
|
patch3.setContent(existing, body);
|
|
14762
14762
|
return;
|
|
14763
14763
|
}
|
|
14764
|
-
const next = FIELDS2.slice(
|
|
14764
|
+
const next = FIELDS2.slice(index3 + 1).map(([, name]) => first(root, name, ns.app)).find((node) => node !== void 0);
|
|
14765
14765
|
patch3.insert(`<${ownPrefix}${local}>${body}</${ownPrefix}${local}>`, next);
|
|
14766
14766
|
});
|
|
14767
14767
|
return patch3.toString();
|
|
@@ -14856,9 +14856,9 @@ function writeCustomProperties(properties2) {
|
|
|
14856
14856
|
});
|
|
14857
14857
|
if (!unique2.length) return void 0;
|
|
14858
14858
|
const pids = allocateCustomPropertyIds(unique2);
|
|
14859
|
-
const body = unique2.map((property,
|
|
14859
|
+
const body = unique2.map((property, index3) => {
|
|
14860
14860
|
const link = property.linkTarget ? ` linkTarget="${escape(property.linkTarget, true)}"` : "";
|
|
14861
|
-
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[
|
|
14861
|
+
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[index3] ?? index3 + 2}" name="${escape(property.name, true)}"${link}>${variantXml(property)}</property>`;
|
|
14862
14862
|
}).join("");
|
|
14863
14863
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
14864
14864
|
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
@@ -14953,9 +14953,9 @@ function sparklineDataRange(workbook, sheet, source2) {
|
|
|
14953
14953
|
}
|
|
14954
14954
|
if (ast.type !== "ref" || !ast.ref || !["cell", "area"].includes(ast.ref.kind) || ast.prefix?.book || ast.prefix?.sheet2 || ast.spill)
|
|
14955
14955
|
throw new Error("The reference is not valid.");
|
|
14956
|
-
const
|
|
14957
|
-
if (!workbook.sheets[
|
|
14958
|
-
return { sheet:
|
|
14956
|
+
const index3 = ast.prefix ? workbook.sheets.findIndex((ws) => ws.name.toLowerCase() === ast.prefix.sheet.toLowerCase()) : sheet;
|
|
14957
|
+
if (!workbook.sheets[index3]) throw new Error("The reference is not valid.");
|
|
14958
|
+
return { sheet: index3, range: checkedSparklineRange({ start: ast.ref.start, end: ast.ref.end }) };
|
|
14959
14959
|
}
|
|
14960
14960
|
function newSparklines(workbook, sheet, source2, locations) {
|
|
14961
14961
|
const data = sparklineDataRange(workbook, sheet, source2);
|
|
@@ -14982,6 +14982,99 @@ function newSparklines(workbook, sheet, source2, locations) {
|
|
|
14982
14982
|
return out;
|
|
14983
14983
|
}
|
|
14984
14984
|
|
|
14985
|
+
// xlsx/pivot/page-filter.ts
|
|
14986
|
+
function validatePivotPageFilter(pivot) {
|
|
14987
|
+
const filter2 = pivot.pageFilter;
|
|
14988
|
+
const extras = Array.isArray(pivot.additionalValues) ? pivot.additionalValues : [];
|
|
14989
|
+
if (filter2 === void 0) return;
|
|
14990
|
+
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) || [
|
|
14991
|
+
pivot.rowField,
|
|
14992
|
+
pivot.secondRowField,
|
|
14993
|
+
pivot.columnField,
|
|
14994
|
+
pivot.valueField,
|
|
14995
|
+
...extras.map((v) => v?.field)
|
|
14996
|
+
].includes(filter2.field) || pivot.valuesAxis === "rows")
|
|
14997
|
+
throw new Error("Report filters require Values on columns and a separate source field.");
|
|
14998
|
+
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))
|
|
14999
|
+
throw new Error("Choose a cached literal report filter item.");
|
|
15000
|
+
}
|
|
15001
|
+
function pivotPageProjection(pivot) {
|
|
15002
|
+
const filter2 = pivot.pageFilter;
|
|
15003
|
+
if (!filter2) return pivot;
|
|
15004
|
+
const labels = /* @__PURE__ */ new Map();
|
|
15005
|
+
for (const item of pivotItems(pivot, filter2.field)) {
|
|
15006
|
+
const label3 = String(pivotItemLabel(item)).toLowerCase(), key2 = pivotValueKey(item);
|
|
15007
|
+
if (label3 === "(all)" || labels.has(label3) && labels.get(label3) !== key2)
|
|
15008
|
+
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
15009
|
+
labels.set(label3, key2);
|
|
15010
|
+
}
|
|
15011
|
+
if (filter2.item === void 0) return pivot;
|
|
15012
|
+
const index3 = pivot.fields.indexOf(filter2.field), key = pivotValueKey(filter2.item);
|
|
15013
|
+
const records = pivot.records.filter((record) => pivotValueKey(record[index3] ?? null) === key);
|
|
15014
|
+
if (!records.length) throw new Error("The report filter item is missing from the source.");
|
|
15015
|
+
if (JSON.stringify(records[0][index3] ?? null) !== JSON.stringify(filter2.item))
|
|
15016
|
+
throw new Error("Choose an exact cached literal report filter item.");
|
|
15017
|
+
return { ...pivot, records };
|
|
15018
|
+
}
|
|
15019
|
+
function prependPivotPage(grid, pivot) {
|
|
15020
|
+
if (!pivot.pageFilter) return grid;
|
|
15021
|
+
const width = grid.values[0].length;
|
|
15022
|
+
return {
|
|
15023
|
+
...grid,
|
|
15024
|
+
values: [
|
|
15025
|
+
[
|
|
15026
|
+
pivot.pageFilter.field,
|
|
15027
|
+
pivot.pageFilter.item === void 0 ? "(All)" : pivotItemLabel(pivot.pageFilter.item),
|
|
15028
|
+
...Array(width - 2).fill(null)
|
|
15029
|
+
],
|
|
15030
|
+
Array(width).fill(null),
|
|
15031
|
+
...grid.values
|
|
15032
|
+
],
|
|
15033
|
+
firstDataRow: grid.firstDataRow + 2,
|
|
15034
|
+
...grid.firstHeaderRow !== void 0 ? { firstHeaderRow: grid.firstHeaderRow + 2 } : {},
|
|
15035
|
+
...grid.indents ? { indents: [0, 0, ...grid.indents] } : {}
|
|
15036
|
+
};
|
|
15037
|
+
}
|
|
15038
|
+
var index2 = (raw2) => raw2 !== null && /^\d+$/.test(raw2.trim()) && Number.isSafeInteger(Number(raw2)) ? Number(raw2) : NaN;
|
|
15039
|
+
function readPivotPageFilter(root, fields, shared) {
|
|
15040
|
+
const list = first(root, "pageFields", NS.x), location = first(root, "location", NS.x);
|
|
15041
|
+
const definitions = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
15042
|
+
if (!list) {
|
|
15043
|
+
if (definitions.some((n2) => n2.getAttribute("axis") === "axisPage") || location?.hasAttribute("rowPageCount") || location?.hasAttribute("colPageCount"))
|
|
15044
|
+
throw new Error("Unmodeled report filter metadata");
|
|
15045
|
+
return;
|
|
15046
|
+
}
|
|
15047
|
+
if (root.getAttribute("multipleFieldFilters") === "1")
|
|
15048
|
+
throw new Error("Multiple report filters are preserved");
|
|
15049
|
+
const pages = children(list, "pageField", NS.x);
|
|
15050
|
+
if (pages.length !== 1 || list.getAttribute("count") !== "1" || location?.getAttribute("rowPageCount") !== "1" || location.getAttribute("colPageCount") !== "1")
|
|
15051
|
+
throw new Error("Only one report filter is modeled");
|
|
15052
|
+
const page = pages[0], field = index2(page.getAttribute("fld"));
|
|
15053
|
+
if (page.getAttribute("hier") !== "-1" || !fields[field] || definitions[field]?.getAttribute("axis") !== "axisPage" || definitions.filter((n2) => n2.getAttribute("axis") === "axisPage").length !== 1)
|
|
15054
|
+
throw new Error("Unsupported report field");
|
|
15055
|
+
const container = first(definitions[field], "items", NS.x);
|
|
15056
|
+
const items = children(container, "item", NS.x);
|
|
15057
|
+
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"))
|
|
15058
|
+
throw new Error("Unsupported report field items");
|
|
15059
|
+
const data = items.slice(0, -1).map((item2) => {
|
|
15060
|
+
const i2 = index2(item2.getAttribute("x"));
|
|
15061
|
+
if (item2.hasAttribute("t") || !Number.isInteger(i2) || i2 >= shared[field].length)
|
|
15062
|
+
throw new Error("Invalid report cache item");
|
|
15063
|
+
return i2;
|
|
15064
|
+
});
|
|
15065
|
+
if (new Set(data).size !== data.length || data.length !== shared[field].length)
|
|
15066
|
+
throw new Error("Incomplete report cache items");
|
|
15067
|
+
const item = page.getAttribute("item");
|
|
15068
|
+
if (item === null) return { field: fields[field] };
|
|
15069
|
+
const selected2 = index2(item);
|
|
15070
|
+
if (!Number.isInteger(selected2) || selected2 >= data.length)
|
|
15071
|
+
throw new Error("Invalid report item selection");
|
|
15072
|
+
return { field: fields[field], item: shared[field][data[selected2]] };
|
|
15073
|
+
}
|
|
15074
|
+
function pivotPageItems(pivot, field) {
|
|
15075
|
+
return pivotItems(pivot, field);
|
|
15076
|
+
}
|
|
15077
|
+
|
|
14985
15078
|
// xlsx/pivot/data.ts
|
|
14986
15079
|
var PIVOT_AGGREGATES = ["sum", "count", "average", "min", "max"];
|
|
14987
15080
|
function pivotSourceData(workbook, sheet, source2) {
|
|
@@ -15012,10 +15105,10 @@ function pivotValueKey(value2) {
|
|
|
15012
15105
|
return value2 === null || value2 === "" ? "blank" : isCellError(value2) ? `error:${value2.error}` : `${typeof value2}:${String(value2).toLowerCase()}`;
|
|
15013
15106
|
}
|
|
15014
15107
|
function pivotItems(pivot, field) {
|
|
15015
|
-
const
|
|
15108
|
+
const index3 = pivot.fields.indexOf(field);
|
|
15016
15109
|
const items = /* @__PURE__ */ new Map();
|
|
15017
15110
|
for (const record of pivot.records) {
|
|
15018
|
-
const value2 = record[
|
|
15111
|
+
const value2 = record[index3] ?? null;
|
|
15019
15112
|
const key = pivotValueKey(value2);
|
|
15020
15113
|
if (!items.has(key)) items.set(key, value2);
|
|
15021
15114
|
}
|
|
@@ -15033,12 +15126,32 @@ function pivotItemLabel(value2) {
|
|
|
15033
15126
|
return isCellError(value2) ? value2.error : value2;
|
|
15034
15127
|
}
|
|
15035
15128
|
function validatePivotFields(pivot) {
|
|
15129
|
+
validatePivotPageFilter(pivot);
|
|
15036
15130
|
const used = [
|
|
15037
15131
|
pivot.rowField,
|
|
15038
15132
|
...pivot.secondRowField ? [pivot.secondRowField] : [],
|
|
15039
15133
|
...pivot.columnField ? [pivot.columnField] : [],
|
|
15040
15134
|
pivot.valueField
|
|
15041
15135
|
];
|
|
15136
|
+
const extras = pivot.additionalValues ?? [];
|
|
15137
|
+
if (pivot.valuesAxis !== void 0 && !["columns", "rows"].includes(pivot.valuesAxis))
|
|
15138
|
+
throw new Error("Choose a valid Values axis.");
|
|
15139
|
+
if (pivot.valuesPosition !== void 0 && !["last", "between", "first"].includes(pivot.valuesPosition))
|
|
15140
|
+
throw new Error("Choose a valid Values position.");
|
|
15141
|
+
if ((pivot.valuesPosition === "between" || pivot.valuesPosition === "first") && (pivot.valuesAxis !== "rows" || !pivot.secondRowField))
|
|
15142
|
+
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
15143
|
+
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
15144
|
+
throw new Error("Values on rows require multiple measures.");
|
|
15145
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== "Values")
|
|
15146
|
+
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
15147
|
+
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
15148
|
+
(measure) => !measure || !pivot.fields.includes(measure.field) || !PIVOT_AGGREGATES.includes(measure.aggregate) || typeof measure.caption !== "string" || !measure.caption.trim() || measure.caption.length > 255 || pivot.fields.some((field) => field.toLowerCase() === measure.caption.toLowerCase())
|
|
15149
|
+
) || new Set(
|
|
15150
|
+
[pivot.valueCaption, ...extras.map((measure) => measure.caption)].map(
|
|
15151
|
+
(caption) => caption?.toLowerCase()
|
|
15152
|
+
)
|
|
15153
|
+
).size !== extras.length + 1)
|
|
15154
|
+
throw new Error("Choose PivotTable value fields with valid aggregates and unique captions.");
|
|
15042
15155
|
if (pivot.layout !== void 0 && !["tabular", "compact", "outline"].includes(pivot.layout) || pivot.subtotalPosition !== void 0 && !["top", "bottom"].includes(pivot.subtotalPosition) || !PIVOT_AGGREGATES.includes(pivot.aggregate) || used.some((field) => !pivot.fields.includes(field)) || new Set([pivot.rowField, pivot.secondRowField, pivot.columnField].filter(Boolean)).size !== [pivot.rowField, pivot.secondRowField, pivot.columnField].filter(Boolean).length || pivot.subtotals !== void 0 && typeof pivot.subtotals !== "boolean" || pivot.repeatLabels !== void 0 && typeof pivot.repeatLabels !== "boolean")
|
|
15043
15156
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
15044
15157
|
}
|
|
@@ -15046,25 +15159,195 @@ function pivotCaption(aggregate3, field) {
|
|
|
15046
15159
|
return `${aggregate3[0].toUpperCase()}${aggregate3.slice(1)} of ${field}`;
|
|
15047
15160
|
}
|
|
15048
15161
|
|
|
15162
|
+
// xlsx/pivot/measures.ts
|
|
15163
|
+
var pivotMeasures = (pivot) => [
|
|
15164
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
15165
|
+
...pivot.additionalValues ?? []
|
|
15166
|
+
];
|
|
15167
|
+
function normalizedPivotMeasures(values2) {
|
|
15168
|
+
if (!Array.isArray(values2) || values2.length > 15)
|
|
15169
|
+
throw new Error("Choose between one and sixteen PivotTable value fields.");
|
|
15170
|
+
return values2.map((value2) => {
|
|
15171
|
+
if (!value2 || typeof value2.field !== "string")
|
|
15172
|
+
throw new Error("Choose valid PivotTable value fields.");
|
|
15173
|
+
const aggregate3 = value2.aggregate ?? "sum";
|
|
15174
|
+
if (!PIVOT_AGGREGATES.includes(aggregate3))
|
|
15175
|
+
throw new Error("Choose a valid PivotTable aggregate.");
|
|
15176
|
+
return {
|
|
15177
|
+
field: value2.field,
|
|
15178
|
+
aggregate: aggregate3,
|
|
15179
|
+
caption: value2.caption ?? `${aggregate3[0].toUpperCase()}${aggregate3.slice(1)} of ${value2.field}`
|
|
15180
|
+
};
|
|
15181
|
+
});
|
|
15182
|
+
}
|
|
15183
|
+
function aggregate2(records, field, type) {
|
|
15184
|
+
if (!records.length) return null;
|
|
15185
|
+
const values2 = records.map((record) => record[field] ?? null);
|
|
15186
|
+
if (type === "count") return values2.filter((value2) => value2 !== null && value2 !== "").length;
|
|
15187
|
+
const error = values2.find(isCellError);
|
|
15188
|
+
if (error) return error;
|
|
15189
|
+
const numbers3 = values2.filter((value2) => typeof value2 === "number");
|
|
15190
|
+
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
15191
|
+
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
15192
|
+
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
15193
|
+
const sum2 = numbers3.reduce((total2, value2) => total2 + value2, 0);
|
|
15194
|
+
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
15195
|
+
}
|
|
15196
|
+
var pivotMeasureNumber = (pivot, records, measure) => aggregate2(records, pivot.fields.indexOf(measure.field), measure.aggregate);
|
|
15197
|
+
var pivotNumbers = (pivot, records) => pivotMeasures(pivot).map((measure) => pivotMeasureNumber(pivot, records, measure));
|
|
15198
|
+
function pivotHeaderDimensions(pivot, columnItems, rowLabels) {
|
|
15199
|
+
const measures = 1 + (pivot.additionalValues?.length ?? 0);
|
|
15200
|
+
if (pivot.valuesAxis === "rows")
|
|
15201
|
+
return {
|
|
15202
|
+
rows: (pivot.columnField ? 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
15203
|
+
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
15204
|
+
};
|
|
15205
|
+
return {
|
|
15206
|
+
rows: (pivot.columnField ? measures > 1 ? 3 : 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
15207
|
+
width: rowLabels + (pivot.columnField ? measures === 1 ? Math.max(1, columnItems) + 1 : (columnItems + 1) * measures : measures)
|
|
15208
|
+
};
|
|
15209
|
+
}
|
|
15210
|
+
function pivotHeaders(pivot, columns, labels, label3) {
|
|
15211
|
+
const measures = pivotMeasures(pivot);
|
|
15212
|
+
if (pivot.valuesAxis === "rows") {
|
|
15213
|
+
const rowLabels = pivot.layout === "compact" ? ["Row Labels"] : pivot.valuesPosition === "first" ? ["Values", ...labels] : pivot.valuesPosition === "between" ? [labels[0], "Values", labels[1]] : [...labels, "Values"];
|
|
15214
|
+
return pivot.columnField ? [
|
|
15215
|
+
[
|
|
15216
|
+
...rowLabels.map(() => null),
|
|
15217
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
15218
|
+
...columns.map(() => null)
|
|
15219
|
+
],
|
|
15220
|
+
[...rowLabels, ...columns.map(label3), "Grand Total"]
|
|
15221
|
+
] : [[...rowLabels, null]];
|
|
15222
|
+
}
|
|
15223
|
+
if (!pivot.columnField) return [[...labels, ...measures.map((measure) => measure.caption)]];
|
|
15224
|
+
if (measures.length === 1)
|
|
15225
|
+
return [
|
|
15226
|
+
[
|
|
15227
|
+
pivot.valueCaption,
|
|
15228
|
+
...labels.slice(1).map(() => null),
|
|
15229
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
15230
|
+
...columns.slice(1).map(() => null),
|
|
15231
|
+
null
|
|
15232
|
+
],
|
|
15233
|
+
[...labels, ...columns.map(label3), "Grand Total"]
|
|
15234
|
+
];
|
|
15235
|
+
const { width } = pivotHeaderDimensions(pivot, columns.length, labels.length);
|
|
15236
|
+
const first2 = Array(width).fill(null);
|
|
15237
|
+
first2[labels.length] = pivot.layout === "compact" ? "Column Labels" : pivot.columnField;
|
|
15238
|
+
if (pivot.layout !== "compact") first2[labels.length + 1] = "Values";
|
|
15239
|
+
return [
|
|
15240
|
+
first2,
|
|
15241
|
+
[
|
|
15242
|
+
...labels.map(() => null),
|
|
15243
|
+
...columns.flatMap((column) => [label3(column), ...measures.slice(1).map(() => null)]),
|
|
15244
|
+
...measures.map((measure) => `Total ${measure.caption}`)
|
|
15245
|
+
],
|
|
15246
|
+
[
|
|
15247
|
+
...labels,
|
|
15248
|
+
...columns.flatMap(() => measures.map((measure) => measure.caption)),
|
|
15249
|
+
...measures.map(() => null)
|
|
15250
|
+
]
|
|
15251
|
+
];
|
|
15252
|
+
}
|
|
15253
|
+
|
|
15254
|
+
// xlsx/pivot/hierarchy-first.ts
|
|
15255
|
+
function appendFirstPivotValues(pivot, context) {
|
|
15256
|
+
const {
|
|
15257
|
+
rowItems,
|
|
15258
|
+
secondRowItems,
|
|
15259
|
+
columnItems,
|
|
15260
|
+
children: children2,
|
|
15261
|
+
innerIndices,
|
|
15262
|
+
groups,
|
|
15263
|
+
details,
|
|
15264
|
+
buckets,
|
|
15265
|
+
width,
|
|
15266
|
+
rowLabels,
|
|
15267
|
+
top,
|
|
15268
|
+
bottom,
|
|
15269
|
+
append
|
|
15270
|
+
} = context;
|
|
15271
|
+
const compact3 = pivot.layout === "compact";
|
|
15272
|
+
const tabular = !pivot.layout || pivot.layout === "tabular";
|
|
15273
|
+
const blank = () => Array(width - rowLabels).fill(null);
|
|
15274
|
+
pivotMeasures(pivot).forEach((measure, m) => {
|
|
15275
|
+
const numbers3 = (keys, records) => [
|
|
15276
|
+
...columnItems.map(
|
|
15277
|
+
(column) => pivotMeasureNumber(
|
|
15278
|
+
pivot,
|
|
15279
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
15280
|
+
measure
|
|
15281
|
+
)
|
|
15282
|
+
),
|
|
15283
|
+
pivotMeasureNumber(pivot, records, measure)
|
|
15284
|
+
];
|
|
15285
|
+
if (!tabular)
|
|
15286
|
+
append([measure.caption, ...Array(rowLabels - 1).fill(null)], blank(), {
|
|
15287
|
+
indices: [m],
|
|
15288
|
+
measure: m
|
|
15289
|
+
});
|
|
15290
|
+
let first2 = true;
|
|
15291
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
15292
|
+
const key = pivotValueKey(outer);
|
|
15293
|
+
const group = groups.get(key) ?? [];
|
|
15294
|
+
if (!tabular)
|
|
15295
|
+
append(
|
|
15296
|
+
compact3 ? [pivotItemLabel(outer)] : [null, pivotItemLabel(outer), null],
|
|
15297
|
+
top ? numbers3([key], group) : blank(),
|
|
15298
|
+
{ indices: [m, outerIndex], measure: m },
|
|
15299
|
+
compact3 ? 1 : 0
|
|
15300
|
+
);
|
|
15301
|
+
const innerKeys = [...children2.get(key)].sort(
|
|
15302
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
15303
|
+
);
|
|
15304
|
+
innerKeys.forEach((innerKey, child3) => {
|
|
15305
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
15306
|
+
append(
|
|
15307
|
+
compact3 ? [pivotItemLabel(secondRowItems[innerIndex])] : [
|
|
15308
|
+
tabular && first2 ? measure.caption : null,
|
|
15309
|
+
pivot.repeatLabels || tabular && child3 === 0 ? pivotItemLabel(outer) : null,
|
|
15310
|
+
pivotItemLabel(secondRowItems[innerIndex])
|
|
15311
|
+
],
|
|
15312
|
+
numbers3([key, innerKey], details.get(JSON.stringify([key, innerKey]))),
|
|
15313
|
+
{ indices: [m, outerIndex, innerIndex], measure: m },
|
|
15314
|
+
compact3 ? 2 : 0
|
|
15315
|
+
);
|
|
15316
|
+
first2 = false;
|
|
15317
|
+
});
|
|
15318
|
+
if (bottom)
|
|
15319
|
+
append(
|
|
15320
|
+
compact3 ? [`${String(pivotItemLabel(outer))} Total`] : [null, `${String(pivotItemLabel(outer))} Total`, null],
|
|
15321
|
+
numbers3([key], group),
|
|
15322
|
+
{ indices: [m, outerIndex], measure: m, type: "default" },
|
|
15323
|
+
compact3 ? 1 : 0
|
|
15324
|
+
);
|
|
15325
|
+
});
|
|
15326
|
+
});
|
|
15327
|
+
}
|
|
15328
|
+
|
|
15049
15329
|
// xlsx/pivot/hierarchy.ts
|
|
15050
15330
|
var label2 = pivotItemLabel;
|
|
15051
|
-
function hierarchicalPivotGrid(pivot
|
|
15331
|
+
function hierarchicalPivotGrid(pivot) {
|
|
15052
15332
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
15053
15333
|
const secondRowItems = pivotItems(pivot, pivot.secondRowField);
|
|
15054
15334
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
15055
15335
|
const outerField = pivot.fields.indexOf(pivot.rowField);
|
|
15056
15336
|
const innerField = pivot.fields.indexOf(pivot.secondRowField);
|
|
15057
15337
|
const columnField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
15058
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
15059
15338
|
const layout2 = pivot.layout ?? "tabular";
|
|
15060
15339
|
const compact3 = layout2 === "compact";
|
|
15061
|
-
const
|
|
15340
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
15341
|
+
const firstValues = rowsAxis && pivot.valuesPosition === "first";
|
|
15342
|
+
const between = rowsAxis && pivot.valuesPosition === "between";
|
|
15343
|
+
const measures = pivotMeasures(pivot);
|
|
15344
|
+
const top = (!rowsAxis || firstValues) && layout2 !== "tabular" && pivot.subtotals !== false && (pivot.subtotalPosition ?? "top") === "top";
|
|
15062
15345
|
const bottom = pivot.subtotals !== false && !top;
|
|
15063
|
-
const rowLabelColumns = compact3 ? 1 : 2;
|
|
15346
|
+
const rowLabelColumns = compact3 ? 1 : rowsAxis ? 3 : 2;
|
|
15064
15347
|
const groups = /* @__PURE__ */ new Map();
|
|
15065
15348
|
const details = /* @__PURE__ */ new Map();
|
|
15066
15349
|
const children2 = /* @__PURE__ */ new Map();
|
|
15067
|
-
const innerIndices = new Map(secondRowItems.map((item,
|
|
15350
|
+
const innerIndices = new Map(secondRowItems.map((item, index3) => [pivotValueKey(item), index3]));
|
|
15068
15351
|
const buckets = /* @__PURE__ */ new Map();
|
|
15069
15352
|
const collect2 = (map, key, record) => {
|
|
15070
15353
|
const list = map.get(key);
|
|
@@ -15084,20 +15367,12 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
15084
15367
|
collect2(buckets, JSON.stringify([...key, column]), record);
|
|
15085
15368
|
}
|
|
15086
15369
|
}
|
|
15087
|
-
const
|
|
15088
|
-
|
|
15089
|
-
|
|
15370
|
+
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, rowLabelColumns);
|
|
15371
|
+
const rows = (details.size + rowItems.length * Number(bottom) + 1) * (rowsAxis ? measures.length : 1) + rowItems.length * Number(layout2 !== "tabular") * (firstValues ? measures.length : 1) + (firstValues ? measures.length : between ? rowItems.length * measures.length : details.size) * Number(rowsAxis && layout2 !== "tabular") + dimensions.rows;
|
|
15372
|
+
if (rows * dimensions.width > 1e6) throw new Error("The PivotTable result is too large.");
|
|
15090
15373
|
const labels = compact3 ? ["Row Labels"] : [pivot.rowField, pivot.secondRowField];
|
|
15091
|
-
const values2 = pivot
|
|
15092
|
-
|
|
15093
|
-
pivot.valueCaption,
|
|
15094
|
-
...compact3 ? [] : [null],
|
|
15095
|
-
compact3 ? "Column Labels" : pivot.columnField,
|
|
15096
|
-
...columnItems.slice(1).map(() => null),
|
|
15097
|
-
null
|
|
15098
|
-
],
|
|
15099
|
-
[...labels, ...columnItems.map(label2), "Grand Total"]
|
|
15100
|
-
] : [[...labels, pivot.valueCaption]];
|
|
15374
|
+
const values2 = pivotHeaders(pivot, columnItems, labels, label2);
|
|
15375
|
+
const firstDataRow = values2.length;
|
|
15101
15376
|
const indents = values2.map(() => 0);
|
|
15102
15377
|
const rowEntries = [];
|
|
15103
15378
|
const append = (labels2, numbers4, entry3, indent = 0) => {
|
|
@@ -15105,91 +15380,187 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
15105
15380
|
rowEntries.push(entry3);
|
|
15106
15381
|
indents.push(indent);
|
|
15107
15382
|
};
|
|
15108
|
-
const
|
|
15383
|
+
const bands = (keys, records) => [
|
|
15109
15384
|
...columnItems.map(
|
|
15110
|
-
(column) =>
|
|
15111
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
15112
|
-
valueField,
|
|
15113
|
-
pivot.aggregate
|
|
15114
|
-
)
|
|
15385
|
+
(column) => pivotNumbers(pivot, buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [])
|
|
15115
15386
|
),
|
|
15116
|
-
|
|
15387
|
+
pivotNumbers(pivot, records)
|
|
15117
15388
|
];
|
|
15118
|
-
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
const records = details.get(JSON.stringify(keys));
|
|
15132
|
-
if (!records) return;
|
|
15133
|
-
append(
|
|
15134
|
-
compact3 ? [label2(inner2)] : [
|
|
15135
|
-
pivot.repeatLabels || layout2 === "tabular" && first2 ? label2(outer) : null,
|
|
15136
|
-
label2(inner2)
|
|
15389
|
+
const numbers3 = (keys, records) => bands(keys, records).flat();
|
|
15390
|
+
const appendMeasures = (labels2, keys, records, indices, type) => {
|
|
15391
|
+
const values3 = bands(keys, records);
|
|
15392
|
+
measures.forEach(
|
|
15393
|
+
(measure, m) => append(
|
|
15394
|
+
type ? [
|
|
15395
|
+
`${type === "grand" ? "Total" : String(labels2[0])} ${measure.caption}`,
|
|
15396
|
+
...Array(rowLabelColumns - 1).fill(null)
|
|
15397
|
+
] : compact3 ? [measure.caption] : [
|
|
15398
|
+
...labels2.map(
|
|
15399
|
+
(label3) => layout2 === "tabular" && m === 0 || pivot.repeatLabels ? label3 : null
|
|
15400
|
+
),
|
|
15401
|
+
measure.caption
|
|
15137
15402
|
],
|
|
15138
|
-
|
|
15139
|
-
{ indices: [
|
|
15140
|
-
compact3 ?
|
|
15141
|
-
)
|
|
15142
|
-
|
|
15403
|
+
values3.map((band) => band[m] ?? null),
|
|
15404
|
+
{ indices: type ? indices : [...indices, m], measure: m, ...type ? { type } : {} },
|
|
15405
|
+
compact3 && !type ? 2 : 0
|
|
15406
|
+
)
|
|
15407
|
+
);
|
|
15408
|
+
};
|
|
15409
|
+
if (firstValues)
|
|
15410
|
+
appendFirstPivotValues(pivot, {
|
|
15411
|
+
rowItems,
|
|
15412
|
+
secondRowItems,
|
|
15413
|
+
columnItems,
|
|
15414
|
+
children: children2,
|
|
15415
|
+
innerIndices,
|
|
15416
|
+
groups,
|
|
15417
|
+
details,
|
|
15418
|
+
buckets,
|
|
15419
|
+
width: dimensions.width,
|
|
15420
|
+
rowLabels: rowLabelColumns,
|
|
15421
|
+
top,
|
|
15422
|
+
bottom,
|
|
15423
|
+
append
|
|
15143
15424
|
});
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15425
|
+
else
|
|
15426
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
15427
|
+
const key = pivotValueKey(outer);
|
|
15428
|
+
if (layout2 !== "tabular")
|
|
15429
|
+
append(
|
|
15430
|
+
[label2(outer), ...Array(rowLabelColumns - 1).fill(null)],
|
|
15431
|
+
top ? numbers3([key], groups.get(key) ?? []) : Array(dimensions.width - rowLabelColumns).fill(null),
|
|
15432
|
+
{ indices: [outerIndex] }
|
|
15433
|
+
);
|
|
15434
|
+
let first2 = true;
|
|
15435
|
+
const innerKeys = [...children2.get(key)].sort(
|
|
15436
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
15150
15437
|
);
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15438
|
+
if (between)
|
|
15439
|
+
measures.forEach((measure, m) => {
|
|
15440
|
+
if (layout2 !== "tabular")
|
|
15441
|
+
append(
|
|
15442
|
+
compact3 ? [measure.caption] : [pivot.repeatLabels ? label2(outer) : null, measure.caption, null],
|
|
15443
|
+
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
15444
|
+
{ indices: [outerIndex, m], measure: m },
|
|
15445
|
+
compact3 ? 1 : 0
|
|
15446
|
+
);
|
|
15447
|
+
innerKeys.forEach((innerKey, child3) => {
|
|
15448
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
15449
|
+
const keys = [key, innerKey];
|
|
15450
|
+
const records = details.get(JSON.stringify(keys));
|
|
15451
|
+
append(
|
|
15452
|
+
compact3 ? [label2(secondRowItems[innerIndex])] : [
|
|
15453
|
+
pivot.repeatLabels || layout2 === "tabular" && m === 0 && child3 === 0 ? label2(outer) : null,
|
|
15454
|
+
layout2 === "tabular" && child3 === 0 ? measure.caption : null,
|
|
15455
|
+
label2(secondRowItems[innerIndex])
|
|
15456
|
+
],
|
|
15457
|
+
[
|
|
15458
|
+
...columnItems.map(
|
|
15459
|
+
(column) => pivotMeasureNumber(
|
|
15460
|
+
pivot,
|
|
15461
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
15462
|
+
measure
|
|
15463
|
+
)
|
|
15464
|
+
),
|
|
15465
|
+
pivotMeasureNumber(pivot, records, measure)
|
|
15466
|
+
],
|
|
15467
|
+
{ indices: [outerIndex, m, innerIndex], measure: m },
|
|
15468
|
+
compact3 ? 2 : 0
|
|
15469
|
+
);
|
|
15470
|
+
});
|
|
15471
|
+
});
|
|
15472
|
+
else
|
|
15473
|
+
innerKeys.forEach((innerKey) => {
|
|
15474
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
15475
|
+
const inner2 = secondRowItems[innerIndex];
|
|
15476
|
+
const keys = [key, innerKey];
|
|
15477
|
+
const records = details.get(JSON.stringify(keys));
|
|
15478
|
+
if (!records) return;
|
|
15479
|
+
if (rowsAxis) {
|
|
15480
|
+
if (layout2 !== "tabular")
|
|
15481
|
+
append(
|
|
15482
|
+
compact3 ? [label2(inner2)] : [pivot.repeatLabels ? label2(outer) : null, label2(inner2), null],
|
|
15483
|
+
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
15484
|
+
{ indices: [outerIndex, innerIndex] },
|
|
15485
|
+
compact3 ? 1 : 0
|
|
15486
|
+
);
|
|
15487
|
+
appendMeasures(
|
|
15488
|
+
[pivot.repeatLabels || first2 ? label2(outer) : null, label2(inner2)],
|
|
15489
|
+
keys,
|
|
15490
|
+
records,
|
|
15491
|
+
[outerIndex, innerIndex]
|
|
15492
|
+
);
|
|
15493
|
+
first2 = false;
|
|
15494
|
+
return;
|
|
15495
|
+
}
|
|
15496
|
+
append(
|
|
15497
|
+
compact3 ? [label2(inner2)] : [
|
|
15498
|
+
pivot.repeatLabels || layout2 === "tabular" && first2 ? label2(outer) : null,
|
|
15499
|
+
label2(inner2)
|
|
15500
|
+
],
|
|
15501
|
+
numbers3(keys, records),
|
|
15502
|
+
{ indices: [outerIndex, innerIndex] },
|
|
15503
|
+
compact3 ? 1 : 0
|
|
15504
|
+
);
|
|
15505
|
+
first2 = false;
|
|
15506
|
+
});
|
|
15507
|
+
if (bottom) {
|
|
15508
|
+
if (rowsAxis) {
|
|
15509
|
+
appendMeasures([label2(outer)], [key], groups.get(key) ?? [], [outerIndex], "default");
|
|
15510
|
+
return;
|
|
15511
|
+
}
|
|
15512
|
+
const caption = String(label2(outer));
|
|
15513
|
+
append(
|
|
15514
|
+
[`${caption} Total`, ...compact3 ? [] : [null]],
|
|
15515
|
+
numbers3([key], groups.get(key) ?? []),
|
|
15516
|
+
{ indices: [outerIndex], type: "default" }
|
|
15517
|
+
);
|
|
15518
|
+
}
|
|
15519
|
+
});
|
|
15520
|
+
if (rowsAxis) appendMeasures([], [], pivot.records, [0], "grand");
|
|
15521
|
+
else
|
|
15522
|
+
append(["Grand Total", ...compact3 ? [] : [null]], numbers3([], pivot.records), {
|
|
15523
|
+
indices: [0],
|
|
15524
|
+
type: "grand"
|
|
15525
|
+
});
|
|
15157
15526
|
return {
|
|
15158
15527
|
values: values2,
|
|
15159
15528
|
rowItems,
|
|
15160
15529
|
secondRowItems,
|
|
15161
15530
|
columnItems,
|
|
15162
15531
|
rowEntries,
|
|
15163
|
-
firstDataRow
|
|
15532
|
+
firstDataRow,
|
|
15164
15533
|
rowLabelColumns,
|
|
15165
|
-
indents
|
|
15534
|
+
indents,
|
|
15535
|
+
...rowsAxis ? { firstHeaderRow: 1 } : {}
|
|
15166
15536
|
};
|
|
15167
15537
|
}
|
|
15168
15538
|
|
|
15169
15539
|
// xlsx/pivot/aggregate.ts
|
|
15170
|
-
function aggregate2(records, field, type) {
|
|
15171
|
-
if (!records.length) return null;
|
|
15172
|
-
const values2 = records.map((record) => record[field] ?? null);
|
|
15173
|
-
if (type === "count") return values2.filter((value2) => value2 !== null && value2 !== "").length;
|
|
15174
|
-
const error = values2.find(isCellError);
|
|
15175
|
-
if (error) return error;
|
|
15176
|
-
const numbers3 = values2.filter((value2) => typeof value2 === "number");
|
|
15177
|
-
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
15178
|
-
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
15179
|
-
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
15180
|
-
const sum2 = numbers3.reduce((total2, value2) => total2 + value2, 0);
|
|
15181
|
-
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
15182
|
-
}
|
|
15183
15540
|
function pivotGrid(pivot) {
|
|
15184
15541
|
validatePivotFields(pivot);
|
|
15185
|
-
|
|
15542
|
+
return prependPivotPage(pivotDataGrid(pivotPageProjection(pivot)), pivot);
|
|
15543
|
+
}
|
|
15544
|
+
function pivotDataGrid(pivot) {
|
|
15545
|
+
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
15186
15546
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
15187
15547
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
15188
|
-
|
|
15548
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
15549
|
+
const compact3 = pivot.layout === "compact";
|
|
15550
|
+
const headings = rowsAxis && pivot.layout !== void 0 && pivot.layout !== "tabular";
|
|
15551
|
+
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, rowsAxis && !compact3 ? 2 : 1);
|
|
15552
|
+
const dataRows = (rowItems.length + 1) * (rowsAxis ? 1 + (pivot.additionalValues?.length ?? 0) : 1) + (headings ? rowItems.length : 0);
|
|
15553
|
+
if ((dataRows + dimensions.rows) * dimensions.width > 1e6)
|
|
15189
15554
|
throw new Error("The PivotTable result is too large.");
|
|
15555
|
+
const label3 = pivotItemLabel;
|
|
15556
|
+
const values2 = pivotHeaders(
|
|
15557
|
+
pivot,
|
|
15558
|
+
columnItems,
|
|
15559
|
+
[pivot.layout === "compact" ? "Row Labels" : pivot.rowField],
|
|
15560
|
+
label3
|
|
15561
|
+
);
|
|
15190
15562
|
const rowField = pivot.fields.indexOf(pivot.rowField);
|
|
15191
15563
|
const colField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
15192
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
15193
15564
|
const groups = /* @__PURE__ */ new Map();
|
|
15194
15565
|
const cells = /* @__PURE__ */ new Map();
|
|
15195
15566
|
const columns = /* @__PURE__ */ new Map();
|
|
@@ -15207,42 +15578,85 @@ function pivotGrid(pivot) {
|
|
|
15207
15578
|
collect2(cells, JSON.stringify([key, col]), record);
|
|
15208
15579
|
}
|
|
15209
15580
|
}
|
|
15210
|
-
const
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15581
|
+
const firstDataRow = values2.length;
|
|
15582
|
+
if (rowsAxis) {
|
|
15583
|
+
const measures = pivotMeasures(pivot);
|
|
15584
|
+
const rowEntries = [];
|
|
15585
|
+
const indents = values2.map(() => 0);
|
|
15586
|
+
const append = (caption, bands, index3, grand = false) => {
|
|
15587
|
+
measures.forEach((measure, m) => {
|
|
15588
|
+
values2.push([
|
|
15589
|
+
...compact3 ? [grand ? `Total ${measure.caption}` : measure.caption] : [
|
|
15590
|
+
grand ? `Total ${measure.caption}` : pivot.repeatLabels || !headings && m === 0 ? caption : null,
|
|
15591
|
+
grand ? null : measure.caption
|
|
15592
|
+
],
|
|
15593
|
+
...bands.map((band) => band[m] ?? null)
|
|
15594
|
+
]);
|
|
15595
|
+
indents.push(compact3 && !grand ? 1 : 0);
|
|
15596
|
+
rowEntries.push({
|
|
15597
|
+
indices: grand ? [0] : [index3, m],
|
|
15598
|
+
measure: m,
|
|
15599
|
+
...grand ? { type: "grand" } : {}
|
|
15600
|
+
});
|
|
15601
|
+
});
|
|
15602
|
+
};
|
|
15603
|
+
rowItems.forEach((item, index3) => {
|
|
15604
|
+
const key = pivotValueKey(item);
|
|
15605
|
+
if (headings) {
|
|
15606
|
+
values2.push([label3(item), ...Array(dimensions.width - 1).fill(null)]);
|
|
15607
|
+
rowEntries.push({ indices: [index3] });
|
|
15608
|
+
indents.push(0);
|
|
15609
|
+
}
|
|
15610
|
+
append(
|
|
15611
|
+
label3(item),
|
|
15612
|
+
[
|
|
15613
|
+
...columnItems.map(
|
|
15614
|
+
(col) => pivotNumbers(pivot, cells.get(JSON.stringify([key, pivotValueKey(col)])) ?? [])
|
|
15615
|
+
),
|
|
15616
|
+
pivotNumbers(pivot, groups.get(key) ?? [])
|
|
15617
|
+
],
|
|
15618
|
+
index3
|
|
15619
|
+
);
|
|
15620
|
+
});
|
|
15621
|
+
append(
|
|
15622
|
+
"Grand Total",
|
|
15623
|
+
[
|
|
15624
|
+
...columnItems.map((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
15625
|
+
pivotNumbers(pivot, pivot.records)
|
|
15626
|
+
],
|
|
15627
|
+
0,
|
|
15628
|
+
true
|
|
15629
|
+
);
|
|
15630
|
+
return {
|
|
15631
|
+
values: values2,
|
|
15632
|
+
rowItems,
|
|
15633
|
+
columnItems,
|
|
15634
|
+
firstDataRow,
|
|
15635
|
+
rowLabelColumns: compact3 ? 1 : 2,
|
|
15636
|
+
indents,
|
|
15637
|
+
firstHeaderRow: 1,
|
|
15638
|
+
rowEntries
|
|
15639
|
+
};
|
|
15640
|
+
}
|
|
15224
15641
|
for (const row2 of rowItems) {
|
|
15225
15642
|
const records = groups.get(pivotValueKey(row2)) ?? [];
|
|
15226
15643
|
values2.push([
|
|
15227
15644
|
label3(row2),
|
|
15228
|
-
...columnItems.
|
|
15229
|
-
(col) =>
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
pivot.aggregate
|
|
15645
|
+
...columnItems.flatMap(
|
|
15646
|
+
(col) => pivotNumbers(
|
|
15647
|
+
pivot,
|
|
15648
|
+
cells.get(JSON.stringify([pivotValueKey(row2), pivotValueKey(col)])) ?? []
|
|
15233
15649
|
)
|
|
15234
15650
|
),
|
|
15235
|
-
|
|
15651
|
+
...pivotNumbers(pivot, records)
|
|
15236
15652
|
]);
|
|
15237
15653
|
}
|
|
15238
15654
|
values2.push([
|
|
15239
15655
|
"Grand Total",
|
|
15240
|
-
...columnItems.
|
|
15241
|
-
|
|
15242
|
-
),
|
|
15243
|
-
aggregate2(pivot.records, valueField, pivot.aggregate)
|
|
15656
|
+
...columnItems.flatMap((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
15657
|
+
...pivotNumbers(pivot, pivot.records)
|
|
15244
15658
|
]);
|
|
15245
|
-
return { values: values2, rowItems, columnItems, firstDataRow
|
|
15659
|
+
return { values: values2, rowItems, columnItems, firstDataRow };
|
|
15246
15660
|
}
|
|
15247
15661
|
function pivotTableAt(sheet, at) {
|
|
15248
15662
|
return sheet.pivotTables?.find((pivot) => rangeContains(pivot.location, at));
|
|
@@ -15252,8 +15666,10 @@ function pivotTableAt(sheet, at) {
|
|
|
15252
15666
|
var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
15253
15667
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
15254
15668
|
var TABLE = {
|
|
15255
|
-
pivotTableDefinition: "name cacheId dataCaption updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
|
|
15256
|
-
location: "ref firstHeaderRow firstDataRow firstDataCol",
|
|
15669
|
+
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",
|
|
15670
|
+
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
15671
|
+
pageFields: "count",
|
|
15672
|
+
pageField: "fld item hier",
|
|
15257
15673
|
pivotFields: "count",
|
|
15258
15674
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal",
|
|
15259
15675
|
items: "count",
|
|
@@ -15263,7 +15679,7 @@ var TABLE = {
|
|
|
15263
15679
|
field: "x",
|
|
15264
15680
|
rowItems: "count",
|
|
15265
15681
|
colItems: "count",
|
|
15266
|
-
i: "t r",
|
|
15682
|
+
i: "t r i",
|
|
15267
15683
|
x: "v",
|
|
15268
15684
|
dataFields: "count",
|
|
15269
15685
|
dataField: "name fld subtotal baseField baseItem showDataAs",
|
|
@@ -15294,7 +15710,7 @@ function inspect(node, profile, cache3) {
|
|
|
15294
15710
|
for (let i2 = 0; i2 < node.attributes.length; i2++) {
|
|
15295
15711
|
const attr2 = node.attributes.item(i2);
|
|
15296
15712
|
if (attr2.name.startsWith("xmlns")) continue;
|
|
15297
|
-
if (!cache3 && node.namespaceURI === X14 && node.localName === "pivotTableDefinition" && attr2.name === "hideValuesRow" &&
|
|
15713
|
+
if (!cache3 && node.namespaceURI === X14 && node.localName === "pivotTableDefinition" && attr2.name === "hideValuesRow" && ["0", "1"].includes(attr2.value))
|
|
15298
15714
|
continue;
|
|
15299
15715
|
if (!cache3 && node.namespaceURI === X14 && (node.localName === "pivotField" && attr2.name === "fillDownLabels" || node.localName === "pivotTableDefinition" && attr2.name === "fillDownLabelsDefault") && ["0", "1"].includes(attr2.value))
|
|
15300
15716
|
continue;
|
|
@@ -15323,7 +15739,9 @@ function inspect(node, profile, cache3) {
|
|
|
15323
15739
|
throw new Error("Unsupported PivotTable option");
|
|
15324
15740
|
if (attr2.localName === "numFmtId" && attr2.value !== "0")
|
|
15325
15741
|
throw new Error("Unsupported PivotTable field number format");
|
|
15326
|
-
if (node.localName === "pivotTableDefinition" && ["compact", "compactData", "outline", "outlineData"
|
|
15742
|
+
if (node.localName === "pivotTableDefinition" && ["compact", "compactData", "outline", "outlineData", "dataOnRows"].includes(
|
|
15743
|
+
attr2.localName
|
|
15744
|
+
) && !["0", "1"].includes(attr2.value))
|
|
15327
15745
|
throw new Error("Unsupported PivotTable global layout");
|
|
15328
15746
|
if (node.localName === "item" && attr2.localName === "t" && !["default", "data"].includes(attr2.value))
|
|
15329
15747
|
throw new Error("Unsupported PivotTable subtotal");
|
|
@@ -15346,6 +15764,258 @@ function assertPivotRecords(records) {
|
|
|
15346
15764
|
);
|
|
15347
15765
|
}
|
|
15348
15766
|
|
|
15767
|
+
// xlsx/write/xml-out.ts
|
|
15768
|
+
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
15769
|
+
var CONTROL2 = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
15770
|
+
var NEEDS_ESCAPE = new RegExp(`[${CONTROL2}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
15771
|
+
var ESCAPABLE = new RegExp(`[${CONTROL2}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
15772
|
+
function encodeEscapes(text3) {
|
|
15773
|
+
if (!NEEDS_ESCAPE.test(text3)) return text3;
|
|
15774
|
+
return text3.replace(
|
|
15775
|
+
ESCAPABLE,
|
|
15776
|
+
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
15777
|
+
);
|
|
15778
|
+
}
|
|
15779
|
+
var INVALID_XML = new RegExp(`[${CONTROL2}]`, "g");
|
|
15780
|
+
var escapeText2 = (text3) => text3.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
15781
|
+
var escapeAttr3 = (text3) => text3.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
15782
|
+
function attrs(values2) {
|
|
15783
|
+
let out = "";
|
|
15784
|
+
for (const [name, value2] of Object.entries(values2)) {
|
|
15785
|
+
if (value2 === void 0) continue;
|
|
15786
|
+
const text3 = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num2(value2) : value2;
|
|
15787
|
+
out += ` ${name}="${escapeAttr3(text3)}"`;
|
|
15788
|
+
}
|
|
15789
|
+
return out;
|
|
15790
|
+
}
|
|
15791
|
+
var el = (name, values2 = {}, content2 = "") => content2 ? `<${name}${attrs(values2)}>${content2}</${name}>` : `<${name}${attrs(values2)}/>`;
|
|
15792
|
+
var num2 = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
15793
|
+
function tElement(text3, name = "t") {
|
|
15794
|
+
const encoded = escapeText2(encodeEscapes(text3));
|
|
15795
|
+
const preserve = /^\s|\s$|\n|\t/.test(text3) ? ' xml:space="preserve"' : "";
|
|
15796
|
+
return `<${name}${preserve}>${encoded}</${name}>`;
|
|
15797
|
+
}
|
|
15798
|
+
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
15799
|
+
function inlineFragment(xml) {
|
|
15800
|
+
const end = xml.indexOf(">");
|
|
15801
|
+
if (end < 0) return xml;
|
|
15802
|
+
const head = xml.slice(0, end);
|
|
15803
|
+
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
15804
|
+
}
|
|
15805
|
+
|
|
15806
|
+
// xlsx/pivot/values-axis.ts
|
|
15807
|
+
function remapPivotRowEntries(entries, axes3) {
|
|
15808
|
+
return entries.map(
|
|
15809
|
+
(entry3) => entry3.type === "grand" ? entry3 : {
|
|
15810
|
+
...entry3,
|
|
15811
|
+
indices: entry3.indices.map((item, axis) => {
|
|
15812
|
+
const index3 = axes3[axis]?.[item];
|
|
15813
|
+
if (index3 === void 0) throw new Error("Invalid report row axis item");
|
|
15814
|
+
return index3;
|
|
15815
|
+
})
|
|
15816
|
+
}
|
|
15817
|
+
);
|
|
15818
|
+
}
|
|
15819
|
+
function pivotFieldIndex(field) {
|
|
15820
|
+
const raw2 = field?.getAttribute("x");
|
|
15821
|
+
if (raw2 === null || raw2 === void 0 || !/^-?\d+$/.test(raw2.trim())) return NaN;
|
|
15822
|
+
const value2 = Number(raw2);
|
|
15823
|
+
return Number.isSafeInteger(value2) ? value2 : NaN;
|
|
15824
|
+
}
|
|
15825
|
+
function pivotValueIndex(root, axis) {
|
|
15826
|
+
const index3 = axis.findIndex((field) => pivotFieldIndex(field) === -2);
|
|
15827
|
+
const position = root.getAttribute("dataPosition");
|
|
15828
|
+
if (position !== null && (!/^\d+$/.test(position.trim()) || Number(position) !== index3))
|
|
15829
|
+
throw new Error("Inconsistent Values axis position");
|
|
15830
|
+
if (axis.length === 3 && index3 < 2 && position === null)
|
|
15831
|
+
throw new Error("Missing leading or between-field Values position");
|
|
15832
|
+
return index3;
|
|
15833
|
+
}
|
|
15834
|
+
function pivotValueAxisItems(measures, columns, columnIndices) {
|
|
15835
|
+
const entries = [];
|
|
15836
|
+
if (columns === void 0) {
|
|
15837
|
+
for (let measure = 0; measure < measures; measure++)
|
|
15838
|
+
entries.push(
|
|
15839
|
+
`<i${attrs({ i: measure || void 0 })}><x${attrs({ v: measure || void 0 })}/></i>`
|
|
15840
|
+
);
|
|
15841
|
+
} else {
|
|
15842
|
+
for (let column = 0; column < columns; column++)
|
|
15843
|
+
for (let measure = 0; measure < measures; measure++) {
|
|
15844
|
+
entries.push(
|
|
15845
|
+
`<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>`
|
|
15846
|
+
);
|
|
15847
|
+
}
|
|
15848
|
+
for (let measure = 0; measure < measures; measure++)
|
|
15849
|
+
entries.push(`<i${attrs({ t: "grand", i: measure || void 0 })}><x/></i>`);
|
|
15850
|
+
}
|
|
15851
|
+
return `<colItems count="${entries.length}">${entries.join("")}</colItems>`;
|
|
15852
|
+
}
|
|
15853
|
+
function supportedPivotAxes(rows, columns, measures, valuesOnRows) {
|
|
15854
|
+
const index3 = pivotFieldIndex;
|
|
15855
|
+
if (valuesOnRows)
|
|
15856
|
+
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);
|
|
15857
|
+
if (rows.some((field) => !Number.isInteger(index3(field)) || index3(field) < 0)) return false;
|
|
15858
|
+
return measures === 1 ? columns.length <= 1 : columns.length >= 1 && columns.length <= 2 && index3(columns.at(-1)) === -2 && (columns.length !== 2 || index3(columns[0]) >= 0);
|
|
15859
|
+
}
|
|
15860
|
+
|
|
15861
|
+
// drawingml/dom.ts
|
|
15862
|
+
function attributeReader(element2) {
|
|
15863
|
+
return (name) => {
|
|
15864
|
+
if (!element2) return void 0;
|
|
15865
|
+
const direct = element2.getAttribute(name);
|
|
15866
|
+
if (direct !== null) return direct;
|
|
15867
|
+
const attributes = element2.attributes;
|
|
15868
|
+
for (let index3 = 0; index3 < attributes.length; index3++) {
|
|
15869
|
+
const candidate = attributes.item(index3);
|
|
15870
|
+
if (candidate && candidate.localName === name) return candidate.value;
|
|
15871
|
+
}
|
|
15872
|
+
return void 0;
|
|
15873
|
+
};
|
|
15874
|
+
}
|
|
15875
|
+
function stringAttribute(element2, name) {
|
|
15876
|
+
const value2 = attributeReader(element2)(name)?.trim();
|
|
15877
|
+
return value2 ? value2 : void 0;
|
|
15878
|
+
}
|
|
15879
|
+
function integerAttribute(element2, name) {
|
|
15880
|
+
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
15881
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
15882
|
+
}
|
|
15883
|
+
function booleanAttribute(element2, name) {
|
|
15884
|
+
const value2 = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
15885
|
+
if (value2 === "1" || value2 === "true") return true;
|
|
15886
|
+
if (value2 === "0" || value2 === "false") return false;
|
|
15887
|
+
return void 0;
|
|
15888
|
+
}
|
|
15889
|
+
function descendants2(root, local) {
|
|
15890
|
+
const result2 = [];
|
|
15891
|
+
const visit2 = (node) => {
|
|
15892
|
+
for (const child3 of Array.from(node.childNodes)) {
|
|
15893
|
+
if (!isElement(child3)) continue;
|
|
15894
|
+
if (child3.localName === local) result2.push(child3);
|
|
15895
|
+
visit2(child3);
|
|
15896
|
+
}
|
|
15897
|
+
};
|
|
15898
|
+
visit2(root);
|
|
15899
|
+
return result2;
|
|
15900
|
+
}
|
|
15901
|
+
|
|
15902
|
+
// xlsx/pivot/page-filter-admission.ts
|
|
15903
|
+
var integer = (value2, fallback) => value2 === null ? fallback ?? NaN : /^\d+$/.test(value2.trim()) && Number.isSafeInteger(Number(value2)) ? Number(value2) : NaN;
|
|
15904
|
+
function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
15905
|
+
if (!pivot.pageFilter) return;
|
|
15906
|
+
const literals = (node) => {
|
|
15907
|
+
const raw2 = node.getAttribute("v");
|
|
15908
|
+
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())))
|
|
15909
|
+
throw new Error("Unmodeled report cache literal");
|
|
15910
|
+
for (const child3 of elements(node)) literals(child3);
|
|
15911
|
+
};
|
|
15912
|
+
literals(cache3);
|
|
15913
|
+
literals(recordRoot);
|
|
15914
|
+
const cacheFields = children(first(cache3, "cacheFields", NS.x), "cacheField", NS.x);
|
|
15915
|
+
if (pivot.columnField) {
|
|
15916
|
+
const column = children(first(root, "pivotFields", NS.x), "pivotField", NS.x)[pivot.fields.indexOf(pivot.columnField)];
|
|
15917
|
+
const list = first(column, "extLst", NS.x);
|
|
15918
|
+
const extensions = list ? children(list, "ext", NS.x) : [];
|
|
15919
|
+
if (extensions.some(
|
|
15920
|
+
(extension) => children(
|
|
15921
|
+
extension,
|
|
15922
|
+
"pivotField",
|
|
15923
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
15924
|
+
).some((field) => {
|
|
15925
|
+
const raw2 = field.getAttribute("fillDownLabels");
|
|
15926
|
+
if (raw2 !== null && !["0", "1", "false", "true"].includes(raw2.trim()))
|
|
15927
|
+
throw new Error("Invalid report column label repetition");
|
|
15928
|
+
return booleanAttribute(field, "fillDownLabels") === true;
|
|
15929
|
+
})
|
|
15930
|
+
))
|
|
15931
|
+
throw new Error("Repeated report column labels are preserved");
|
|
15932
|
+
}
|
|
15933
|
+
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)
|
|
15934
|
+
throw new Error("Inconsistent report cache counts");
|
|
15935
|
+
for (const name of [
|
|
15936
|
+
pivot.rowField,
|
|
15937
|
+
pivot.secondRowField,
|
|
15938
|
+
pivot.columnField,
|
|
15939
|
+
pivot.pageFilter.field
|
|
15940
|
+
].filter(Boolean)) {
|
|
15941
|
+
const field = pivot.fields.indexOf(name);
|
|
15942
|
+
if (integer(first(cacheFields[field], "sharedItems", NS.x)?.getAttribute("count") ?? null) !== shared[field].length)
|
|
15943
|
+
throw new Error("Inconsistent report shared-item counts");
|
|
15944
|
+
}
|
|
15945
|
+
for (const name of ["rowFields", "colFields"]) {
|
|
15946
|
+
const list = first(root, name, NS.x);
|
|
15947
|
+
if (list && integer(list.getAttribute("count")) !== children(list, "field", NS.x).length)
|
|
15948
|
+
throw new Error("Inconsistent report axis counts");
|
|
15949
|
+
}
|
|
15950
|
+
const projected = pivotPageProjection(pivot), fields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
15951
|
+
const axisValues = (name, axis) => {
|
|
15952
|
+
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;
|
|
15953
|
+
if (node.getAttribute("axis") !== axis) throw new Error("Inconsistent report axis field");
|
|
15954
|
+
const defaults = node.getAttribute("defaultSubtotal") !== "0";
|
|
15955
|
+
if (!list || integer(list.getAttribute("count")) !== items.length || items.length !== count2 + Number(defaults))
|
|
15956
|
+
throw new Error("Incomplete page-axis field items");
|
|
15957
|
+
const data = items.slice(0, count2).map((item) => {
|
|
15958
|
+
const i2 = integer(item.getAttribute("x"));
|
|
15959
|
+
if (item.hasAttribute("t") || !Number.isInteger(i2) || i2 >= count2)
|
|
15960
|
+
throw new Error("Invalid page-axis cache item");
|
|
15961
|
+
return shared[f6][i2];
|
|
15962
|
+
});
|
|
15963
|
+
if (new Set(data.map(pivotValueKey)).size !== count2 || defaults && (items.at(-1)?.getAttribute("t") !== "default" || items.at(-1)?.hasAttribute("x")))
|
|
15964
|
+
throw new Error("Invalid page-axis default item");
|
|
15965
|
+
const indices = new Map(data.map((v, i2) => [pivotValueKey(v), i2]));
|
|
15966
|
+
return pivotItems(projected, name).map((v) => indices.get(pivotValueKey(v)));
|
|
15967
|
+
};
|
|
15968
|
+
const read = (name) => {
|
|
15969
|
+
const list = first(root, name, NS.x), items = children(list, "i", NS.x);
|
|
15970
|
+
if (!list || integer(list.getAttribute("count")) !== items.length)
|
|
15971
|
+
throw new Error("Invalid page-axis item count");
|
|
15972
|
+
return items;
|
|
15973
|
+
};
|
|
15974
|
+
const rows = axisValues(pivot.rowField, "axisRow"), rowItems = read("rowItems");
|
|
15975
|
+
const grid = pivotGrid(pivot);
|
|
15976
|
+
const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, [
|
|
15977
|
+
rows,
|
|
15978
|
+
pivot.secondRowField ? axisValues(pivot.secondRowField, "axisRow") : []
|
|
15979
|
+
]) : [
|
|
15980
|
+
...rows.map((index3) => ({ indices: [index3], type: void 0 })),
|
|
15981
|
+
{ indices: [0], type: "grand" }
|
|
15982
|
+
];
|
|
15983
|
+
if (rowItems.length !== entries.length) throw new Error("Invalid page row items");
|
|
15984
|
+
let previousRow = [];
|
|
15985
|
+
rowItems.forEach((item, i2) => {
|
|
15986
|
+
const expected2 = entries[i2];
|
|
15987
|
+
const xs = children(item, "x", NS.x).map((x) => integer(x.getAttribute("v"), 0)), prefix = integer(item.getAttribute("r"), 0);
|
|
15988
|
+
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))
|
|
15989
|
+
throw new Error("Unmodeled page row item");
|
|
15990
|
+
previousRow = expected2.type ? [] : expected2.indices;
|
|
15991
|
+
});
|
|
15992
|
+
const measures = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
15993
|
+
if (columns)
|
|
15994
|
+
for (const col of columns)
|
|
15995
|
+
for (let m = 0; m < measures; m++) expected.push(measures > 1 ? [col, m] : [col]);
|
|
15996
|
+
else for (let m = 0; m < measures; m++) expected.push([m]);
|
|
15997
|
+
const colItems = read("colItems");
|
|
15998
|
+
if (colItems.length !== expected.length + (columns ? measures : 0))
|
|
15999
|
+
throw new Error("Invalid page column items");
|
|
16000
|
+
let previous = [];
|
|
16001
|
+
colItems.forEach((item, i2) => {
|
|
16002
|
+
const grand = i2 >= expected.length, measure = grand ? i2 - expected.length : i2 % measures;
|
|
16003
|
+
const xs = children(item, "x", NS.x).map((x) => integer(x.getAttribute("v"), 0)), prefix = integer(item.getAttribute("r"), 0);
|
|
16004
|
+
if (integer(item.getAttribute("i"), 0) !== measure || !Number.isInteger(prefix) || prefix < 0 || prefix > Math.max(0, previous.length - 1))
|
|
16005
|
+
throw new Error("Invalid page column prefix");
|
|
16006
|
+
if (grand) {
|
|
16007
|
+
if (item.getAttribute("t") !== "grand" || prefix !== 0 || xs.length !== 1 || xs[0] !== 0)
|
|
16008
|
+
throw new Error("Unmodeled page grand item");
|
|
16009
|
+
previous = [];
|
|
16010
|
+
return;
|
|
16011
|
+
}
|
|
16012
|
+
const values2 = !columns && measures === 1 && xs.length === 0 && prefix === 0 ? [0] : [...previous.slice(0, prefix), ...xs];
|
|
16013
|
+
if (item.hasAttribute("t") || JSON.stringify(values2) !== JSON.stringify(expected[i2]))
|
|
16014
|
+
throw new Error("Unmodeled page column item");
|
|
16015
|
+
previous = values2;
|
|
16016
|
+
});
|
|
16017
|
+
}
|
|
16018
|
+
|
|
15349
16019
|
// xlsx/pivot/read.ts
|
|
15350
16020
|
function value(node) {
|
|
15351
16021
|
const v = att(node, "v") ?? "";
|
|
@@ -15380,22 +16050,24 @@ function readOne(workbook, source2, part) {
|
|
|
15380
16050
|
const dataSheet = sourceNode && att(sourceNode, "sheet");
|
|
15381
16051
|
const dataRange = sourceNode && parseRange(att(sourceNode, "ref") ?? "");
|
|
15382
16052
|
const recordPart = source2.targetOfType(cachePart, `${NS.r}/pivotCacheRecords`);
|
|
16053
|
+
const rowsAxis = att(root, "dataOnRows") === "1";
|
|
15383
16054
|
if (!dataSheet || !dataRange || !recordPart || !workbook.sheets.some((sheet) => sheet.name === dataSheet))
|
|
15384
16055
|
throw new Error("Unsupported pivot source");
|
|
15385
|
-
|
|
16056
|
+
const recordRoot = parseXml(source2.text(recordPart)).documentElement;
|
|
16057
|
+
assertPivotRecords(recordRoot);
|
|
15386
16058
|
const fields = children(first(cache3, "cacheFields", NS.x), "cacheField", NS.x);
|
|
15387
16059
|
if (fields.some((field) => first(field, "fieldGroup", NS.x) || field.hasAttribute("formula")))
|
|
15388
16060
|
throw new Error("Grouped or calculated cache field");
|
|
15389
16061
|
const shared = fields.map(
|
|
15390
16062
|
(field) => elements(first(field, "sharedItems", NS.x) ?? parseXml("<root/>").documentElement).map(value)
|
|
15391
16063
|
);
|
|
15392
|
-
const records = children(
|
|
16064
|
+
const records = children(recordRoot, "r", NS.x).map(
|
|
15393
16065
|
(record) => elements(record).map((node, field) => {
|
|
15394
16066
|
if (node.localName !== "x") return value(node);
|
|
15395
|
-
const
|
|
15396
|
-
if (!Number.isInteger(
|
|
16067
|
+
const index3 = Number(att(node, "v"));
|
|
16068
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= (shared[field]?.length ?? 0))
|
|
15397
16069
|
throw new Error("Invalid pivot cache index");
|
|
15398
|
-
return shared[field][
|
|
16070
|
+
return shared[field][index3];
|
|
15399
16071
|
})
|
|
15400
16072
|
);
|
|
15401
16073
|
if (records.some((record) => record.length !== fields.length) || records.length * fields.length > 1e6)
|
|
@@ -15415,17 +16087,43 @@ function readOne(workbook, source2, part) {
|
|
|
15415
16087
|
"dataField",
|
|
15416
16088
|
NS.x
|
|
15417
16089
|
);
|
|
15418
|
-
if (rowFields.length < 1 || rowFields.length > 2 ||
|
|
16090
|
+
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")
|
|
15419
16091
|
throw new Error("Unsupported pivot layout");
|
|
16092
|
+
const valueIndex = pivotValueIndex(root, rowsAxis ? rowFields : colFields);
|
|
15420
16093
|
const measure = dataFields[0];
|
|
16094
|
+
const definition = elements(first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement).map(
|
|
16095
|
+
(extension) => first(
|
|
16096
|
+
extension,
|
|
16097
|
+
"pivotTableDefinition",
|
|
16098
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
16099
|
+
)
|
|
16100
|
+
).find(Boolean);
|
|
16101
|
+
if (dataFields.length > 1 && att(definition, "hideValuesRow") !== "1")
|
|
16102
|
+
throw new Error("Visible Values header rows are preserved");
|
|
16103
|
+
for (const [axis, count2] of [
|
|
16104
|
+
["rowItems", rowsAxis ? dataFields.length : 1],
|
|
16105
|
+
["colItems", rowsAxis ? 1 : dataFields.length]
|
|
16106
|
+
]) {
|
|
16107
|
+
for (const item of children(
|
|
16108
|
+
first(root, axis, NS.x) ?? parseXml("<root/>").documentElement,
|
|
16109
|
+
"i",
|
|
16110
|
+
NS.x
|
|
16111
|
+
)) {
|
|
16112
|
+
const index3 = Number(att(item, "i") ?? "0");
|
|
16113
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= count2)
|
|
16114
|
+
throw new Error("Unsupported Values axis item");
|
|
16115
|
+
}
|
|
16116
|
+
}
|
|
15421
16117
|
const aggregate3 = att(measure, "subtotal") ?? "sum";
|
|
15422
16118
|
if (!PIVOT_AGGREGATES.includes(aggregate3) || att(measure, "showDataAs") && att(measure, "showDataAs") !== "normal")
|
|
15423
16119
|
throw new Error("Unsupported pivot aggregate");
|
|
15424
16120
|
const names = fields.map((field) => decodeEscapes(att(field, "name") ?? ""));
|
|
15425
|
-
const
|
|
15426
|
-
const
|
|
16121
|
+
const realRows = rowsAxis ? rowFields.filter((field) => pivotFieldIndex(field) !== -2) : rowFields;
|
|
16122
|
+
const row2 = names[pivotFieldIndex(realRows[0])];
|
|
16123
|
+
const second = realRows[1] ? names[Number(att(realRows[1], "x"))] : void 0;
|
|
16124
|
+
const pageFilter = readPivotPageFilter(root, names, shared);
|
|
15427
16125
|
const tableFields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
15428
|
-
const outer = tableFields[
|
|
16126
|
+
const outer = tableFields[pivotFieldIndex(realRows[0])];
|
|
15429
16127
|
const compact3 = att(outer, "compact") !== "0";
|
|
15430
16128
|
const outline = att(outer, "outline") !== "0";
|
|
15431
16129
|
const layout2 = compact3 ? "compact" : outline ? "outline" : "tabular";
|
|
@@ -15434,7 +16132,7 @@ function readOne(workbook, source2, part) {
|
|
|
15434
16132
|
) || att(root, "compact") !== "0" !== compact3 || att(root, "compactData") !== "0" !== compact3 || att(root, "outline") === "1" !== outline || att(root, "outlineData") === "1" !== outline || layout2 === "compact" && att(root, "indent") !== "0")
|
|
15435
16133
|
throw new Error("Mixed field layouts or custom compact indentation are preserved");
|
|
15436
16134
|
const subtotal = att(outer, "defaultSubtotal") !== "0";
|
|
15437
|
-
const repeat =
|
|
16135
|
+
const repeat = realRows.map((field) => {
|
|
15438
16136
|
const node = tableFields[Number(att(field, "x"))];
|
|
15439
16137
|
const extension = first(first(node, "extLst", NS.x), "ext", NS.x);
|
|
15440
16138
|
return att(
|
|
@@ -15447,16 +16145,24 @@ function readOne(workbook, source2, part) {
|
|
|
15447
16145
|
) === "1";
|
|
15448
16146
|
});
|
|
15449
16147
|
if (repeat.some((entry4) => entry4 !== repeat[0])) throw new Error("Mixed field label repetition");
|
|
15450
|
-
const
|
|
16148
|
+
const hasColumn = colFields.length > (dataFields.length > 1 && !rowsAxis ? 1 : 0);
|
|
16149
|
+
const col = hasColumn ? names[Number(att(colFields[0], "x"))] : void 0;
|
|
15451
16150
|
const data = names[Number(att(measure, "fld"))];
|
|
15452
16151
|
const location = parseRange(att(first(root, "location", NS.x), "ref") ?? "");
|
|
15453
|
-
if (!row2 || !data || !location ||
|
|
16152
|
+
if (!row2 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
|
|
15454
16153
|
throw new Error("Invalid pivot fields");
|
|
16154
|
+
if (pageFilter) {
|
|
16155
|
+
if (location.start.row < 2) throw new Error("Invalid report filter location");
|
|
16156
|
+
location.start.row -= 2;
|
|
16157
|
+
}
|
|
15455
16158
|
const pivot = {
|
|
16159
|
+
...pageFilter ? { pageFilter } : {},
|
|
15456
16160
|
name: att(root, "name") ?? "PivotTable",
|
|
15457
16161
|
source: `${quoteSheetName(dataSheet)}!${formatRange(dataRange)}`,
|
|
15458
16162
|
rowField: row2,
|
|
15459
16163
|
layout: layout2,
|
|
16164
|
+
...rowsAxis ? { valuesAxis: "rows" } : {},
|
|
16165
|
+
...rowsAxis && realRows.length === 2 && valueIndex < 2 ? { valuesPosition: valueIndex === 0 ? "first" : "between" } : {},
|
|
15460
16166
|
subtotalPosition: att(outer, "subtotalTop") === "0" ? "bottom" : "top",
|
|
15461
16167
|
...second ? { secondRowField: second, subtotals: subtotal, repeatLabels: repeat[0] ?? false } : {
|
|
15462
16168
|
...subtotal ? {} : { subtotals: false },
|
|
@@ -15465,6 +16171,15 @@ function readOne(workbook, source2, part) {
|
|
|
15465
16171
|
valueField: data,
|
|
15466
16172
|
aggregate: aggregate3,
|
|
15467
16173
|
valueCaption: decodeEscapes(att(measure, "name") ?? data),
|
|
16174
|
+
...dataFields.length > 1 ? {
|
|
16175
|
+
additionalValues: dataFields.slice(1).map((measure2) => {
|
|
16176
|
+
const field = names[Number(att(measure2, "fld"))];
|
|
16177
|
+
const aggregate4 = att(measure2, "subtotal") ?? "sum";
|
|
16178
|
+
if (!field || !PIVOT_AGGREGATES.includes(aggregate4) || att(measure2, "showDataAs") && att(measure2, "showDataAs") !== "normal")
|
|
16179
|
+
throw new Error("Unsupported pivot measure");
|
|
16180
|
+
return { field, aggregate: aggregate4, caption: decodeEscapes(att(measure2, "name") ?? field) };
|
|
16181
|
+
})
|
|
16182
|
+
} : {},
|
|
15468
16183
|
fields: names,
|
|
15469
16184
|
records,
|
|
15470
16185
|
location,
|
|
@@ -15473,6 +16188,7 @@ function readOne(workbook, source2, part) {
|
|
|
15473
16188
|
sourceXml: xml,
|
|
15474
16189
|
...col ? { columnField: col } : {}
|
|
15475
16190
|
};
|
|
16191
|
+
assertPageAxisItems(root, pivot, shared, cache3, recordRoot);
|
|
15476
16192
|
return pivot;
|
|
15477
16193
|
}
|
|
15478
16194
|
function readPivotTables(workbook, source2, warn) {
|
|
@@ -15798,10 +16514,10 @@ function parseDynamicArrayMetadata(xml) {
|
|
|
15798
16514
|
const flag2 = props?.getAttribute("fDynamic");
|
|
15799
16515
|
return flag2 === "1" || flag2 === "true";
|
|
15800
16516
|
});
|
|
15801
|
-
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk,
|
|
16517
|
+
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk, index3) => {
|
|
15802
16518
|
for (const rc of childrenNamed(bk, "rc")) {
|
|
15803
16519
|
const type = types[Number(att(rc, "t")) - 1];
|
|
15804
|
-
if (type === DYNAMIC_ARRAY_TYPE && dynamic[Number(att(rc, "v"))]) out.add(
|
|
16520
|
+
if (type === DYNAMIC_ARRAY_TYPE && dynamic[Number(att(rc, "v"))]) out.add(index3 + 1);
|
|
15805
16521
|
}
|
|
15806
16522
|
});
|
|
15807
16523
|
return out;
|
|
@@ -16079,13 +16795,13 @@ function parseStyles(xml, warnings) {
|
|
|
16079
16795
|
const named2 = namesByXf.get(xfId);
|
|
16080
16796
|
if (named2 && xfId !== 0 && named2 !== "Normal") style2.cellStyleName = named2;
|
|
16081
16797
|
const key = styleKey(style2);
|
|
16082
|
-
let
|
|
16083
|
-
if (
|
|
16084
|
-
|
|
16798
|
+
let index3 = keys.get(key);
|
|
16799
|
+
if (index3 === void 0) {
|
|
16800
|
+
index3 = styles.length;
|
|
16085
16801
|
styles.push(style2);
|
|
16086
|
-
keys.set(key,
|
|
16802
|
+
keys.set(key, index3);
|
|
16087
16803
|
}
|
|
16088
|
-
xfMap.push(
|
|
16804
|
+
xfMap.push(index3);
|
|
16089
16805
|
}
|
|
16090
16806
|
if (!styles.length) {
|
|
16091
16807
|
styles.push(fallback);
|
|
@@ -16494,11 +17210,11 @@ function sigmaGradientStops(stops) {
|
|
|
16494
17210
|
const front = hexToRgbChannels(stops[0].color);
|
|
16495
17211
|
const back = hexToRgbChannels(stops[1].color);
|
|
16496
17212
|
if (!front || !back) return void 0;
|
|
16497
|
-
return OFFICE_SIGMA_FACTORS.map((value2,
|
|
17213
|
+
return OFFICE_SIGMA_FACTORS.map((value2, index3) => {
|
|
16498
17214
|
const factor = value2 / 65536;
|
|
16499
17215
|
const mix = (a2, b) => toHex(255 * ((a2 / 255) ** 2.2 * (1 - factor) + (b / 255) ** 2.2 * factor) ** (1 / 2.2));
|
|
16500
17216
|
return {
|
|
16501
|
-
offset: Math.fround(
|
|
17217
|
+
offset: Math.fround(index3 / 255),
|
|
16502
17218
|
color: `#${mix(front.r, back.r)}${mix(front.g, back.g)}${mix(front.b, back.b)}`,
|
|
16503
17219
|
opacity: 1
|
|
16504
17220
|
};
|
|
@@ -16515,47 +17231,6 @@ function parseArgbHex(hex) {
|
|
|
16515
17231
|
var clamp255 = (v) => Math.max(0, Math.min(255, v));
|
|
16516
17232
|
var rgbToUpperHex = (rgb2) => `#${rgb2.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
16517
17233
|
|
|
16518
|
-
// drawingml/dom.ts
|
|
16519
|
-
function attributeReader(element2) {
|
|
16520
|
-
return (name) => {
|
|
16521
|
-
if (!element2) return void 0;
|
|
16522
|
-
const direct = element2.getAttribute(name);
|
|
16523
|
-
if (direct !== null) return direct;
|
|
16524
|
-
const attributes = element2.attributes;
|
|
16525
|
-
for (let index2 = 0; index2 < attributes.length; index2++) {
|
|
16526
|
-
const candidate = attributes.item(index2);
|
|
16527
|
-
if (candidate && candidate.localName === name) return candidate.value;
|
|
16528
|
-
}
|
|
16529
|
-
return void 0;
|
|
16530
|
-
};
|
|
16531
|
-
}
|
|
16532
|
-
function stringAttribute(element2, name) {
|
|
16533
|
-
const value2 = attributeReader(element2)(name)?.trim();
|
|
16534
|
-
return value2 ? value2 : void 0;
|
|
16535
|
-
}
|
|
16536
|
-
function integerAttribute(element2, name) {
|
|
16537
|
-
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
16538
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
16539
|
-
}
|
|
16540
|
-
function booleanAttribute(element2, name) {
|
|
16541
|
-
const value2 = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
16542
|
-
if (value2 === "1" || value2 === "true") return true;
|
|
16543
|
-
if (value2 === "0" || value2 === "false") return false;
|
|
16544
|
-
return void 0;
|
|
16545
|
-
}
|
|
16546
|
-
function descendants2(root, local) {
|
|
16547
|
-
const result2 = [];
|
|
16548
|
-
const visit2 = (node) => {
|
|
16549
|
-
for (const child3 of Array.from(node.childNodes)) {
|
|
16550
|
-
if (!isElement(child3)) continue;
|
|
16551
|
-
if (child3.localName === local) result2.push(child3);
|
|
16552
|
-
visit2(child3);
|
|
16553
|
-
}
|
|
16554
|
-
};
|
|
16555
|
-
visit2(root);
|
|
16556
|
-
return result2;
|
|
16557
|
-
}
|
|
16558
|
-
|
|
16559
17234
|
// drawingml/ordered-color-transforms.ts
|
|
16560
17235
|
function orderedColorTransforms(channels, transforms) {
|
|
16561
17236
|
let { r, g: g2, b } = channels;
|
|
@@ -16877,7 +17552,7 @@ function parseTheme2(xml) {
|
|
|
16877
17552
|
if (!xml) return palette;
|
|
16878
17553
|
const theme2 = parseTheme(parseXml(xml, { label: "XLSX theme" }));
|
|
16879
17554
|
palette.colors = PALETTE_SLOTS.map(
|
|
16880
|
-
(slot2,
|
|
17555
|
+
(slot2, index3) => paletteHex(theme2.colorScheme.colors[slot2]) ?? DEFAULT_THEME.colors[index3] ?? "000000"
|
|
16881
17556
|
);
|
|
16882
17557
|
palette.majorFont = theme2.fontScheme.major.latin ?? palette.majorFont;
|
|
16883
17558
|
palette.minorFont = theme2.fontScheme.minor.latin ?? palette.minorFont;
|
|
@@ -17060,11 +17735,11 @@ function readModernHash(node, prefix = "") {
|
|
|
17060
17735
|
function parseWorkbookPart(xml) {
|
|
17061
17736
|
const root = parseXml(xml, { label: "XLSX workbook" }).documentElement;
|
|
17062
17737
|
const sheets = [];
|
|
17063
|
-
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node,
|
|
17738
|
+
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node, index3) => {
|
|
17064
17739
|
const state = att(node, "state");
|
|
17065
17740
|
sheets.push({
|
|
17066
|
-
name: att(node, "name") ?? `Sheet${
|
|
17067
|
-
sheetId: numAttr(node, "sheetId") ??
|
|
17741
|
+
name: att(node, "name") ?? `Sheet${index3 + 1}`,
|
|
17742
|
+
sheetId: numAttr(node, "sheetId") ?? index3 + 1,
|
|
17068
17743
|
state: state === "hidden" || state === "veryHidden" ? state : "visible",
|
|
17069
17744
|
relId: relAttr(node, "id") ?? ""
|
|
17070
17745
|
});
|
|
@@ -17414,8 +18089,8 @@ function styleRef(element2) {
|
|
|
17414
18089
|
if (element2.localName === "fontRef") {
|
|
17415
18090
|
if (raw2) ref.fontIndex = raw2;
|
|
17416
18091
|
} else {
|
|
17417
|
-
const
|
|
17418
|
-
if (Number.isFinite(
|
|
18092
|
+
const index3 = Number.parseInt(raw2 ?? "", 10);
|
|
18093
|
+
if (Number.isFinite(index3)) ref.index = index3;
|
|
17419
18094
|
}
|
|
17420
18095
|
const color = parseDrawingColorIn(element2);
|
|
17421
18096
|
if (color) ref.color = color;
|
|
@@ -17803,11 +18478,11 @@ function groupTransform(group, parent) {
|
|
|
17803
18478
|
scaleY: parent.scaleY * local.scaleY
|
|
17804
18479
|
};
|
|
17805
18480
|
}
|
|
17806
|
-
function parseShape(sp,
|
|
18481
|
+
function parseShape(sp, index3, group, issues) {
|
|
17807
18482
|
const spPr = first(sp, "spPr", NS.dsp);
|
|
17808
18483
|
const transform6 = parseTransform(first(spPr, "xfrm", NS.a));
|
|
17809
18484
|
if (!transform6) return void 0;
|
|
17810
|
-
const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${
|
|
18485
|
+
const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${index3}`;
|
|
17811
18486
|
const { geometry, adjustments, paths, issue } = parseDrawingGeometry(spPr);
|
|
17812
18487
|
if (issue) issues.push({ code: issue, message: `Shape ${modelId}: ${issue}.` });
|
|
17813
18488
|
const frame = applyGroup(transform6.frame, group);
|
|
@@ -18025,8 +18700,8 @@ function drawingFillXml(fill) {
|
|
|
18025
18700
|
const stops = children(list, "gs", NS.a).filter(
|
|
18026
18701
|
(node) => parseDrawingColorIn(node) && Number.isFinite(Number.parseInt(node.getAttribute("pos") ?? "", 10))
|
|
18027
18702
|
);
|
|
18028
|
-
fill.stops.forEach((stop,
|
|
18029
|
-
const node = stops[
|
|
18703
|
+
fill.stops.forEach((stop, index3) => {
|
|
18704
|
+
const node = stops[index3] ?? doc.createElementNS(NS.a, "a:gs");
|
|
18030
18705
|
if (!node.parentNode) list.appendChild(node);
|
|
18031
18706
|
node.setAttribute("pos", String(Math.round(stop.position * 1e3)));
|
|
18032
18707
|
for (const old of elements(node))
|
|
@@ -18384,8 +19059,8 @@ var OFFICE_GRADIENT_PRESET_DATA = [
|
|
|
18384
19059
|
];
|
|
18385
19060
|
|
|
18386
19061
|
// drawingml/gradient-presets.ts
|
|
18387
|
-
OFFICE_GRADIENT_PRESET_DATA.map(([label3],
|
|
18388
|
-
id:
|
|
19062
|
+
OFFICE_GRADIENT_PRESET_DATA.map(([label3], index3) => ({
|
|
19063
|
+
id: index3 + 1,
|
|
18389
19064
|
label: label3
|
|
18390
19065
|
}));
|
|
18391
19066
|
function officeGradientPresetFill(id) {
|
|
@@ -18993,45 +19668,6 @@ function readDataValidations(node) {
|
|
|
18993
19668
|
return out;
|
|
18994
19669
|
}
|
|
18995
19670
|
|
|
18996
|
-
// xlsx/write/xml-out.ts
|
|
18997
|
-
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
18998
|
-
var CONTROL2 = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
18999
|
-
var NEEDS_ESCAPE = new RegExp(`[${CONTROL2}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
19000
|
-
var ESCAPABLE = new RegExp(`[${CONTROL2}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
19001
|
-
function encodeEscapes(text3) {
|
|
19002
|
-
if (!NEEDS_ESCAPE.test(text3)) return text3;
|
|
19003
|
-
return text3.replace(
|
|
19004
|
-
ESCAPABLE,
|
|
19005
|
-
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
19006
|
-
);
|
|
19007
|
-
}
|
|
19008
|
-
var INVALID_XML = new RegExp(`[${CONTROL2}]`, "g");
|
|
19009
|
-
var escapeText2 = (text3) => text3.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
19010
|
-
var escapeAttr3 = (text3) => text3.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
19011
|
-
function attrs(values2) {
|
|
19012
|
-
let out = "";
|
|
19013
|
-
for (const [name, value2] of Object.entries(values2)) {
|
|
19014
|
-
if (value2 === void 0) continue;
|
|
19015
|
-
const text3 = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num2(value2) : value2;
|
|
19016
|
-
out += ` ${name}="${escapeAttr3(text3)}"`;
|
|
19017
|
-
}
|
|
19018
|
-
return out;
|
|
19019
|
-
}
|
|
19020
|
-
var el = (name, values2 = {}, content2 = "") => content2 ? `<${name}${attrs(values2)}>${content2}</${name}>` : `<${name}${attrs(values2)}/>`;
|
|
19021
|
-
var num2 = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
19022
|
-
function tElement(text3, name = "t") {
|
|
19023
|
-
const encoded = escapeText2(encodeEscapes(text3));
|
|
19024
|
-
const preserve = /^\s|\s$|\n|\t/.test(text3) ? ' xml:space="preserve"' : "";
|
|
19025
|
-
return `<${name}${preserve}>${encoded}</${name}>`;
|
|
19026
|
-
}
|
|
19027
|
-
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
19028
|
-
function inlineFragment(xml) {
|
|
19029
|
-
const end = xml.indexOf(">");
|
|
19030
|
-
if (end < 0) return xml;
|
|
19031
|
-
const head = xml.slice(0, end);
|
|
19032
|
-
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
19033
|
-
}
|
|
19034
|
-
|
|
19035
19671
|
// xlsx/conditional-extensions.ts
|
|
19036
19672
|
var XM = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
19037
19673
|
var URI = "{78C0D931-6437-407d-A8EE-F0AAD7539E65}";
|
|
@@ -19041,8 +19677,8 @@ function writeSettings(node, rule) {
|
|
|
19041
19677
|
if (rule.minLength !== void 0) bar.setAttribute("minLength", String(rule.minLength));
|
|
19042
19678
|
if (rule.maxLength !== void 0) bar.setAttribute("maxLength", String(rule.maxLength));
|
|
19043
19679
|
const thresholds = children(bar, "cfvo", NS.x14);
|
|
19044
|
-
for (const [
|
|
19045
|
-
const target = thresholds[
|
|
19680
|
+
for (const [index3, threshold] of [rule.min, rule.max].entries()) {
|
|
19681
|
+
const target = thresholds[index3];
|
|
19046
19682
|
if (!target) continue;
|
|
19047
19683
|
const oldType = target.getAttribute("type");
|
|
19048
19684
|
if (oldType === "autoMin" && threshold.type === "min" || oldType === "autoMax" && threshold.type === "max")
|
|
@@ -19352,7 +19988,7 @@ function chartCacheValues(cache3) {
|
|
|
19352
19988
|
out[point.index ?? out.length] = numeric2 && text3.trim() !== "" && Number.isFinite(Number(text3)) ? Number(text3) : text3;
|
|
19353
19989
|
}
|
|
19354
19990
|
const size = Math.max(cache3.pointCount ?? 0, out.length);
|
|
19355
|
-
for (let
|
|
19991
|
+
for (let index3 = 0; index3 < size; index3++) if (out[index3] === void 0) out[index3] = "";
|
|
19356
19992
|
return out;
|
|
19357
19993
|
}
|
|
19358
19994
|
var chartSourceValues = (source2) => chartCacheValues(source2?.cache ?? source2?.levels?.[0]);
|
|
@@ -19487,8 +20123,8 @@ function parseCache(node) {
|
|
|
19487
20123
|
type: node.localName === "numCache" || node.localName === "numLit" ? "number" : "string",
|
|
19488
20124
|
points: children(node, "pt", NS.c).map((pt) => {
|
|
19489
20125
|
const point = { value: cChild(pt, "v")?.textContent ?? "" };
|
|
19490
|
-
const
|
|
19491
|
-
if (Number.isInteger(
|
|
20126
|
+
const index3 = Number(attribute(pt, "idx") ?? Number.NaN);
|
|
20127
|
+
if (Number.isInteger(index3) && index3 >= 0) point.index = index3;
|
|
19492
20128
|
const formatCode2 = attribute(pt, "formatCode");
|
|
19493
20129
|
if (formatCode2 !== void 0) point.formatCode = formatCode2;
|
|
19494
20130
|
return point;
|
|
@@ -19714,11 +20350,11 @@ var POINT = /* @__PURE__ */ new Set([
|
|
|
19714
20350
|
]);
|
|
19715
20351
|
function parseDataPoint(context, element2) {
|
|
19716
20352
|
reportUnmodelled(context, element2, POINT);
|
|
19717
|
-
const
|
|
20353
|
+
const index3 = cNumber(context, element2, "idx");
|
|
19718
20354
|
return assignDefined(
|
|
19719
20355
|
{},
|
|
19720
20356
|
{
|
|
19721
|
-
index:
|
|
20357
|
+
index: index3 !== void 0 && Number.isInteger(index3) && index3 >= 0 ? index3 : void 0,
|
|
19722
20358
|
invertIfNegative: cBool(context, element2, "invertIfNegative"),
|
|
19723
20359
|
bubble3D: cBool(context, element2, "bubble3D"),
|
|
19724
20360
|
explosion: cNumber(context, element2, "explosion"),
|
|
@@ -20255,8 +20891,8 @@ var SCHEME_INDEX = {
|
|
|
20255
20891
|
function legacyColor(color) {
|
|
20256
20892
|
if (color?.kind === "srgb") return color.value ? { rgb: color.value.toUpperCase() } : void 0;
|
|
20257
20893
|
if (color?.kind === "scheme") {
|
|
20258
|
-
const
|
|
20259
|
-
return
|
|
20894
|
+
const index3 = SCHEME_INDEX[color.value];
|
|
20895
|
+
return index3 === void 0 ? void 0 : { theme: index3 };
|
|
20260
20896
|
}
|
|
20261
20897
|
return void 0;
|
|
20262
20898
|
}
|
|
@@ -21193,14 +21829,14 @@ var PersonRegistry = class {
|
|
|
21193
21829
|
return `${XML_HEADER}<personList xmlns="${NS.tc}" xmlns:x="${NS.x}">${people}</personList>`;
|
|
21194
21830
|
}
|
|
21195
21831
|
};
|
|
21196
|
-
function vmlShape(comment,
|
|
21832
|
+
function vmlShape(comment, index3, id) {
|
|
21197
21833
|
const { row: row2, col } = comment.address;
|
|
21198
21834
|
const anchor = `${col + 1}, 15, ${Math.max(0, row2 - 1)}, 10, ${col + 3}, 15, ${row2 + 3}, 4`;
|
|
21199
|
-
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:${
|
|
21835
|
+
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>`;
|
|
21200
21836
|
}
|
|
21201
21837
|
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>';
|
|
21202
21838
|
function vmlXml(comments, layout2) {
|
|
21203
|
-
const shapes = comments.map((comment,
|
|
21839
|
+
const shapes = comments.map((comment, index3) => vmlShape(comment, index3, layout2.ids[index3] ?? 0)).join("");
|
|
21204
21840
|
const data = layout2.blocks.join(",");
|
|
21205
21841
|
const base = layout2.base;
|
|
21206
21842
|
if (base && /<\/xml>\s*$/.test(base)) {
|
|
@@ -21231,8 +21867,8 @@ function commentParts(comments, sheetNumber, persons, sheetName, layout2) {
|
|
|
21231
21867
|
const id = guidFrom(`${sheetName}!${ref}:${comment.text}`);
|
|
21232
21868
|
const personId = persons.id(comment.author);
|
|
21233
21869
|
threaded += `<threadedComment ref="${ref}" personId="${personId}" id="${id}"><text>${escapeText2(comment.text)}</text></threadedComment>`;
|
|
21234
|
-
comment.replies.forEach((reply,
|
|
21235
|
-
const replyId = guidFrom(`${id}:reply:${
|
|
21870
|
+
comment.replies.forEach((reply, index3) => {
|
|
21871
|
+
const replyId = guidFrom(`${id}:reply:${index3}:${reply.text}`);
|
|
21236
21872
|
const dT = reply.date ? ` dT="${escapeAttr3(reply.date)}"` : "";
|
|
21237
21873
|
threaded += `<threadedComment ref="${ref}"${dT} personId="${persons.id(reply.author)}" id="${replyId}" parentId="${id}"><text>${escapeText2(reply.text)}</text></threadedComment>`;
|
|
21238
21874
|
});
|
|
@@ -21249,7 +21885,7 @@ Reply:
|
|
|
21249
21885
|
sorted2,
|
|
21250
21886
|
layout2 ?? {
|
|
21251
21887
|
blocks: [sheetNumber],
|
|
21252
|
-
ids: sorted2.map((_,
|
|
21888
|
+
ids: sorted2.map((_, index3) => 1024 * sheetNumber + index3 + 1)
|
|
21253
21889
|
}
|
|
21254
21890
|
);
|
|
21255
21891
|
const parts = { comments: commentsXml, vml };
|
|
@@ -21961,11 +22597,11 @@ var GRAY_VARIATIONS = [
|
|
|
21961
22597
|
{ tint: 8e4 }
|
|
21962
22598
|
];
|
|
21963
22599
|
var ACCENTS2 = ["accent1", "accent2", "accent3", "accent4", "accent5", "accent6"];
|
|
21964
|
-
function colorful(id,
|
|
21965
|
-
return { id, group: "colorful", index:
|
|
22600
|
+
function colorful(id, index3, base) {
|
|
22601
|
+
return { id, group: "colorful", index: index3, meth: "cycle", base, variations: COLORFUL_VARIATIONS };
|
|
21966
22602
|
}
|
|
21967
|
-
function mono(id,
|
|
21968
|
-
return { id, group: "monochromatic", index:
|
|
22603
|
+
function mono(id, index3, accent, meth) {
|
|
22604
|
+
return { id, group: "monochromatic", index: index3, meth, base: [accent], variations: [] };
|
|
21969
22605
|
}
|
|
21970
22606
|
var CHART_COLOR_PALETTES = [
|
|
21971
22607
|
colorful(10, 1, ACCENTS2),
|
|
@@ -22009,9 +22645,9 @@ function chartPaletteSeriesColorChoice(palette, i2, n2) {
|
|
|
22009
22645
|
const round3 = Math.floor(i2 / palette.base.length);
|
|
22010
22646
|
transform6 = (palette.variations.length ? palette.variations[round3 % palette.variations.length] : {}) ?? {};
|
|
22011
22647
|
} else {
|
|
22012
|
-
const
|
|
22648
|
+
const index3 = palette.meth === "withinLinearReversed" ? n2 - 1 - i2 : i2;
|
|
22013
22649
|
base = palette.base[0];
|
|
22014
|
-
transform6 = withinLinearTransform(
|
|
22650
|
+
transform6 = withinLinearTransform(index3, n2);
|
|
22015
22651
|
}
|
|
22016
22652
|
if (!base) throw new RangeError("A chart palette must have a base color");
|
|
22017
22653
|
return {
|
|
@@ -22060,18 +22696,18 @@ function chartColorPalettePatch(chart, id) {
|
|
|
22060
22696
|
const previous = findChartColorPalette(chart.colorPalette ?? 10);
|
|
22061
22697
|
if (!next) return void 0;
|
|
22062
22698
|
const radial = chart.chartType === "pie" || chart.chartType === "doughnut";
|
|
22063
|
-
const series = chart.series.map((series2,
|
|
22699
|
+
const series = chart.series.map((series2, index3) => {
|
|
22064
22700
|
const copy = structuredClone(series2);
|
|
22065
22701
|
if (!previous) return copy;
|
|
22066
|
-
const previousChoice = chartPaletteSeriesColorChoice(previous,
|
|
22067
|
-
const nextChoice = chartPaletteSeriesColorChoice(next,
|
|
22702
|
+
const previousChoice = chartPaletteSeriesColorChoice(previous, index3, chart.series.length);
|
|
22703
|
+
const nextChoice = chartPaletteSeriesColorChoice(next, index3, chart.series.length);
|
|
22068
22704
|
const fill = recolorGradient(copy.fill, previousChoice, nextChoice);
|
|
22069
22705
|
if (fill) copy.fill = fill;
|
|
22070
22706
|
if (sameChartColor(
|
|
22071
22707
|
series2.drawingColor,
|
|
22072
|
-
chartPaletteSeriesColorChoice(previous,
|
|
22708
|
+
chartPaletteSeriesColorChoice(previous, index3, chart.series.length)
|
|
22073
22709
|
)) {
|
|
22074
|
-
copy.drawingColor = chartPaletteSeriesColorChoice(next,
|
|
22710
|
+
copy.drawingColor = chartPaletteSeriesColorChoice(next, index3, chart.series.length);
|
|
22075
22711
|
delete copy.color;
|
|
22076
22712
|
}
|
|
22077
22713
|
if (radial && copy.pointColors) {
|
|
@@ -22179,8 +22815,8 @@ var DEFAULT_THEME_COLORS = [
|
|
|
22179
22815
|
"0563C1",
|
|
22180
22816
|
"954F72"
|
|
22181
22817
|
];
|
|
22182
|
-
function themeColor(theme2,
|
|
22183
|
-
const hex = theme2.colors[
|
|
22818
|
+
function themeColor(theme2, index3) {
|
|
22819
|
+
const hex = theme2.colors[index3] ?? DEFAULT_THEME_COLORS[index3];
|
|
22184
22820
|
return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
|
|
22185
22821
|
}
|
|
22186
22822
|
|
|
@@ -22276,18 +22912,18 @@ function mixColors(a2, b, t, rounding = "nearest") {
|
|
|
22276
22912
|
}
|
|
22277
22913
|
|
|
22278
22914
|
// xlsx/edit/chart-series-target.ts
|
|
22279
|
-
function chartSeriesAt(chart,
|
|
22280
|
-
const target = isSeriesPosition(chart,
|
|
22281
|
-
if (!target) throw new RangeError(`No chart series at index ${String(
|
|
22915
|
+
function chartSeriesAt(chart, index3) {
|
|
22916
|
+
const target = isSeriesPosition(chart, index3) ? chart.series.find((_, position) => position === index3) : void 0;
|
|
22917
|
+
if (!target) throw new RangeError(`No chart series at index ${String(index3)}`);
|
|
22282
22918
|
return target;
|
|
22283
22919
|
}
|
|
22284
|
-
function cloneChartSeriesForEdit(chart,
|
|
22285
|
-
chartSeriesAt(chart,
|
|
22920
|
+
function cloneChartSeriesForEdit(chart, index3) {
|
|
22921
|
+
chartSeriesAt(chart, index3);
|
|
22286
22922
|
const series = structuredClone(chart.series);
|
|
22287
|
-
return { series, target: series.find((_, position) => position ===
|
|
22923
|
+
return { series, target: series.find((_, position) => position === index3) };
|
|
22288
22924
|
}
|
|
22289
|
-
function isSeriesPosition(chart,
|
|
22290
|
-
return typeof
|
|
22925
|
+
function isSeriesPosition(chart, index3) {
|
|
22926
|
+
return typeof index3 === "number" && Number.isSafeInteger(index3) && index3 >= 0 && index3 < chart.series.length;
|
|
22291
22927
|
}
|
|
22292
22928
|
|
|
22293
22929
|
// xlsx/edit/chart-series-fill.ts
|
|
@@ -22303,8 +22939,8 @@ function chartDrawingColor(color) {
|
|
|
22303
22939
|
if (!Number.isFinite(tint) || tint < -1 || tint > 1) return void 0;
|
|
22304
22940
|
return tint !== 0 ? withDrawingColorBrightness(choice, tint * 100) : choice;
|
|
22305
22941
|
}
|
|
22306
|
-
function chartSeriesFillPatch(chart,
|
|
22307
|
-
const current = chartSeriesAt(chart,
|
|
22942
|
+
function chartSeriesFillPatch(chart, index3, color) {
|
|
22943
|
+
const current = chartSeriesAt(chart, index3);
|
|
22308
22944
|
const choice = color === null ? void 0 : chartDrawingColor(color);
|
|
22309
22945
|
if (color !== null && !choice) throw new RangeError("Invalid chart fill color");
|
|
22310
22946
|
const previous = current.fill?.kind === "solid" ? current.fill.color : current.drawingColor;
|
|
@@ -22316,27 +22952,27 @@ function chartSeriesFillPatch(chart, index2, color) {
|
|
|
22316
22952
|
) ?? []
|
|
22317
22953
|
)
|
|
22318
22954
|
);
|
|
22319
|
-
return replaceSeriesPaint(chart,
|
|
22955
|
+
return replaceSeriesPaint(chart, index3, choice);
|
|
22320
22956
|
}
|
|
22321
|
-
function chartSeriesSolidFillPatch(chart,
|
|
22322
|
-
const current = chartSeriesAt(chart,
|
|
22957
|
+
function chartSeriesSolidFillPatch(chart, index3) {
|
|
22958
|
+
const current = chartSeriesAt(chart, index3);
|
|
22323
22959
|
if (!current.fill || current.fill.kind === "solid") return void 0;
|
|
22324
22960
|
const choice = current.fill.kind === "gradient" ? current.fill.stops[0]?.color : void 0;
|
|
22325
22961
|
return replaceSeriesPaint(
|
|
22326
22962
|
chart,
|
|
22327
|
-
|
|
22963
|
+
index3,
|
|
22328
22964
|
choice ?? current.drawingColor ?? chartDrawingColor(current.color) ?? chartPaletteSeriesColorChoice(
|
|
22329
22965
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
22330
|
-
|
|
22966
|
+
index3,
|
|
22331
22967
|
chart.series.length
|
|
22332
22968
|
)
|
|
22333
22969
|
);
|
|
22334
22970
|
}
|
|
22335
|
-
function replaceSeriesPaint(chart,
|
|
22336
|
-
const current = chartSeriesAt(chart,
|
|
22971
|
+
function replaceSeriesPaint(chart, index3, choice) {
|
|
22972
|
+
const current = chartSeriesAt(chart, index3);
|
|
22337
22973
|
if (!Object.keys(current.pointColors ?? {}).length && !Object.keys(current.pointFills ?? {}).length && (!choice ? current.fill?.kind === "none" : !current.fill && sameChartColor(current.drawingColor, choice)))
|
|
22338
22974
|
return void 0;
|
|
22339
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
22975
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
22340
22976
|
delete next.fill;
|
|
22341
22977
|
delete next.color;
|
|
22342
22978
|
delete next.drawingColor;
|
|
@@ -22480,18 +23116,18 @@ var PackageWriter = class {
|
|
|
22480
23116
|
var rank2 = (name) => name === "_rels/.rels" ? 0 : name.startsWith("docProps/") ? 1 : name === "xl/workbook.xml" ? 2 : 3;
|
|
22481
23117
|
|
|
22482
23118
|
// xlsx/write/chart-colors.ts
|
|
22483
|
-
function chartSeriesFill(chart, series,
|
|
23119
|
+
function chartSeriesFill(chart, series, index3) {
|
|
22484
23120
|
const imported = series.fill && drawingFillXml(series.fill);
|
|
22485
23121
|
if (imported) return imported;
|
|
22486
|
-
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series,
|
|
23122
|
+
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series, index3))}</a:solidFill>`;
|
|
22487
23123
|
}
|
|
22488
|
-
function chartSeriesDrawingFill(chart, series,
|
|
23124
|
+
function chartSeriesDrawingFill(chart, series, index3) {
|
|
22489
23125
|
if (series.fill && drawingFillXml(series.fill)) return series.fill;
|
|
22490
|
-
return { kind: "solid", color: chartSeriesColor(chart, series,
|
|
23126
|
+
return { kind: "solid", color: chartSeriesColor(chart, series, index3) };
|
|
22491
23127
|
}
|
|
22492
|
-
function chartSeriesColor(chart, series,
|
|
23128
|
+
function chartSeriesColor(chart, series, index3) {
|
|
22493
23129
|
const palette = findChartColorPalette(chart.colorPalette ?? 10);
|
|
22494
|
-
return series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(palette ?? findChartColorPalette(10),
|
|
23130
|
+
return series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(palette ?? findChartColorPalette(10), index3, chart.series.length);
|
|
22495
23131
|
}
|
|
22496
23132
|
function recolorMarker(marker3, previous, next) {
|
|
22497
23133
|
for (const paint of [marker3, first(marker3, "ln", NS.a)]) {
|
|
@@ -22509,10 +23145,10 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
22509
23145
|
const palette = findChartColorPalette(model.colorPalette ?? 10);
|
|
22510
23146
|
const lineLike = ["line", "scatter", "radar"].includes(model.chartType);
|
|
22511
23147
|
const markerOnly = model.chartType === "scatter" && first(plot2, "scatterStyle", NS.c)?.getAttribute("val") === "marker";
|
|
22512
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
22513
|
-
const series = model.series[
|
|
23148
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
23149
|
+
const series = model.series[index3];
|
|
22514
23150
|
if (!series) return;
|
|
22515
|
-
const old = before.series[
|
|
23151
|
+
const old = before.series[index3];
|
|
22516
23152
|
if (old?.effectsXml !== series.effectsXml) {
|
|
22517
23153
|
let shape2 = first(ser, "spPr", NS.c);
|
|
22518
23154
|
if (!shape2 && series.effectsXml) {
|
|
@@ -22558,12 +23194,12 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
22558
23194
|
paint = doc.createElementNS(NS.a, "a:ln");
|
|
22559
23195
|
spPr.appendChild(paint);
|
|
22560
23196
|
}
|
|
22561
|
-
setDrawingFillXml(paint, chartSeriesFill(model, series,
|
|
23197
|
+
setDrawingFillXml(paint, chartSeriesFill(model, series, index3));
|
|
22562
23198
|
}
|
|
22563
23199
|
if (previousPalette && palette && before.colorPalette !== model.colorPalette) {
|
|
22564
23200
|
const marker3 = first(first(ser, "marker", NS.c), "spPr", NS.c);
|
|
22565
|
-
const previous = chartPaletteSeriesColorChoice(previousPalette,
|
|
22566
|
-
const next = chartPaletteSeriesColorChoice(palette,
|
|
23201
|
+
const previous = chartPaletteSeriesColorChoice(previousPalette, index3, model.series.length);
|
|
23202
|
+
const next = chartPaletteSeriesColorChoice(palette, index3, model.series.length);
|
|
22567
23203
|
recolorMarker(marker3, previous, next);
|
|
22568
23204
|
for (const point of children(ser, "dPt", NS.c))
|
|
22569
23205
|
recolorMarker(first(first(point, "marker", NS.c), "spPr", NS.c), previous, next);
|
|
@@ -22658,7 +23294,7 @@ var FIRST_AXIS = 500000001;
|
|
|
22658
23294
|
var SECOND_AXIS = 500000002;
|
|
22659
23295
|
function source(kind, formula, values2) {
|
|
22660
23296
|
const points = values2.flatMap(
|
|
22661
|
-
(value2,
|
|
23297
|
+
(value2, index3) => value2 === null || value2 === "" ? [] : [{ index: index3, value: String(value2) }]
|
|
22662
23298
|
);
|
|
22663
23299
|
return {
|
|
22664
23300
|
kind: formula ? kind === "str" ? "strRef" : "numRef" : kind === "str" ? "strLit" : "numLit",
|
|
@@ -22691,9 +23327,9 @@ function dataPoints(series) {
|
|
|
22691
23327
|
return /^\d+$/.test(key) && paint ? [{ index: Number(key), spPr: { fill: paint } }] : [];
|
|
22692
23328
|
});
|
|
22693
23329
|
}
|
|
22694
|
-
function seriesModel(chart, series,
|
|
23330
|
+
function seriesModel(chart, series, index3) {
|
|
22695
23331
|
const type = chart.chartType;
|
|
22696
|
-
const out = { index:
|
|
23332
|
+
const out = { index: index3, order: index3, dataPoints: dataPoints(series) };
|
|
22697
23333
|
if (series.nameRef)
|
|
22698
23334
|
out.tx = {
|
|
22699
23335
|
reference: source("str", series.nameRef, series.name === void 0 ? [] : [series.name])
|
|
@@ -22702,7 +23338,7 @@ function seriesModel(chart, series, index2) {
|
|
|
22702
23338
|
const lineLike = type === "line" || type === "scatter" || type === "radar";
|
|
22703
23339
|
const effectsXml = effects(series);
|
|
22704
23340
|
if (type !== "pie" && type !== "doughnut" || series.fill || series.color || series.drawingColor || effectsXml) {
|
|
22705
|
-
const fill = chartSeriesDrawingFill(chart, series,
|
|
23341
|
+
const fill = chartSeriesDrawingFill(chart, series, index3);
|
|
22706
23342
|
const shape2 = lineLike ? { line: { widthEmu: 28575, cap: "rnd", fill } } : { fill };
|
|
22707
23343
|
if (effectsXml) shape2.effectsXml = effectsXml;
|
|
22708
23344
|
out.spPr = shape2;
|
|
@@ -22826,7 +23462,7 @@ function style(chart) {
|
|
|
22826
23462
|
return id > 100 ? { c14Style: id, style: id - 100 } : { style: id };
|
|
22827
23463
|
}
|
|
22828
23464
|
function chartSpaceFromObject(chart) {
|
|
22829
|
-
const series = chart.series.map((entry3,
|
|
23465
|
+
const series = chart.series.map((entry3, index3) => seriesModel(chart, entry3, index3));
|
|
22830
23466
|
const [group, chartAxes] = plot(chart, series);
|
|
22831
23467
|
const space = {
|
|
22832
23468
|
roundedCorners: false,
|
|
@@ -22867,8 +23503,8 @@ function patchChartReferences(xml, chart) {
|
|
|
22867
23503
|
changed = true;
|
|
22868
23504
|
}
|
|
22869
23505
|
};
|
|
22870
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
22871
|
-
const model = chart.series[
|
|
23506
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
23507
|
+
const model = chart.series[index3];
|
|
22872
23508
|
if (!model) return;
|
|
22873
23509
|
setRef(first(ser, "tx", NS.c), model.nameRef);
|
|
22874
23510
|
setRef(first(ser, "cat", NS.c) ?? first(ser, "xVal", NS.c), model.categoriesRef);
|
|
@@ -23175,14 +23811,14 @@ function shiftSpan(start, end, shift2) {
|
|
|
23175
23811
|
const e = end >= max ? max : end < at ? end : end > last ? end - n2 : at - 1;
|
|
23176
23812
|
return s > e ? void 0 : { start: s, end: e };
|
|
23177
23813
|
}
|
|
23178
|
-
function shiftIndex(
|
|
23814
|
+
function shiftIndex(index3, shift2) {
|
|
23179
23815
|
const { at, count: count2 } = shift2;
|
|
23180
|
-
if (
|
|
23181
|
-
if (count2 > 0) return
|
|
23182
|
-
return
|
|
23816
|
+
if (index3 < at) return index3;
|
|
23817
|
+
if (count2 > 0) return index3 + count2 > axisMax(shift2.axis) ? void 0 : index3 + count2;
|
|
23818
|
+
return index3 < at - count2 ? void 0 : index3 + count2;
|
|
23183
23819
|
}
|
|
23184
|
-
function shiftIndexClamped(
|
|
23185
|
-
const moved = shiftIndex(
|
|
23820
|
+
function shiftIndexClamped(index3, shift2) {
|
|
23821
|
+
const moved = shiftIndex(index3, shift2);
|
|
23186
23822
|
if (moved !== void 0) return moved;
|
|
23187
23823
|
return shift2.count > 0 ? axisMax(shift2.axis) : shift2.at;
|
|
23188
23824
|
}
|
|
@@ -23673,9 +24309,9 @@ function readSourceStyles(xml) {
|
|
|
23673
24309
|
(node) => inlineFragment(outerXml(node))
|
|
23674
24310
|
);
|
|
23675
24311
|
const dxfKeys = /* @__PURE__ */ new Map();
|
|
23676
|
-
parseStyles(xml, []).dxfs.forEach((dxf,
|
|
24312
|
+
parseStyles(xml, []).dxfs.forEach((dxf, index3) => {
|
|
23677
24313
|
const key = styleKey(dxf);
|
|
23678
|
-
if (!dxfKeys.has(key)) dxfKeys.set(key,
|
|
24314
|
+
if (!dxfKeys.has(key)) dxfKeys.set(key, index3);
|
|
23679
24315
|
});
|
|
23680
24316
|
const result2 = { numFmts, dxfXml, dxfKeys };
|
|
23681
24317
|
const tableStyles = xFirst(root, "tableStyles");
|
|
@@ -23783,7 +24419,7 @@ var StyleWriter = class {
|
|
|
23783
24419
|
});
|
|
23784
24420
|
const seen = /* @__PURE__ */ new Set();
|
|
23785
24421
|
const unique2 = named2.filter((entry3) => !seen.has(entry3.name) && seen.add(entry3.name));
|
|
23786
|
-
const xfIdOf = new Map(unique2.map((entry3,
|
|
24422
|
+
const xfIdOf = new Map(unique2.map((entry3, index3) => [entry3.name, index3]));
|
|
23787
24423
|
const base = this.workbook.styles[0] ?? defaultCellStyle();
|
|
23788
24424
|
this.fonts.id(fontXml(base.font));
|
|
23789
24425
|
this.borders.id(borderXml({}));
|
|
@@ -23792,7 +24428,7 @@ var StyleWriter = class {
|
|
|
23792
24428
|
(style2) => this.xf(style2, xfIdOf.get(style2.cellStyleName ?? "Normal") ?? 0)
|
|
23793
24429
|
);
|
|
23794
24430
|
const cellStyles = unique2.map(
|
|
23795
|
-
(entry3,
|
|
24431
|
+
(entry3, index3) => el("cellStyle", { name: entry3.name, xfId: index3, builtinId: entry3.builtinId })
|
|
23796
24432
|
);
|
|
23797
24433
|
const custom = [...this.numFmts].filter(([code]) => builtinFormatIdOf(code) === void 0).sort((a2, b) => a2[1] - b[1]);
|
|
23798
24434
|
let out = `${XML_HEADER}<styleSheet xmlns="${NS.x}" xmlns:mc="${NS.mc}" mc:Ignorable="x14ac" xmlns:x14ac="${NS.x14ac}">`;
|
|
@@ -23957,13 +24593,13 @@ function definedNamesOf(workbook) {
|
|
|
23957
24593
|
const names = workbook.definedNames.filter(
|
|
23958
24594
|
(name) => name.name && (name.localSheet === void 0 || name.localSheet >= 0 && name.localSheet < workbook.sheets.length)
|
|
23959
24595
|
);
|
|
23960
|
-
workbook.sheets.forEach((sheet,
|
|
24596
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
23961
24597
|
const area = sheet.pageSetup?.printArea;
|
|
23962
|
-
if (!area || names.some((n2) => n2.name === "_xlnm.Print_Area" && n2.localSheet ===
|
|
24598
|
+
if (!area || names.some((n2) => n2.name === "_xlnm.Print_Area" && n2.localSheet === index3)) return;
|
|
23963
24599
|
names.push({
|
|
23964
24600
|
name: "_xlnm.Print_Area",
|
|
23965
24601
|
formula: `${quoteSheetName(sheet.name)}!${absoluteRange(area)}`,
|
|
23966
|
-
localSheet:
|
|
24602
|
+
localSheet: index3
|
|
23967
24603
|
});
|
|
23968
24604
|
});
|
|
23969
24605
|
return names;
|
|
@@ -24408,8 +25044,8 @@ function extent(values2) {
|
|
|
24408
25044
|
function sparklineValues(group, values2) {
|
|
24409
25045
|
return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
|
|
24410
25046
|
}
|
|
24411
|
-
function sparklineScale(group, all2,
|
|
24412
|
-
const own = extent(sparklineValues(group, all2[
|
|
25047
|
+
function sparklineScale(group, all2, index3) {
|
|
25048
|
+
const own = extent(sparklineValues(group, all2[index3]?.values ?? []));
|
|
24413
25049
|
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
24414
25050
|
const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
|
|
24415
25051
|
const end = (type, manual, key) => {
|
|
@@ -24527,17 +25163,17 @@ var MAX_POINTS = 1e4;
|
|
|
24527
25163
|
var hostIndex = /* @__PURE__ */ new WeakMap();
|
|
24528
25164
|
function hosts(sheet) {
|
|
24529
25165
|
const groups = sheetSparklineGroups(sheet);
|
|
24530
|
-
let
|
|
24531
|
-
if (!
|
|
24532
|
-
|
|
25166
|
+
let index3 = hostIndex.get(groups);
|
|
25167
|
+
if (!index3) {
|
|
25168
|
+
index3 = /* @__PURE__ */ new Map();
|
|
24533
25169
|
for (const group of groups)
|
|
24534
25170
|
group.sparklines.forEach((line3, i2) => {
|
|
24535
25171
|
const key = cellKey(line3.host.start.row, line3.host.start.col);
|
|
24536
|
-
if (!
|
|
25172
|
+
if (!index3.has(key)) index3.set(key, { group, index: i2 });
|
|
24537
25173
|
});
|
|
24538
|
-
hostIndex.set(groups,
|
|
25174
|
+
hostIndex.set(groups, index3);
|
|
24539
25175
|
}
|
|
24540
|
-
return
|
|
25176
|
+
return index3;
|
|
24541
25177
|
}
|
|
24542
25178
|
function hasSparklineAt(sheet, row2, col) {
|
|
24543
25179
|
return hosts(sheet).has(cellKey(row2, col));
|
|
@@ -24603,10 +25239,10 @@ function sparklineViewAt(workbook, sheetIndex2, row2, col) {
|
|
|
24603
25239
|
if (!sheet) return void 0;
|
|
24604
25240
|
const entry3 = hosts(sheet).get(cellKey(row2, col));
|
|
24605
25241
|
if (!entry3) return void 0;
|
|
24606
|
-
const { group, index:
|
|
25242
|
+
const { group, index: index3 } = entry3;
|
|
24607
25243
|
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
24608
|
-
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[
|
|
24609
|
-
const at = needsGroup ?
|
|
25244
|
+
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[index3]] });
|
|
25245
|
+
const at = needsGroup ? index3 : 0;
|
|
24610
25246
|
return sparklineView(
|
|
24611
25247
|
group,
|
|
24612
25248
|
data[at] ?? { values: [] },
|
|
@@ -24771,9 +25407,9 @@ function sourceColumnsForPatch(root, table2, names) {
|
|
|
24771
25407
|
const byName = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
24772
25408
|
const tracked = table2.partName !== void 0 || table2.columns.some((c2) => c2.sourceId !== void 0);
|
|
24773
25409
|
const used = /* @__PURE__ */ new Set();
|
|
24774
|
-
return names.map((name,
|
|
24775
|
-
const id = table2.columns[
|
|
24776
|
-
const match2 = id !== void 0 ? byId2.get(id) : tracked ? void 0 : source2.length === names.length ? source2[
|
|
25410
|
+
return names.map((name, index3) => {
|
|
25411
|
+
const id = table2.columns[index3]?.sourceId;
|
|
25412
|
+
const match2 = id !== void 0 ? byId2.get(id) : tracked ? void 0 : source2.length === names.length ? source2[index3] : byName.get(name.toLowerCase());
|
|
24777
25413
|
if (!match2 || used.has(match2)) return void 0;
|
|
24778
25414
|
used.add(match2);
|
|
24779
25415
|
return match2;
|
|
@@ -24790,12 +25426,12 @@ function patchAutoFilter(doc, root, table2, before, names) {
|
|
|
24790
25426
|
filter2.setAttribute("ref", formatRange(range));
|
|
24791
25427
|
const list = xKid(root, "tableColumns");
|
|
24792
25428
|
const original = list ? xKids(list, "tableColumn") : [];
|
|
24793
|
-
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2,
|
|
25429
|
+
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2, index3) => [c2, index3]));
|
|
24794
25430
|
for (const column of xKids(filter2, "filterColumn")) {
|
|
24795
25431
|
const old = original[Number(column.getAttribute("colId") ?? "0")];
|
|
24796
|
-
const
|
|
24797
|
-
if (
|
|
24798
|
-
else column.setAttribute("colId", num2(
|
|
25432
|
+
const index3 = old ? current.get(old) : void 0;
|
|
25433
|
+
if (index3 === void 0) filter2.removeChild(column);
|
|
25434
|
+
else column.setAttribute("colId", num2(index3));
|
|
24799
25435
|
}
|
|
24800
25436
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
24801
25437
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
@@ -24840,11 +25476,11 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
24840
25476
|
for (const column of sourceColumns) list.removeChild(column);
|
|
24841
25477
|
let nextId = Math.max(0, ...ids) + 1;
|
|
24842
25478
|
const totalsRow = table2.range.end.row;
|
|
24843
|
-
names.forEach((name,
|
|
24844
|
-
const column = picked[
|
|
25479
|
+
names.forEach((name, index3) => {
|
|
25480
|
+
const column = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
24845
25481
|
if (!column.getAttribute("id")) column.setAttribute("id", num2(nextId++));
|
|
24846
25482
|
column.setAttribute("name", name);
|
|
24847
|
-
const model = table2.columns[
|
|
25483
|
+
const model = table2.columns[index3];
|
|
24848
25484
|
const fn = table2.totalsRow ? model?.totalsRowFunction : void 0;
|
|
24849
25485
|
setOrRemove(column, "totalsRowFunction", fn);
|
|
24850
25486
|
setOrRemove(column, "totalsRowLabel", table2.totalsRow ? model?.totalsRowLabel : void 0);
|
|
@@ -24858,7 +25494,7 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
24858
25494
|
);
|
|
24859
25495
|
if (fn !== "custom") setChildText(doc, column, "totalsRowFormula", void 0, []);
|
|
24860
25496
|
else {
|
|
24861
|
-
const cellFormula = sheet.rows.get(totalsRow)?.get(table2.range.start.col +
|
|
25497
|
+
const cellFormula = sheet.rows.get(totalsRow)?.get(table2.range.start.col + index3)?.formula;
|
|
24862
25498
|
if (cellFormula)
|
|
24863
25499
|
setChildText(
|
|
24864
25500
|
doc,
|
|
@@ -24939,11 +25575,11 @@ function tableXml(table2, id, names) {
|
|
|
24939
25575
|
const range = formatRange(table2.range);
|
|
24940
25576
|
const filterEnd = { ...table2.range.end, row: table2.range.end.row - (table2.totalsRow ? 1 : 0) };
|
|
24941
25577
|
const filter2 = table2.headerRow && !table2.totalsRow ? `<autoFilter ref="${range}"/>` : table2.headerRow ? `<autoFilter ref="${formatRange({ start: table2.range.start, end: filterEnd })}"/>` : "";
|
|
24942
|
-
const columns = names.map((name,
|
|
24943
|
-
const column = table2.columns[
|
|
25578
|
+
const columns = names.map((name, index3) => {
|
|
25579
|
+
const column = table2.columns[index3];
|
|
24944
25580
|
const calculated = column?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText2(addFuturePrefixes(column.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
24945
25581
|
const values2 = attrs({
|
|
24946
|
-
id:
|
|
25582
|
+
id: index3 + 1,
|
|
24947
25583
|
name,
|
|
24948
25584
|
totalsRowFunction: table2.totalsRow ? column?.totalsRowFunction : void 0,
|
|
24949
25585
|
totalsRowLabel: table2.totalsRow ? column?.totalsRowLabel : void 0
|
|
@@ -24982,27 +25618,27 @@ function totalsRowFormulas(sheet, table2, names) {
|
|
|
24982
25618
|
const out = /* @__PURE__ */ new Map();
|
|
24983
25619
|
if (!table2.totalsRow) return out;
|
|
24984
25620
|
const row2 = table2.range.end.row;
|
|
24985
|
-
names.forEach((name,
|
|
24986
|
-
const code = SUBTOTAL_CODES[table2.columns[
|
|
25621
|
+
names.forEach((name, index3) => {
|
|
25622
|
+
const code = SUBTOTAL_CODES[table2.columns[index3]?.totalsRowFunction ?? ""];
|
|
24987
25623
|
if (code === void 0) return;
|
|
24988
|
-
const col = table2.range.start.col +
|
|
25624
|
+
const col = table2.range.start.col + index3;
|
|
24989
25625
|
const escaped = name.replace(/['#[\]]/g, "'$&");
|
|
24990
25626
|
const formula = `SUBTOTAL(${code},${table2.displayName || table2.name}[${escaped}])`;
|
|
24991
25627
|
if (sheet.rows.get(row2)?.get(col)?.formula !== formula) out.set(`${row2}:${col}`, formula);
|
|
24992
25628
|
});
|
|
24993
25629
|
return out;
|
|
24994
25630
|
}
|
|
24995
|
-
function resolveTableNames(table2, before,
|
|
25631
|
+
function resolveTableNames(table2, before, index3) {
|
|
24996
25632
|
const display = table2.displayName || table2.name;
|
|
24997
|
-
const displayName = before && before.displayName === display ? display : safeTableName(display,
|
|
24998
|
-
const name = before && before.name === table2.name ? table2.name : table2.name === display ? displayName : safeTableName(table2.name,
|
|
25633
|
+
const displayName = before && before.displayName === display ? display : safeTableName(display, index3);
|
|
25634
|
+
const name = before && before.name === table2.name ? table2.name : table2.name === display ? displayName : safeTableName(table2.name, index3);
|
|
24999
25635
|
return { name, displayName };
|
|
25000
25636
|
}
|
|
25001
|
-
function safeTableName(name,
|
|
25637
|
+
function safeTableName(name, index3) {
|
|
25002
25638
|
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;
|
|
25003
25639
|
if (valid) return name;
|
|
25004
25640
|
const cleaned = name.replace(/[^A-Za-z0-9_.]/g, "_");
|
|
25005
|
-
return `Table_${cleaned ||
|
|
25641
|
+
return `Table_${cleaned || index3}`;
|
|
25006
25642
|
}
|
|
25007
25643
|
|
|
25008
25644
|
// xlsx/write/sheet-parts.ts
|
|
@@ -25015,7 +25651,7 @@ function sourceRelIds(source2, partName) {
|
|
|
25015
25651
|
if (legacy) out.legacy = legacy;
|
|
25016
25652
|
return out;
|
|
25017
25653
|
}
|
|
25018
|
-
function writeComments(ctx, sheet,
|
|
25654
|
+
function writeComments(ctx, sheet, index3, partName, rels) {
|
|
25019
25655
|
const { writer, source: source2 } = ctx;
|
|
25020
25656
|
const name = (pattern) => writer.uniqueName(pattern, ctx.reserved);
|
|
25021
25657
|
const fromSource = source2 && sheet.partName && source2.has(sheet.partName);
|
|
@@ -25060,8 +25696,8 @@ function writeComments(ctx, sheet, index2, partName, rels) {
|
|
|
25060
25696
|
}
|
|
25061
25697
|
}
|
|
25062
25698
|
const own = base ? vmlIdmapBlocks(base) : [];
|
|
25063
|
-
const layout2 = vmlAllocatorFor(ctx, source2).allocate(sheet.comments.length,
|
|
25064
|
-
const parts = commentParts(sheet.comments,
|
|
25699
|
+
const layout2 = vmlAllocatorFor(ctx, source2).allocate(sheet.comments.length, index3 + 1, own);
|
|
25700
|
+
const parts = commentParts(sheet.comments, index3 + 1, ctx.persons, sheet.name, {
|
|
25065
25701
|
...layout2,
|
|
25066
25702
|
...base ? { base } : {}
|
|
25067
25703
|
});
|
|
@@ -25083,11 +25719,11 @@ function sourceVmlPart(source2, sheetPart) {
|
|
|
25083
25719
|
}
|
|
25084
25720
|
function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
25085
25721
|
const ids = [];
|
|
25086
|
-
for (const [
|
|
25722
|
+
for (const [index3, original] of sheet.tables.entries()) {
|
|
25087
25723
|
const { writer, source: source2 } = ctx;
|
|
25088
25724
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
25089
25725
|
const before = sourceXml && original.partName ? parseTable(sourceXml, original.partName) : void 0;
|
|
25090
|
-
const { name, displayName } = resolveTableNames(original, before,
|
|
25726
|
+
const { name, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
25091
25727
|
const table2 = name === original.name && displayName === original.displayName ? original : { ...original, name, displayName };
|
|
25092
25728
|
const { names, headerText: forced } = resolveTableColumns(sheet, table2);
|
|
25093
25729
|
for (const [key, text3] of forced) headerText.set(key, text3);
|
|
@@ -25369,7 +26005,7 @@ var REGENERATED = /* @__PURE__ */ new Set([
|
|
|
25369
26005
|
]);
|
|
25370
26006
|
var NS_XR2 = "http://schemas.microsoft.com/office/spreadsheetml/2015/revision2";
|
|
25371
26007
|
var NS_XR3 = "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3";
|
|
25372
|
-
function writeWorksheet(ctx, sheet,
|
|
26008
|
+
function writeWorksheet(ctx, sheet, index3, partName) {
|
|
25373
26009
|
const { writer, source: source2 } = ctx;
|
|
25374
26010
|
const rels = new RelationshipSet();
|
|
25375
26011
|
let sourceDrawing;
|
|
@@ -25392,7 +26028,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
25392
26028
|
const tableParts = writeTables(ctx, sheet, partName, rels, headerText, formulas);
|
|
25393
26029
|
blocks.set("sheetPr", sheetPrXml(sheet));
|
|
25394
26030
|
blocks.set("dimension", dimensionXml(sheet));
|
|
25395
|
-
blocks.set("sheetViews", sheetViewsXml(sheet,
|
|
26031
|
+
blocks.set("sheetViews", sheetViewsXml(sheet, index3 === ctx.workbook.activeSheet));
|
|
25396
26032
|
blocks.set("sheetFormatPr", sheetFormatXml(sheet));
|
|
25397
26033
|
blocks.set("cols", colsXml(sheet, ctx.workbook.styles.length));
|
|
25398
26034
|
blocks.set(
|
|
@@ -25431,7 +26067,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
25431
26067
|
);
|
|
25432
26068
|
blocks.set("headerFooter", page.headerFooter);
|
|
25433
26069
|
blocks.set("drawing", writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing));
|
|
25434
|
-
blocks.set("legacyDrawing", writeComments(ctx, sheet,
|
|
26070
|
+
blocks.set("legacyDrawing", writeComments(ctx, sheet, index3, partName, rels));
|
|
25435
26071
|
blocks.set("tableParts", tableParts);
|
|
25436
26072
|
ctx.pivots?.writeSheet(writer, sheet, partName, rels);
|
|
25437
26073
|
blocks.set("extLst", conditionalExtensionsXml(sheet));
|
|
@@ -25456,12 +26092,12 @@ function pivotCacheData(pivot) {
|
|
|
25456
26092
|
const items = pivot.fields.map(() => []);
|
|
25457
26093
|
const indices = pivot.fields.map(() => /* @__PURE__ */ new Map());
|
|
25458
26094
|
for (const record of pivot.records)
|
|
25459
|
-
pivot.fields.forEach((_field,
|
|
25460
|
-
const value2 = record[
|
|
26095
|
+
pivot.fields.forEach((_field, index3) => {
|
|
26096
|
+
const value2 = record[index3] ?? null;
|
|
25461
26097
|
const key = pivotValueKey(value2);
|
|
25462
|
-
if (!indices[
|
|
25463
|
-
indices[
|
|
25464
|
-
items[
|
|
26098
|
+
if (!indices[index3].has(key)) {
|
|
26099
|
+
indices[index3].set(key, items[index3].length);
|
|
26100
|
+
items[index3].push(value2);
|
|
25465
26101
|
}
|
|
25466
26102
|
});
|
|
25467
26103
|
return { items, indices };
|
|
@@ -25476,8 +26112,8 @@ function valueXml(value2) {
|
|
|
25476
26112
|
}
|
|
25477
26113
|
function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
25478
26114
|
const source2 = sparklineDataRange(workbook, 0, pivot.source);
|
|
25479
|
-
const fields = pivot.fields.map((name,
|
|
25480
|
-
const items = data.items[
|
|
26115
|
+
const fields = pivot.fields.map((name, index3) => {
|
|
26116
|
+
const items = data.items[index3];
|
|
25481
26117
|
const types = new Set(
|
|
25482
26118
|
items.map((value2) => value2 === null || value2 === "" ? "blank" : typeof value2)
|
|
25483
26119
|
);
|
|
@@ -25489,7 +26125,7 @@ function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
|
25489
26125
|
}
|
|
25490
26126
|
function pivotCacheRecordsXml(pivot, data) {
|
|
25491
26127
|
const records = pivot.records.map(
|
|
25492
|
-
(record) => `<r>${pivot.fields.map((_field,
|
|
26128
|
+
(record) => `<r>${pivot.fields.map((_field, index3) => `<x v="${data.indices[index3].get(pivotValueKey(record[index3] ?? null))}"/>`).join("")}</r>`
|
|
25493
26129
|
).join("");
|
|
25494
26130
|
return `${XML_HEADER}<pivotCacheRecords xmlns="${NS.x}" count="${pivot.records.length}">${records}</pivotCacheRecords>`;
|
|
25495
26131
|
}
|
|
@@ -25499,45 +26135,87 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25499
26135
|
const grid = pivotGrid(pivot);
|
|
25500
26136
|
const row2 = pivot.fields.indexOf(pivot.rowField);
|
|
25501
26137
|
const second = pivot.secondRowField ? pivot.fields.indexOf(pivot.secondRowField) : -1;
|
|
26138
|
+
const page = pivot.pageFilter ? pivot.fields.indexOf(pivot.pageFilter.field) : -1;
|
|
26139
|
+
const pageItems = page >= 0 ? pivotItems(pivot, pivot.pageFilter.field) : [];
|
|
26140
|
+
const axisItems = (field, visible) => page >= 0 ? pivotItems(pivot, field) : visible;
|
|
26141
|
+
const rowItemsFull = axisItems(pivot.rowField, grid.rowItems);
|
|
26142
|
+
const secondRowItemsFull = pivot.secondRowField ? axisItems(pivot.secondRowField, grid.secondRowItems) : [];
|
|
26143
|
+
const columnItemsFull = pivot.columnField ? axisItems(pivot.columnField, grid.columnItems) : [];
|
|
26144
|
+
const itemIndices = (visible, full) => {
|
|
26145
|
+
const indices = new Map(full.map((item, index3) => [pivotValueKey(item), index3]));
|
|
26146
|
+
return visible.map((v) => indices.get(pivotValueKey(v)));
|
|
26147
|
+
};
|
|
26148
|
+
const rowIndicesFull = itemIndices(grid.rowItems, rowItemsFull), secondRowIndicesFull = itemIndices(grid.secondRowItems ?? [], secondRowItemsFull), columnIndicesFull = itemIndices(grid.columnItems, columnItemsFull);
|
|
26149
|
+
const rowEntries = page >= 0 && grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, [rowIndicesFull, secondRowIndicesFull]) : grid.rowEntries;
|
|
26150
|
+
const pageOffset = page >= 0 ? 2 : 0;
|
|
25502
26151
|
const col = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
25503
|
-
const
|
|
26152
|
+
const measures = pivotMeasures(pivot);
|
|
26153
|
+
const multiple = measures.length > 1;
|
|
26154
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
25504
26155
|
const compact3 = pivot.layout === "compact";
|
|
25505
26156
|
const outline = pivot.layout === "compact" || pivot.layout === "outline";
|
|
25506
26157
|
const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
|
|
25507
|
-
const fields = pivot.fields.map((_field,
|
|
25508
|
-
const items2 =
|
|
25509
|
-
const subtotal = !(
|
|
25510
|
-
const repeated = pivot.repeatLabels && (
|
|
25511
|
-
return `<pivotField${attrs({ axis:
|
|
26158
|
+
const fields = pivot.fields.map((_field, index3) => {
|
|
26159
|
+
const items2 = index3 === page ? pageItems : index3 === row2 ? rowItemsFull : index3 === second ? secondRowItemsFull : index3 === col ? columnItemsFull : void 0;
|
|
26160
|
+
const subtotal = !(index3 === row2 && pivot.subtotals === false);
|
|
26161
|
+
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>' : "";
|
|
26162
|
+
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>`;
|
|
25512
26163
|
}).join("");
|
|
25513
|
-
const items = (count2) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
25514
|
-
const header = grid.firstDataRow - 1;
|
|
25515
|
-
const rowIndices = [row2, ...second >= 0 ? [second] : []];
|
|
26164
|
+
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
26165
|
+
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : multiple && col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
26166
|
+
const rowIndices = rowsAxis && pivot.valuesPosition === "first" ? [-2, row2, second] : rowsAxis && pivot.valuesPosition === "between" ? [row2, -2, second] : [row2, ...second >= 0 ? [second] : [], ...rowsAxis ? [-2] : []];
|
|
25516
26167
|
let previous = [];
|
|
25517
|
-
const rowItems =
|
|
26168
|
+
const rowItems = rowEntries?.map((entry3) => {
|
|
25518
26169
|
let prefix = 0;
|
|
25519
|
-
if (
|
|
26170
|
+
if (entry3.type === "default" && rowsAxis && pivot.valuesPosition === "first") prefix = 1;
|
|
26171
|
+
else if (!entry3.type)
|
|
25520
26172
|
while (prefix < entry3.indices.length - 1 && entry3.indices[prefix] === previous[prefix])
|
|
25521
26173
|
prefix++;
|
|
25522
|
-
previous = entry3.type ? [] : entry3.indices;
|
|
25523
|
-
return `<i${attrs({ t: entry3.type, r: prefix || void 0 })}>${entry3.indices.slice(prefix).map((
|
|
25524
|
-
}).join("") ?? items(grid.rowItems.length);
|
|
25525
|
-
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((
|
|
25526
|
-
if (
|
|
25527
|
-
body += `<colFields count="1"
|
|
25528
|
-
else
|
|
25529
|
-
|
|
26174
|
+
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
26175
|
+
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>`;
|
|
26176
|
+
}).join("") ?? items(grid.rowItems.length, rowIndicesFull);
|
|
26177
|
+
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>`;
|
|
26178
|
+
if (multiple && !rowsAxis)
|
|
26179
|
+
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)}`;
|
|
26180
|
+
else if (col >= 0)
|
|
26181
|
+
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length, columnIndicesFull)}</colItems>`;
|
|
26182
|
+
else
|
|
26183
|
+
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : page >= 0 ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
26184
|
+
if (page >= 0)
|
|
26185
|
+
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>`;
|
|
26186
|
+
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>`;
|
|
25530
26187
|
const doc = parseXml(
|
|
25531
26188
|
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>`
|
|
25532
26189
|
);
|
|
25533
26190
|
const root = doc.documentElement;
|
|
25534
26191
|
root.setAttribute("name", pivot.name);
|
|
25535
26192
|
root.setAttribute("cacheId", String(cacheId));
|
|
26193
|
+
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
26194
|
+
if (rowsAxis && (pivot.valuesPosition === "between" || pivot.valuesPosition === "first"))
|
|
26195
|
+
root.setAttribute("dataPosition", pivot.valuesPosition === "first" ? "0" : "1");
|
|
26196
|
+
else root.removeAttribute("dataPosition");
|
|
25536
26197
|
root.setAttribute("compact", compact3 ? "1" : "0");
|
|
25537
26198
|
root.setAttribute("compactData", compact3 ? "1" : "0");
|
|
25538
26199
|
root.setAttribute("outline", outline ? "1" : "0");
|
|
25539
26200
|
root.setAttribute("outlineData", outline ? "1" : "0");
|
|
25540
26201
|
if (compact3) root.setAttribute("indent", "0");
|
|
26202
|
+
if (multiple && !elements(first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement).some(
|
|
26203
|
+
(extension) => first(
|
|
26204
|
+
extension,
|
|
26205
|
+
"pivotTableDefinition",
|
|
26206
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
26207
|
+
)
|
|
26208
|
+
)) {
|
|
26209
|
+
let list = first(root, "extLst", NS.x);
|
|
26210
|
+
if (!list) {
|
|
26211
|
+
list = doc.createElementNS(NS.x, "extLst");
|
|
26212
|
+
root.appendChild(list);
|
|
26213
|
+
}
|
|
26214
|
+
const extension = parseXml(
|
|
26215
|
+
`<ext xmlns="${NS.x}" uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}"><x14:pivotTableDefinition xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" hideValuesRow="1"/></ext>`
|
|
26216
|
+
).documentElement;
|
|
26217
|
+
list.appendChild(doc.importNode(extension, true));
|
|
26218
|
+
}
|
|
25541
26219
|
root.setAttribute("rowGrandTotals", "1");
|
|
25542
26220
|
root.setAttribute("colGrandTotals", "1");
|
|
25543
26221
|
for (const extension of elements(
|
|
@@ -25548,6 +26226,7 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25548
26226
|
"pivotTableDefinition",
|
|
25549
26227
|
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
25550
26228
|
);
|
|
26229
|
+
if (multiple && definition) definition.setAttribute("hideValuesRow", "1");
|
|
25551
26230
|
if (definition?.hasAttribute("fillDownLabelsDefault"))
|
|
25552
26231
|
definition.setAttribute("fillDownLabelsDefault", pivot.repeatLabels ? "1" : "0");
|
|
25553
26232
|
}
|
|
@@ -25558,7 +26237,8 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25558
26237
|
"rowItems",
|
|
25559
26238
|
"colFields",
|
|
25560
26239
|
"colItems",
|
|
25561
|
-
"dataFields"
|
|
26240
|
+
"dataFields",
|
|
26241
|
+
"pageFields"
|
|
25562
26242
|
]);
|
|
25563
26243
|
for (const child3 of elements(root)) if (replaced.has(child3.localName)) root.removeChild(child3);
|
|
25564
26244
|
const replacement = parseXml(`<root xmlns="${NS.x}">${body}</root>`).documentElement;
|
|
@@ -25743,8 +26423,8 @@ async function saveXlsx(workbook) {
|
|
|
25743
26423
|
return void 0;
|
|
25744
26424
|
});
|
|
25745
26425
|
const sheetRefs = [];
|
|
25746
|
-
workbook.sheets.forEach((sheet,
|
|
25747
|
-
let partName = partNames[
|
|
26426
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
26427
|
+
let partName = partNames[index3];
|
|
25748
26428
|
const sourceType = partName && source2?.has(partName) ? source2.contentType(partName) : void 0;
|
|
25749
26429
|
const special = sourceType ? SHEET_TYPES[sourceType] : void 0;
|
|
25750
26430
|
if (!partName) {
|
|
@@ -25755,11 +26435,11 @@ async function saveXlsx(workbook) {
|
|
|
25755
26435
|
claimed.add(partName);
|
|
25756
26436
|
}
|
|
25757
26437
|
if (special) writer.carry(partName);
|
|
25758
|
-
else writeWorksheet(ctx, sheet,
|
|
26438
|
+
else writeWorksheet(ctx, sheet, index3, partName);
|
|
25759
26439
|
sheetRefs.push({
|
|
25760
26440
|
name: sheet.name,
|
|
25761
26441
|
sheetId: sheet.sheetId,
|
|
25762
|
-
state: states[
|
|
26442
|
+
state: states[index3] ?? "visible",
|
|
25763
26443
|
relId: rels.add(special ?? RELATIONSHIP_TYPES.worksheet, relativeTarget(bookPart, partName))
|
|
25764
26444
|
});
|
|
25765
26445
|
});
|
|
@@ -25821,9 +26501,9 @@ async function saveXlsx(workbook) {
|
|
|
25821
26501
|
}
|
|
25822
26502
|
|
|
25823
26503
|
// xlsx/edit/context.ts
|
|
25824
|
-
function sheetAt(workbook,
|
|
25825
|
-
const sheet = Number.isInteger(
|
|
25826
|
-
if (!sheet) throw new RangeError(`No sheet at index ${
|
|
26504
|
+
function sheetAt(workbook, index3) {
|
|
26505
|
+
const sheet = Number.isInteger(index3) ? workbook.sheets[index3] : void 0;
|
|
26506
|
+
if (!sheet) throw new RangeError(`No sheet at index ${index3}`);
|
|
25827
26507
|
return sheet;
|
|
25828
26508
|
}
|
|
25829
26509
|
function baseStyleId(sheet, row2, col) {
|
|
@@ -26057,7 +26737,7 @@ function rewriteFormulas(workbook, rewrite2, formulaCells) {
|
|
|
26057
26737
|
else bySheet.set(cell.sheet, [cell]);
|
|
26058
26738
|
}
|
|
26059
26739
|
workbook.sheets.forEach(
|
|
26060
|
-
(sheet,
|
|
26740
|
+
(sheet, index3) => rewriteSheetFormulas(sheet, rewrite2, bySheet ? bySheet.get(index3) ?? [] : void 0)
|
|
26061
26741
|
);
|
|
26062
26742
|
for (const definedName of workbook.definedNames) {
|
|
26063
26743
|
const local = definedName.localSheet === void 0 ? void 0 : workbook.sheets[definedName.localSheet];
|
|
@@ -26076,11 +26756,11 @@ function rewriteSheetFormulas(sheet, rewrite2, formulaCells) {
|
|
|
26076
26756
|
{
|
|
26077
26757
|
const name = sheet.name;
|
|
26078
26758
|
for (const table2 of sheet.tables)
|
|
26079
|
-
for (const [
|
|
26759
|
+
for (const [index3, column] of table2.columns.entries())
|
|
26080
26760
|
if (column.calculatedColumnFormula !== void 0)
|
|
26081
26761
|
column.calculatedColumnFormula = safe(rewrite2, column.calculatedColumnFormula, name, {
|
|
26082
26762
|
row: table2.range.start.row + (table2.headerRow ? 1 : 0),
|
|
26083
|
-
col: table2.range.start.col +
|
|
26763
|
+
col: table2.range.start.col + index3
|
|
26084
26764
|
});
|
|
26085
26765
|
if (formulaCells) {
|
|
26086
26766
|
for (const at of formulaCells) {
|
|
@@ -26156,8 +26836,8 @@ function syncTableHeader(ctx, sheet, row2, col, formulaCells) {
|
|
|
26156
26836
|
const newName = uniqueHeaders([...others, text3]).at(-1);
|
|
26157
26837
|
column.name = newName;
|
|
26158
26838
|
if (newName !== text3) writeValue(sheet, row2, col, newName);
|
|
26159
|
-
const
|
|
26160
|
-
const cells = formulaCells && (formulaCells.some((cell) => cell.sheet ===
|
|
26839
|
+
const index3 = ctx.workbook.sheets.indexOf(sheet);
|
|
26840
|
+
const cells = formulaCells && (formulaCells.some((cell) => cell.sheet === index3 && cell.row === row2 && cell.col === col) ? formulaCells : [...formulaCells, { sheet: index3, row: row2, col }]);
|
|
26161
26841
|
rewriteFormulas(
|
|
26162
26842
|
ctx.workbook,
|
|
26163
26843
|
(formula, formulaSheet, at) => renameTableColumnInFormula(
|
|
@@ -26170,7 +26850,7 @@ function syncTableHeader(ctx, sheet, row2, col, formulaCells) {
|
|
|
26170
26850
|
cells
|
|
26171
26851
|
);
|
|
26172
26852
|
}
|
|
26173
|
-
function writeScopes(sheet,
|
|
26853
|
+
function writeScopes(sheet, index3, range, parts = []) {
|
|
26174
26854
|
const r = normalizeRange(range);
|
|
26175
26855
|
const touchesHeader = sheet.tables.some(
|
|
26176
26856
|
(t) => t.headerRow && rangesIntersect(
|
|
@@ -26178,9 +26858,9 @@ function writeScopes(sheet, index2, range, parts = []) {
|
|
|
26178
26858
|
cellRange(t.range.start.row, t.range.start.col, t.range.start.row, t.range.end.col)
|
|
26179
26859
|
)
|
|
26180
26860
|
);
|
|
26181
|
-
if (touchesHeader) return [{ kind: "refs" }, { kind: "cells", sheet:
|
|
26182
|
-
const scopes = [{ kind: "cells", sheet:
|
|
26183
|
-
if (parts.length) scopes.push({ kind: "parts", sheet:
|
|
26861
|
+
if (touchesHeader) return [{ kind: "refs" }, { kind: "cells", sheet: index3, ranges: [r] }];
|
|
26862
|
+
const scopes = [{ kind: "cells", sheet: index3, ranges: [r] }];
|
|
26863
|
+
if (parts.length) scopes.push({ kind: "parts", sheet: index3, parts });
|
|
26184
26864
|
return scopes;
|
|
26185
26865
|
}
|
|
26186
26866
|
function writeInput(ctx, sheet, row2, col, text3) {
|
|
@@ -26478,10 +27158,10 @@ function patchRangeWith(sheet, range, patcher) {
|
|
|
26478
27158
|
pruneCell(sheet, row2, col);
|
|
26479
27159
|
});
|
|
26480
27160
|
}
|
|
26481
|
-
function formatScopes(
|
|
26482
|
-
const cells = { kind: "cells", sheet:
|
|
27161
|
+
function formatScopes(index3, ranges) {
|
|
27162
|
+
const cells = { kind: "cells", sheet: index3, ranges };
|
|
26483
27163
|
const whole = ranges.some((r) => isWholeColumns(r) || isWholeRows(r));
|
|
26484
|
-
return whole ? [cells, { kind: "parts", sheet:
|
|
27164
|
+
return whole ? [cells, { kind: "parts", sheet: index3, parts: ["columns", "rowInfo"] }] : [cells];
|
|
26485
27165
|
}
|
|
26486
27166
|
function applyStyle(ctx, s, ranges, patch3) {
|
|
26487
27167
|
const sheet = sheetAt(ctx.workbook, s);
|
|
@@ -26524,8 +27204,8 @@ var LISTS = [
|
|
|
26524
27204
|
function listMatch(text3) {
|
|
26525
27205
|
const lower2 = text3.toLowerCase();
|
|
26526
27206
|
for (const list of LISTS) {
|
|
26527
|
-
const
|
|
26528
|
-
if (
|
|
27207
|
+
const index3 = list.findIndex((item) => item.toLowerCase() === lower2);
|
|
27208
|
+
if (index3 >= 0) return { list, index: index3 };
|
|
26529
27209
|
}
|
|
26530
27210
|
return void 0;
|
|
26531
27211
|
}
|
|
@@ -26737,9 +27417,9 @@ function removeValidationArea(rules, area) {
|
|
|
26737
27417
|
}
|
|
26738
27418
|
|
|
26739
27419
|
// xlsx/edit/conditional-formats.ts
|
|
26740
|
-
function formatAt(sheet,
|
|
26741
|
-
const format = sheet.conditionalFormats[
|
|
26742
|
-
if (!format) throw new RangeError(`No conditional format at index ${
|
|
27420
|
+
function formatAt(sheet, index3) {
|
|
27421
|
+
const format = sheet.conditionalFormats[index3];
|
|
27422
|
+
if (!format) throw new RangeError(`No conditional format at index ${index3}`);
|
|
26743
27423
|
return format;
|
|
26744
27424
|
}
|
|
26745
27425
|
function rulesByPriority(sheet) {
|
|
@@ -26750,9 +27430,9 @@ function renumber(rules) {
|
|
|
26750
27430
|
rule.priority = i2 + 1;
|
|
26751
27431
|
});
|
|
26752
27432
|
}
|
|
26753
|
-
function replaceConditionalFormat(ctx, s,
|
|
27433
|
+
function replaceConditionalFormat(ctx, s, index3, format) {
|
|
26754
27434
|
const sheet = sheetAt(ctx.workbook, s);
|
|
26755
|
-
formatAt(sheet,
|
|
27435
|
+
formatAt(sheet, index3);
|
|
26756
27436
|
if (!format.ranges.length || !format.rules.length)
|
|
26757
27437
|
throw new Error("A conditional format needs at least one range and one rule.");
|
|
26758
27438
|
ctx.run(
|
|
@@ -26762,21 +27442,21 @@ function replaceConditionalFormat(ctx, s, index2, format) {
|
|
|
26762
27442
|
() => {
|
|
26763
27443
|
const next = structuredClone(format);
|
|
26764
27444
|
next.ranges = next.ranges.map(normalizeRange);
|
|
26765
|
-
sheet.conditionalFormats[
|
|
27445
|
+
sheet.conditionalFormats[index3] = next;
|
|
26766
27446
|
renumber(rulesByPriority(sheet));
|
|
26767
27447
|
},
|
|
26768
27448
|
{ sheet: s, ranges: format.ranges }
|
|
26769
27449
|
);
|
|
26770
27450
|
}
|
|
26771
|
-
function removeConditionalFormat(ctx, s,
|
|
27451
|
+
function removeConditionalFormat(ctx, s, index3) {
|
|
26772
27452
|
const sheet = sheetAt(ctx.workbook, s);
|
|
26773
|
-
const format = formatAt(sheet,
|
|
27453
|
+
const format = formatAt(sheet, index3);
|
|
26774
27454
|
ctx.run(
|
|
26775
27455
|
"Delete rule",
|
|
26776
27456
|
"format",
|
|
26777
27457
|
[{ kind: "sheet", sheet: s }],
|
|
26778
27458
|
() => {
|
|
26779
|
-
sheet.conditionalFormats.splice(
|
|
27459
|
+
sheet.conditionalFormats.splice(index3, 1);
|
|
26780
27460
|
renumber(rulesByPriority(sheet));
|
|
26781
27461
|
},
|
|
26782
27462
|
{ sheet: s, ranges: format.ranges }
|
|
@@ -26940,20 +27620,20 @@ function pasteConditionalFormats(sheet, dest, cells, transpose2, skipBlanks, cut
|
|
|
26940
27620
|
// xlsx/edit/annotations.ts
|
|
26941
27621
|
function setComment(ctx, s, at, text3, author) {
|
|
26942
27622
|
const sheet = sheetAt(ctx.workbook, s);
|
|
26943
|
-
const
|
|
27623
|
+
const index3 = sheet.comments.findIndex(
|
|
26944
27624
|
(c2) => c2.address.row === at.row && c2.address.col === at.col
|
|
26945
27625
|
);
|
|
26946
|
-
if (
|
|
27626
|
+
if (index3 < 0 && text3 === void 0) return;
|
|
26947
27627
|
ctx.run(
|
|
26948
|
-
text3 === void 0 ? "Delete comment" :
|
|
27628
|
+
text3 === void 0 ? "Delete comment" : index3 < 0 ? "New comment" : "Edit comment",
|
|
26949
27629
|
"annotations",
|
|
26950
27630
|
[{ kind: "sheet", sheet: s }],
|
|
26951
27631
|
() => {
|
|
26952
27632
|
if (text3 === void 0) {
|
|
26953
|
-
sheet.comments.splice(
|
|
27633
|
+
sheet.comments.splice(index3, 1);
|
|
26954
27634
|
return;
|
|
26955
27635
|
}
|
|
26956
|
-
const existing = sheet.comments[
|
|
27636
|
+
const existing = sheet.comments[index3];
|
|
26957
27637
|
if (existing) {
|
|
26958
27638
|
existing.text = text3;
|
|
26959
27639
|
existing.author = author;
|
|
@@ -28871,7 +29551,7 @@ function replaceAll(ctx, query, replacement) {
|
|
|
28871
29551
|
)
|
|
28872
29552
|
);
|
|
28873
29553
|
const uniqueScopes = scopes.filter(
|
|
28874
|
-
(scope,
|
|
29554
|
+
(scope, index3) => scope.kind !== "refs" || scopes.findIndex((entry3) => entry3.kind === "refs") === index3
|
|
28875
29555
|
);
|
|
28876
29556
|
return ctx.run(
|
|
28877
29557
|
"Replace",
|
|
@@ -29400,9 +30080,9 @@ function setDocumentProperties(ctx, patch3) {
|
|
|
29400
30080
|
}
|
|
29401
30081
|
|
|
29402
30082
|
// xlsx/edit/drawings.ts
|
|
29403
|
-
function drawingAt(ctx, s,
|
|
29404
|
-
const drawing = sheetAt(ctx.workbook, s).drawings[
|
|
29405
|
-
if (!drawing) throw new RangeError(`No drawing at index ${
|
|
30083
|
+
function drawingAt(ctx, s, index3) {
|
|
30084
|
+
const drawing = sheetAt(ctx.workbook, s).drawings[index3];
|
|
30085
|
+
if (!drawing) throw new RangeError(`No drawing at index ${index3} on sheet ${s}`);
|
|
29406
30086
|
return drawing;
|
|
29407
30087
|
}
|
|
29408
30088
|
function checkAnchor(anchor) {
|
|
@@ -29413,8 +30093,8 @@ function checkAnchor(anchor) {
|
|
|
29413
30093
|
if (anchor.ext && !(anchor.ext.cx >= 0 && anchor.ext.cy >= 0))
|
|
29414
30094
|
throw new RangeError("A drawing extent cannot be negative.");
|
|
29415
30095
|
}
|
|
29416
|
-
function setDrawingAnchor(ctx, s,
|
|
29417
|
-
const drawing = drawingAt(ctx, s,
|
|
30096
|
+
function setDrawingAnchor(ctx, s, index3, anchor) {
|
|
30097
|
+
const drawing = drawingAt(ctx, s, index3);
|
|
29418
30098
|
checkAnchor(anchor);
|
|
29419
30099
|
ctx.run(
|
|
29420
30100
|
"Move object",
|
|
@@ -29426,15 +30106,15 @@ function setDrawingAnchor(ctx, s, index2, anchor) {
|
|
|
29426
30106
|
{ sheet: s }
|
|
29427
30107
|
);
|
|
29428
30108
|
}
|
|
29429
|
-
function deleteDrawing(ctx, s,
|
|
29430
|
-
drawingAt(ctx, s,
|
|
30109
|
+
function deleteDrawing(ctx, s, index3) {
|
|
30110
|
+
drawingAt(ctx, s, index3);
|
|
29431
30111
|
const sheet = sheetAt(ctx.workbook, s);
|
|
29432
30112
|
ctx.run(
|
|
29433
30113
|
"Delete object",
|
|
29434
30114
|
"annotations",
|
|
29435
30115
|
[{ kind: "sheet", sheet: s }],
|
|
29436
30116
|
() => {
|
|
29437
|
-
sheet.drawings.splice(
|
|
30117
|
+
sheet.drawings.splice(index3, 1);
|
|
29438
30118
|
},
|
|
29439
30119
|
{ sheet: s }
|
|
29440
30120
|
);
|
|
@@ -29495,8 +30175,8 @@ function patchSparklineNode(node, patch3) {
|
|
|
29495
30175
|
if (old) node.replaceChild(replacement, old);
|
|
29496
30176
|
else {
|
|
29497
30177
|
const before = elements(node).find((child3) => {
|
|
29498
|
-
const
|
|
29499
|
-
return
|
|
30178
|
+
const index3 = COLORS2.indexOf(child3.localName);
|
|
30179
|
+
return index3 > COLORS2.indexOf(key) || child3.localName === "f" || child3.localName === "sparklines";
|
|
29500
30180
|
});
|
|
29501
30181
|
node.insertBefore(replacement, before ?? null);
|
|
29502
30182
|
}
|
|
@@ -29524,8 +30204,8 @@ function editSparklineXml(sheet, edit) {
|
|
|
29524
30204
|
function appendSparklineXml(sheet, groupXml2) {
|
|
29525
30205
|
const source2 = [...sheet.preserved.get("extLst") ?? []];
|
|
29526
30206
|
const found = source2.findIndex((xml) => xml.includes("sparklineGroups"));
|
|
29527
|
-
const
|
|
29528
|
-
const doc = parseXml(source2[
|
|
30207
|
+
const index3 = found >= 0 ? found : 0;
|
|
30208
|
+
const doc = parseXml(source2[index3] ?? `<extLst xmlns="${NS.x}"/>`);
|
|
29529
30209
|
const root = doc.documentElement;
|
|
29530
30210
|
let ext = children(root, "ext", NS.x).find(
|
|
29531
30211
|
(node) => node.getAttribute("uri")?.toUpperCase() === URI2.toUpperCase()
|
|
@@ -29552,7 +30232,7 @@ function appendSparklineXml(sheet, groupXml2) {
|
|
|
29552
30232
|
fresh.setAttributeNS(revision, "xr2:uid", `{${globalThis.crypto.randomUUID().toUpperCase()}}`);
|
|
29553
30233
|
}
|
|
29554
30234
|
groups.appendChild(fresh);
|
|
29555
|
-
source2[
|
|
30235
|
+
source2[index3] = buildXml(root);
|
|
29556
30236
|
return source2;
|
|
29557
30237
|
}
|
|
29558
30238
|
|
|
@@ -29771,12 +30451,16 @@ function write(ctx, s, pivot, old) {
|
|
|
29771
30451
|
],
|
|
29772
30452
|
() => {
|
|
29773
30453
|
const compact3 = pivot.layout === "compact";
|
|
29774
|
-
const indents =
|
|
29775
|
-
|
|
29776
|
-
|
|
29777
|
-
|
|
29778
|
-
|
|
29779
|
-
|
|
30454
|
+
const indents = new Map(
|
|
30455
|
+
[.../* @__PURE__ */ new Set([0, ...grid.indents ?? []])].map(
|
|
30456
|
+
(indent) => [
|
|
30457
|
+
indent,
|
|
30458
|
+
stylePatcher(ctx.workbook, {
|
|
30459
|
+
alignment: { indent, ...compact3 || indent > 0 ? { horizontal: "left" } : {} }
|
|
30460
|
+
})
|
|
30461
|
+
]
|
|
30462
|
+
)
|
|
30463
|
+
);
|
|
29780
30464
|
const styles = /* @__PURE__ */ new Map();
|
|
29781
30465
|
forEachCellInRange(sheet, location, (cell, row2, col) => {
|
|
29782
30466
|
if (cell.styleId !== void 0) styles.set(`${row2}:${col}`, cell.styleId);
|
|
@@ -29799,7 +30483,7 @@ function write(ctx, s, pivot, old) {
|
|
|
29799
30483
|
const indent = col === 0 ? grid.indents?.[row2] ?? 0 : 0;
|
|
29800
30484
|
const alignment = styleAt(ctx.workbook, styleId).alignment;
|
|
29801
30485
|
if ((alignment?.indent ?? 0) !== indent || compact3 && alignment?.horizontal !== "left")
|
|
29802
|
-
styleId = indents
|
|
30486
|
+
styleId = indents.get(indent)(styleId);
|
|
29803
30487
|
}
|
|
29804
30488
|
putCell(sheet, r, c2, { value: value2, ...styleId !== void 0 ? { styleId } : {} });
|
|
29805
30489
|
})
|
|
@@ -29826,6 +30510,10 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
29826
30510
|
valueField: options.valueField,
|
|
29827
30511
|
aggregate: aggregate3,
|
|
29828
30512
|
valueCaption: pivotCaption(aggregate3, options.valueField),
|
|
30513
|
+
...options.pageFilter !== void 0 ? { pageFilter: structuredClone(options.pageFilter) } : {},
|
|
30514
|
+
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
30515
|
+
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
30516
|
+
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
29829
30517
|
location: { start: { ...destination }, end: { ...destination } },
|
|
29830
30518
|
...options.columnField ? { columnField: options.columnField } : {}
|
|
29831
30519
|
};
|
|
@@ -29857,6 +30545,19 @@ function refreshPivotTable(ctx, s, name, patch3 = {}) {
|
|
|
29857
30545
|
if (patch3.repeatLabels !== void 0) next.repeatLabels = patch3.repeatLabels;
|
|
29858
30546
|
if (patch3.layout !== void 0) next.layout = patch3.layout;
|
|
29859
30547
|
if (patch3.subtotalPosition !== void 0) next.subtotalPosition = patch3.subtotalPosition;
|
|
30548
|
+
if (patch3.valuesAxis !== void 0) next.valuesAxis = patch3.valuesAxis;
|
|
30549
|
+
if (patch3.pageFilter !== void 0) {
|
|
30550
|
+
if (patch3.pageFilter === null) delete next.pageFilter;
|
|
30551
|
+
else next.pageFilter = structuredClone(patch3.pageFilter);
|
|
30552
|
+
}
|
|
30553
|
+
if (patch3.valuesPosition !== void 0) next.valuesPosition = patch3.valuesPosition;
|
|
30554
|
+
else if (patch3.valuesAxis === "columns" || patch3.secondRowField === "")
|
|
30555
|
+
delete next.valuesPosition;
|
|
30556
|
+
if (patch3.additionalValues !== void 0) {
|
|
30557
|
+
const measures = normalizedPivotMeasures(patch3.additionalValues);
|
|
30558
|
+
if (measures.length) next.additionalValues = measures;
|
|
30559
|
+
else delete next.additionalValues;
|
|
30560
|
+
}
|
|
29860
30561
|
validatePivotFields(next);
|
|
29861
30562
|
write(ctx, s, next, old);
|
|
29862
30563
|
}
|
|
@@ -29943,22 +30644,22 @@ function applyCellStyle(ctx, s, ranges, name) {
|
|
|
29943
30644
|
function sortGradientStops(stops) {
|
|
29944
30645
|
return stops.slice().sort((a2, b) => a2.position - b.position);
|
|
29945
30646
|
}
|
|
29946
|
-
function removeGradientStop(stops,
|
|
29947
|
-
return stops.length <= 2 ? void 0 : stops.filter((_, i2) => i2 !==
|
|
30647
|
+
function removeGradientStop(stops, index3) {
|
|
30648
|
+
return stops.length <= 2 ? void 0 : stops.filter((_, i2) => i2 !== index3);
|
|
29948
30649
|
}
|
|
29949
30650
|
|
|
29950
30651
|
// xlsx/edit/chart-series-transparency.ts
|
|
29951
|
-
function chartSeriesSolidColor(chart,
|
|
29952
|
-
const series = chart.series[
|
|
30652
|
+
function chartSeriesSolidColor(chart, index3) {
|
|
30653
|
+
const series = chart.series[index3];
|
|
29953
30654
|
if (!series || series.fill && series.fill.kind !== "solid") return void 0;
|
|
29954
30655
|
return series.fill?.kind === "solid" ? series.fill.color : series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(
|
|
29955
30656
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
29956
|
-
|
|
30657
|
+
index3,
|
|
29957
30658
|
chart.series.length
|
|
29958
30659
|
);
|
|
29959
30660
|
}
|
|
29960
|
-
function chartSeriesTransparency(chart,
|
|
29961
|
-
const color = chartSeriesSolidColor(chart,
|
|
30661
|
+
function chartSeriesTransparency(chart, index3) {
|
|
30662
|
+
const color = chartSeriesSolidColor(chart, index3);
|
|
29962
30663
|
if (!color) return void 0;
|
|
29963
30664
|
const resolved = resolveDrawingColor(
|
|
29964
30665
|
color,
|
|
@@ -29967,11 +30668,11 @@ function chartSeriesTransparency(chart, index2) {
|
|
|
29967
30668
|
);
|
|
29968
30669
|
return resolved ? Math.round((1 - resolved.alpha) * 1e5) / 1e3 : void 0;
|
|
29969
30670
|
}
|
|
29970
|
-
function chartSeriesTransparencyPatch(chart,
|
|
30671
|
+
function chartSeriesTransparencyPatch(chart, index3, percent2) {
|
|
29971
30672
|
if (!Number.isFinite(percent2) || percent2 < 0 || percent2 > 100)
|
|
29972
30673
|
throw new RangeError("Chart transparency must be from 0 to 100");
|
|
29973
|
-
const current = chartSeriesAt(chart,
|
|
29974
|
-
const color = chartSeriesSolidColor(chart,
|
|
30674
|
+
const current = chartSeriesAt(chart, index3);
|
|
30675
|
+
const color = chartSeriesSolidColor(chart, index3);
|
|
29975
30676
|
if (!color) return void 0;
|
|
29976
30677
|
const choice = structuredClone(color);
|
|
29977
30678
|
choice.transforms = choice.transforms.filter(
|
|
@@ -29981,7 +30682,7 @@ function chartSeriesTransparencyPatch(chart, index2, percent2) {
|
|
|
29981
30682
|
choice.transforms.push({ name: "alpha", value: String(Math.round((100 - percent2) * 1e3)) });
|
|
29982
30683
|
if (sameChartColor(choice, color) && !Object.keys(current.pointColors ?? {}).length && !Object.keys(current.pointFills ?? {}).length)
|
|
29983
30684
|
return void 0;
|
|
29984
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
30685
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
29985
30686
|
delete next.fill;
|
|
29986
30687
|
delete next.color;
|
|
29987
30688
|
delete next.pointColors;
|
|
@@ -29991,8 +30692,8 @@ function chartSeriesTransparencyPatch(chart, index2, percent2) {
|
|
|
29991
30692
|
}
|
|
29992
30693
|
|
|
29993
30694
|
// xlsx/edit/chart-series-gradient.ts
|
|
29994
|
-
function chartGradientStopTransparency(fill,
|
|
29995
|
-
const color = fill.stops[
|
|
30695
|
+
function chartGradientStopTransparency(fill, index3) {
|
|
30696
|
+
const color = fill.stops[index3]?.color;
|
|
29996
30697
|
const value2 = color && resolveDrawingColor(color, { scheme: () => "#000000" }, { transformOrder: "document" });
|
|
29997
30698
|
return value2 ? Math.round((1 - value2.alpha) * 1e5) / 1e3 : 0;
|
|
29998
30699
|
}
|
|
@@ -30000,19 +30701,19 @@ function percent(value2) {
|
|
|
30000
30701
|
if (!Number.isFinite(value2) || value2 < 0 || value2 > 100)
|
|
30001
30702
|
throw new RangeError("Gradient value must be from 0 to 100");
|
|
30002
30703
|
}
|
|
30003
|
-
function chartSeriesGradientPatch(chart,
|
|
30004
|
-
const current = chartSeriesAt(chart,
|
|
30704
|
+
function chartSeriesGradientPatch(chart, index3, edit) {
|
|
30705
|
+
const current = chartSeriesAt(chart, index3);
|
|
30005
30706
|
const result2 = chartGradientFillEdit(
|
|
30006
30707
|
current.fill,
|
|
30007
30708
|
edit,
|
|
30008
|
-
chartSeriesSolidColor(chart,
|
|
30709
|
+
chartSeriesSolidColor(chart, index3) ?? chartPaletteSeriesColorChoice(
|
|
30009
30710
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
30010
|
-
|
|
30711
|
+
index3,
|
|
30011
30712
|
chart.series.length
|
|
30012
30713
|
)
|
|
30013
30714
|
);
|
|
30014
30715
|
if (!result2) return void 0;
|
|
30015
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
30716
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
30016
30717
|
next.fill = result2.fill;
|
|
30017
30718
|
delete next.color;
|
|
30018
30719
|
delete next.drawingColor;
|
|
@@ -30208,18 +30909,18 @@ function addChart(ctx, s, chart) {
|
|
|
30208
30909
|
{ sheet: s }
|
|
30209
30910
|
);
|
|
30210
30911
|
}
|
|
30211
|
-
function updateChart(ctx, s,
|
|
30912
|
+
function updateChart(ctx, s, index3, patch3) {
|
|
30212
30913
|
assertBarClusterOptions(patch3);
|
|
30213
30914
|
const sheet = sheetAt(ctx.workbook, s);
|
|
30214
|
-
const chart = sheet.drawings[
|
|
30215
|
-
if (!chart || chart.kind !== "chart") throw new RangeError(`No chart at index ${
|
|
30915
|
+
const chart = sheet.drawings[index3];
|
|
30916
|
+
if (!chart || chart.kind !== "chart") throw new RangeError(`No chart at index ${index3}`);
|
|
30216
30917
|
const formatting = patch3.elementFills ? chartWithElementFills(chart, patch3.elementFills).formatting : void 0;
|
|
30217
30918
|
ctx.run(
|
|
30218
30919
|
"Edit chart",
|
|
30219
30920
|
"annotations",
|
|
30220
30921
|
[{ kind: "sheet", sheet: s }],
|
|
30221
30922
|
() => {
|
|
30222
|
-
const live = sheet.drawings[
|
|
30923
|
+
const live = sheet.drawings[index3];
|
|
30223
30924
|
const changes = structuredClone(patch3);
|
|
30224
30925
|
delete changes.elementFills;
|
|
30225
30926
|
if (formatting) live.formatting = formatting;
|
|
@@ -30337,9 +31038,9 @@ function applyTotalsRow(sheet, table2) {
|
|
|
30337
31038
|
|
|
30338
31039
|
// xlsx/edit/table-edits.ts
|
|
30339
31040
|
function tableIndex(sheet, ref) {
|
|
30340
|
-
const
|
|
30341
|
-
if (!sheet.tables[
|
|
30342
|
-
return
|
|
31041
|
+
const index3 = typeof ref === "number" ? ref : sheet.tables.findIndex((t) => t.name.toLowerCase() === ref.toLowerCase());
|
|
31042
|
+
if (!sheet.tables[index3]) throw new RangeError(`No table ${String(ref)} on ${sheet.name}`);
|
|
31043
|
+
return index3;
|
|
30343
31044
|
}
|
|
30344
31045
|
var TABLE_NAME = /^[A-Za-z_\\][A-Za-z0-9_.\\]*$/;
|
|
30345
31046
|
function validateTableName(workbook, name, self) {
|
|
@@ -30501,8 +31202,8 @@ function updateTable(ctx, s, ref, patch3) {
|
|
|
30501
31202
|
if (patch3.columns.length !== width) throw new Error("Give one column per table column.");
|
|
30502
31203
|
const before = table2.columns;
|
|
30503
31204
|
table2.columns = structuredClone(patch3.columns);
|
|
30504
|
-
for (const [
|
|
30505
|
-
const sourceId = before[
|
|
31205
|
+
for (const [index3, column] of table2.columns.entries()) {
|
|
31206
|
+
const sourceId = before[index3]?.sourceId;
|
|
30506
31207
|
if (column.sourceId === void 0 && sourceId !== void 0) column.sourceId = sourceId;
|
|
30507
31208
|
}
|
|
30508
31209
|
}
|
|
@@ -30759,8 +31460,8 @@ function setPageBreak(ctx, s, axis, before, present = true) {
|
|
|
30759
31460
|
const sheet = sheetAt(ctx.workbook, s);
|
|
30760
31461
|
const key = axis === "row" ? "rowBreaks" : "colBreaks";
|
|
30761
31462
|
const source2 = sheet.preserved.get(key) ?? [`<${key} xmlns="${NS.x}"/>`];
|
|
30762
|
-
const result2 = source2.flatMap((xml,
|
|
30763
|
-
const next = patch2(xml, before, present &&
|
|
31463
|
+
const result2 = source2.flatMap((xml, index3) => {
|
|
31464
|
+
const next = patch2(xml, before, present && index3 === 0, axis);
|
|
30764
31465
|
return next ? [next] : [];
|
|
30765
31466
|
});
|
|
30766
31467
|
ctx.run(
|
|
@@ -30903,16 +31604,16 @@ function setDefinedName(ctx, name) {
|
|
|
30903
31604
|
entry3.formula = entry3.formula.replace(/^=/, "");
|
|
30904
31605
|
ctx.run("Define name", "names", [{ kind: "meta" }], () => {
|
|
30905
31606
|
const { definedNames } = ctx.workbook;
|
|
30906
|
-
const
|
|
30907
|
-
if (
|
|
31607
|
+
const index3 = definedNames.findIndex((n2) => sameName(n2, name.name, name.localSheet));
|
|
31608
|
+
if (index3 >= 0) definedNames[index3] = entry3;
|
|
30908
31609
|
else definedNames.push(entry3);
|
|
30909
31610
|
});
|
|
30910
31611
|
}
|
|
30911
31612
|
function deleteDefinedName(ctx, name, localSheet) {
|
|
30912
|
-
const
|
|
30913
|
-
if (
|
|
31613
|
+
const index3 = ctx.workbook.definedNames.findIndex((n2) => sameName(n2, name, localSheet));
|
|
31614
|
+
if (index3 < 0) return;
|
|
30914
31615
|
ctx.run("Delete name", "names", [{ kind: "meta" }], () => {
|
|
30915
|
-
ctx.workbook.definedNames.splice(
|
|
31616
|
+
ctx.workbook.definedNames.splice(index3, 1);
|
|
30916
31617
|
});
|
|
30917
31618
|
}
|
|
30918
31619
|
|
|
@@ -30950,7 +31651,7 @@ function normalizeDigestAlgorithmName(name) {
|
|
|
30950
31651
|
|
|
30951
31652
|
// digest/base64.ts
|
|
30952
31653
|
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
30953
|
-
var VALUES = new Map([...ALPHABET].map((char,
|
|
31654
|
+
var VALUES = new Map([...ALPHABET].map((char, index3) => [char, index3]));
|
|
30954
31655
|
function encodeBase64(bytes) {
|
|
30955
31656
|
let out = "";
|
|
30956
31657
|
for (let i2 = 0; i2 < bytes.length; i2 += 3) {
|
|
@@ -30972,7 +31673,7 @@ function decodeBase64(text3) {
|
|
|
30972
31673
|
const out = new Uint8Array(Math.floor(body.length * 3 / 4));
|
|
30973
31674
|
let bits = 0;
|
|
30974
31675
|
let buffer = 0;
|
|
30975
|
-
let
|
|
31676
|
+
let index3 = 0;
|
|
30976
31677
|
for (const char of body) {
|
|
30977
31678
|
const value2 = VALUES.get(char);
|
|
30978
31679
|
if (value2 === void 0) return void 0;
|
|
@@ -30980,7 +31681,7 @@ function decodeBase64(text3) {
|
|
|
30980
31681
|
bits += 6;
|
|
30981
31682
|
if (bits >= 8) {
|
|
30982
31683
|
bits -= 8;
|
|
30983
|
-
out[
|
|
31684
|
+
out[index3++] = buffer >> bits & 255;
|
|
30984
31685
|
}
|
|
30985
31686
|
}
|
|
30986
31687
|
return out;
|
|
@@ -31369,7 +32070,7 @@ function i(x, y, z) {
|
|
|
31369
32070
|
}
|
|
31370
32071
|
var T = Array.from(
|
|
31371
32072
|
{ length: 64 },
|
|
31372
|
-
(_,
|
|
32073
|
+
(_, index3) => Math.floor(Math.abs(Math.sin(index3 + 1)) * 2 ** 32)
|
|
31373
32074
|
);
|
|
31374
32075
|
var SHIFTS = [
|
|
31375
32076
|
[7, 12, 17, 22],
|
|
@@ -33127,14 +33828,14 @@ var AxisMetrics = class {
|
|
|
33127
33828
|
constructor(defaultSize, count2, overrides) {
|
|
33128
33829
|
this.defaultSize = defaultSize;
|
|
33129
33830
|
this.count = count2;
|
|
33130
|
-
const sorted2 = [...overrides].filter(([
|
|
33831
|
+
const sorted2 = [...overrides].filter(([index3, size]) => index3 >= 0 && index3 < count2 && size !== defaultSize).sort((a2, b) => a2[0] - b[0]);
|
|
33131
33832
|
this.indices = [];
|
|
33132
33833
|
this.sizes = [];
|
|
33133
33834
|
this.prefix = [];
|
|
33134
33835
|
let delta = 0;
|
|
33135
|
-
for (const [
|
|
33136
|
-
if (this.indices.at(-1) ===
|
|
33137
|
-
this.indices.push(
|
|
33836
|
+
for (const [index3, size] of sorted2) {
|
|
33837
|
+
if (this.indices.at(-1) === index3) continue;
|
|
33838
|
+
this.indices.push(index3);
|
|
33138
33839
|
this.sizes.push(Math.max(0, size));
|
|
33139
33840
|
this.prefix.push(delta);
|
|
33140
33841
|
delta += Math.max(0, size) - defaultSize;
|
|
@@ -33151,24 +33852,24 @@ var AxisMetrics = class {
|
|
|
33151
33852
|
prefix;
|
|
33152
33853
|
totalDelta;
|
|
33153
33854
|
/** Number of custom entries strictly before `index` (binary search). */
|
|
33154
|
-
rank(
|
|
33855
|
+
rank(index3) {
|
|
33155
33856
|
let lo = 0;
|
|
33156
33857
|
let hi = this.indices.length;
|
|
33157
33858
|
while (lo < hi) {
|
|
33158
33859
|
const mid = lo + hi >> 1;
|
|
33159
|
-
if ((this.indices[mid] ?? 0) <
|
|
33860
|
+
if ((this.indices[mid] ?? 0) < index3) lo = mid + 1;
|
|
33160
33861
|
else hi = mid;
|
|
33161
33862
|
}
|
|
33162
33863
|
return lo;
|
|
33163
33864
|
}
|
|
33164
|
-
size(
|
|
33165
|
-
if (
|
|
33166
|
-
const k = this.rank(
|
|
33167
|
-
return this.indices[k] ===
|
|
33865
|
+
size(index3) {
|
|
33866
|
+
if (index3 < 0 || index3 >= this.count) return 0;
|
|
33867
|
+
const k = this.rank(index3);
|
|
33868
|
+
return this.indices[k] === index3 ? this.sizes[k] ?? 0 : this.defaultSize;
|
|
33168
33869
|
}
|
|
33169
33870
|
/** Offset of the leading edge of `index` (`index` may equal `count` for the axis end). */
|
|
33170
|
-
start(
|
|
33171
|
-
const i2 = Math.max(0, Math.min(
|
|
33871
|
+
start(index3) {
|
|
33872
|
+
const i2 = Math.max(0, Math.min(index3, this.count));
|
|
33172
33873
|
const k = this.rank(i2);
|
|
33173
33874
|
const before = k < this.indices.length ? this.prefix[k] ?? 0 : this.totalDelta;
|
|
33174
33875
|
return i2 * this.defaultSize + before;
|
|
@@ -33203,13 +33904,13 @@ var AxisMetrics = class {
|
|
|
33203
33904
|
return Math.min(line3, this.count - 1);
|
|
33204
33905
|
}
|
|
33205
33906
|
/** The first line at or after `index` with a non-zero size (or `count - 1`). */
|
|
33206
|
-
firstVisible(
|
|
33207
|
-
for (let i2 = Math.max(0,
|
|
33907
|
+
firstVisible(index3) {
|
|
33908
|
+
for (let i2 = Math.max(0, index3); i2 < this.count; i2++) if (this.size(i2) > 0) return i2;
|
|
33208
33909
|
return this.count - 1;
|
|
33209
33910
|
}
|
|
33210
33911
|
/** The last line at or before `index` with a non-zero size (or 0). */
|
|
33211
|
-
lastVisible(
|
|
33212
|
-
for (let i2 = Math.min(
|
|
33912
|
+
lastVisible(index3) {
|
|
33913
|
+
for (let i2 = Math.min(index3, this.count - 1); i2 >= 0; i2--) if (this.size(i2) > 0) return i2;
|
|
33213
33914
|
return 0;
|
|
33214
33915
|
}
|
|
33215
33916
|
/** Largest custom-entry index, or -1. */
|
|
@@ -33426,10 +34127,10 @@ function remapSheets(workbook, map) {
|
|
|
33426
34127
|
});
|
|
33427
34128
|
}
|
|
33428
34129
|
var visibleCount = (workbook) => workbook.sheets.filter((s) => s.state === "visible").length;
|
|
33429
|
-
function nearestVisible(workbook,
|
|
33430
|
-
for (let i2 =
|
|
34130
|
+
function nearestVisible(workbook, index3) {
|
|
34131
|
+
for (let i2 = index3; i2 < workbook.sheets.length; i2++)
|
|
33431
34132
|
if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
33432
|
-
for (let i2 =
|
|
34133
|
+
for (let i2 = index3 - 1; i2 >= 0; i2--) if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
33433
34134
|
return 0;
|
|
33434
34135
|
}
|
|
33435
34136
|
function addSheet(ctx, name, at) {
|
|
@@ -33438,24 +34139,24 @@ function addSheet(ctx, name, at) {
|
|
|
33438
34139
|
const sheetName = name ?? nextSheetName(workbook, ctx.defaultSheetBase);
|
|
33439
34140
|
const problem = validateSheetName(workbook, sheetName);
|
|
33440
34141
|
if (problem) throw new Error(problem);
|
|
33441
|
-
const
|
|
34142
|
+
const index3 = Math.max(0, Math.min(at ?? workbook.sheets.length, workbook.sheets.length));
|
|
33442
34143
|
return ctx.run(
|
|
33443
34144
|
"Insert sheet",
|
|
33444
34145
|
"sheets",
|
|
33445
34146
|
[{ kind: "workbook" }],
|
|
33446
34147
|
() => {
|
|
33447
|
-
workbook.sheets.splice(
|
|
33448
|
-
remapSheets(workbook, (i2) => i2 >=
|
|
33449
|
-
workbook.activeSheet =
|
|
33450
|
-
return
|
|
34148
|
+
workbook.sheets.splice(index3, 0, createWorksheet(sheetName, nextSheetId(workbook)));
|
|
34149
|
+
remapSheets(workbook, (i2) => i2 >= index3 ? i2 + 1 : i2);
|
|
34150
|
+
workbook.activeSheet = index3;
|
|
34151
|
+
return index3;
|
|
33451
34152
|
},
|
|
33452
|
-
{ sheet:
|
|
34153
|
+
{ sheet: index3, structural: true }
|
|
33453
34154
|
);
|
|
33454
34155
|
}
|
|
33455
|
-
function deleteSheet(ctx,
|
|
34156
|
+
function deleteSheet(ctx, index3) {
|
|
33456
34157
|
const { workbook } = ctx;
|
|
33457
34158
|
assertUnlocked(workbook);
|
|
33458
|
-
const sheet = sheetAt(workbook,
|
|
34159
|
+
const sheet = sheetAt(workbook, index3);
|
|
33459
34160
|
if (sheet.state === "visible" && visibleCount(workbook) <= 1)
|
|
33460
34161
|
throw new Error("A workbook must contain at least one visible sheet.");
|
|
33461
34162
|
if (workbook.sheets.some(
|
|
@@ -33470,26 +34171,26 @@ function deleteSheet(ctx, index2) {
|
|
|
33470
34171
|
[{ kind: "workbook" }],
|
|
33471
34172
|
() => {
|
|
33472
34173
|
const tables = sheet.tables.map((t) => t.name);
|
|
33473
|
-
workbook.sheets.splice(
|
|
33474
|
-
remapSheets(workbook, (i2) => i2 ===
|
|
34174
|
+
workbook.sheets.splice(index3, 1);
|
|
34175
|
+
remapSheets(workbook, (i2) => i2 === index3 ? void 0 : i2 > index3 ? i2 - 1 : i2);
|
|
33475
34176
|
rewriteFormulas(workbook, (formula) => deleteSheetInFormula(formula, sheet.name, tables));
|
|
33476
|
-
if (workbook.activeSheet >
|
|
33477
|
-
else if (workbook.activeSheet ===
|
|
34177
|
+
if (workbook.activeSheet > index3) workbook.activeSheet--;
|
|
34178
|
+
else if (workbook.activeSheet === index3)
|
|
33478
34179
|
workbook.activeSheet = nearestVisible(
|
|
33479
34180
|
workbook,
|
|
33480
|
-
Math.min(
|
|
34181
|
+
Math.min(index3, workbook.sheets.length - 1)
|
|
33481
34182
|
);
|
|
33482
34183
|
},
|
|
33483
34184
|
{ structural: true }
|
|
33484
34185
|
);
|
|
33485
34186
|
}
|
|
33486
|
-
function renameSheet(ctx,
|
|
34187
|
+
function renameSheet(ctx, index3, name) {
|
|
33487
34188
|
const { workbook } = ctx;
|
|
33488
34189
|
assertUnlocked(workbook);
|
|
33489
|
-
const sheet = sheetAt(workbook,
|
|
34190
|
+
const sheet = sheetAt(workbook, index3);
|
|
33490
34191
|
const old = sheet.name;
|
|
33491
34192
|
if (old === name) return;
|
|
33492
|
-
const problem = validateSheetName(workbook, name,
|
|
34193
|
+
const problem = validateSheetName(workbook, name, index3);
|
|
33493
34194
|
if (problem) throw new Error(problem);
|
|
33494
34195
|
ctx.run(
|
|
33495
34196
|
"Rename sheet",
|
|
@@ -33499,7 +34200,7 @@ function renameSheet(ctx, index2, name) {
|
|
|
33499
34200
|
rewriteFormulas(workbook, (formula) => renameSheetInFormula(formula, old, name));
|
|
33500
34201
|
sheet.name = name;
|
|
33501
34202
|
},
|
|
33502
|
-
{ sheet:
|
|
34203
|
+
{ sheet: index3, structural: true, calc: { kind: "rename", from: old, to: name } }
|
|
33503
34204
|
);
|
|
33504
34205
|
}
|
|
33505
34206
|
function moveSheet(ctx, from, to) {
|
|
@@ -33542,8 +34243,8 @@ function uniqueTableName(workbook, base, extra) {
|
|
|
33542
34243
|
const stem = base.replace(/_\d+$/, "") || "Table";
|
|
33543
34244
|
for (let n2 = 2; ; n2++) if (!taken.has(`${stem}_${n2}`.toLowerCase())) return `${stem}_${n2}`;
|
|
33544
34245
|
}
|
|
33545
|
-
function namesForCopy(workbook,
|
|
33546
|
-
const local = workbook.definedNames.filter((n2) => n2.localSheet ===
|
|
34246
|
+
function namesForCopy(workbook, index3, from, to) {
|
|
34247
|
+
const local = workbook.definedNames.filter((n2) => n2.localSheet === index3);
|
|
33547
34248
|
const taken = new Set(local.map((n2) => n2.name.toLowerCase()));
|
|
33548
34249
|
const global = workbook.definedNames.filter(
|
|
33549
34250
|
(n2) => n2.localSheet === void 0 && !taken.has(n2.name.toLowerCase()) && renameSheetInFormula(n2.formula, from, to) !== n2.formula
|
|
@@ -33553,11 +34254,11 @@ function namesForCopy(workbook, index2, from, to) {
|
|
|
33553
34254
|
formula: renameSheetInFormula(n2.formula, from, to)
|
|
33554
34255
|
}));
|
|
33555
34256
|
}
|
|
33556
|
-
function duplicateSheet(ctx,
|
|
34257
|
+
function duplicateSheet(ctx, index3) {
|
|
33557
34258
|
const { workbook } = ctx;
|
|
33558
34259
|
assertUnlocked(workbook);
|
|
33559
|
-
const sheet = sheetAt(workbook,
|
|
33560
|
-
const at =
|
|
34260
|
+
const sheet = sheetAt(workbook, index3);
|
|
34261
|
+
const at = index3 + 1;
|
|
33561
34262
|
return ctx.run(
|
|
33562
34263
|
"Duplicate sheet",
|
|
33563
34264
|
"sheets",
|
|
@@ -33595,7 +34296,7 @@ function duplicateSheet(ctx, index2) {
|
|
|
33595
34296
|
);
|
|
33596
34297
|
rewriteSheetFormulas(copy, rewrite2);
|
|
33597
34298
|
for (const drawing of copy.drawings) if (drawing.kind === "chart") delete drawing.partName;
|
|
33598
|
-
const copiedNames = namesForCopy(workbook,
|
|
34299
|
+
const copiedNames = namesForCopy(workbook, index3, sheet.name, copy.name);
|
|
33599
34300
|
for (const name of copiedNames) name.formula = rewrite2(name.formula);
|
|
33600
34301
|
workbook.sheets.splice(at, 0, copy);
|
|
33601
34302
|
remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
|
|
@@ -33606,9 +34307,9 @@ function duplicateSheet(ctx, index2) {
|
|
|
33606
34307
|
{ sheet: at, structural: true }
|
|
33607
34308
|
);
|
|
33608
34309
|
}
|
|
33609
|
-
function setSheetState(ctx,
|
|
34310
|
+
function setSheetState(ctx, index3, state) {
|
|
33610
34311
|
const { workbook } = ctx;
|
|
33611
|
-
const sheet = sheetAt(workbook,
|
|
34312
|
+
const sheet = sheetAt(workbook, index3);
|
|
33612
34313
|
if (sheet.state === state) return;
|
|
33613
34314
|
assertUnlocked(workbook);
|
|
33614
34315
|
if (state !== "visible") {
|
|
@@ -33618,26 +34319,26 @@ function setSheetState(ctx, index2, state) {
|
|
|
33618
34319
|
ctx.run(
|
|
33619
34320
|
state === "visible" ? "Unhide sheet" : "Hide sheet",
|
|
33620
34321
|
"sheets",
|
|
33621
|
-
[{ kind: "sheet", sheet:
|
|
34322
|
+
[{ kind: "sheet", sheet: index3 }, { kind: "meta" }],
|
|
33622
34323
|
() => {
|
|
33623
34324
|
sheet.state = state;
|
|
33624
|
-
if (state !== "visible" && workbook.activeSheet ===
|
|
33625
|
-
workbook.activeSheet = nearestVisible(workbook,
|
|
34325
|
+
if (state !== "visible" && workbook.activeSheet === index3)
|
|
34326
|
+
workbook.activeSheet = nearestVisible(workbook, index3);
|
|
33626
34327
|
},
|
|
33627
|
-
{ sheet:
|
|
34328
|
+
{ sheet: index3, structural: true }
|
|
33628
34329
|
);
|
|
33629
34330
|
}
|
|
33630
|
-
function setTabColor(ctx,
|
|
33631
|
-
const sheet = sheetAt(ctx.workbook,
|
|
34331
|
+
function setTabColor(ctx, index3, color) {
|
|
34332
|
+
const sheet = sheetAt(ctx.workbook, index3);
|
|
33632
34333
|
ctx.run(
|
|
33633
34334
|
"Tab color",
|
|
33634
34335
|
"sheets",
|
|
33635
|
-
[{ kind: "sheet", sheet:
|
|
34336
|
+
[{ kind: "sheet", sheet: index3 }],
|
|
33636
34337
|
() => {
|
|
33637
34338
|
if (color) sheet.tabColor = { ...color };
|
|
33638
34339
|
else Reflect.deleteProperty(sheet, "tabColor");
|
|
33639
34340
|
},
|
|
33640
|
-
{ sheet:
|
|
34341
|
+
{ sheet: index3 }
|
|
33641
34342
|
);
|
|
33642
34343
|
}
|
|
33643
34344
|
|
|
@@ -34051,20 +34752,20 @@ function createEditSession(workbook, options = {}) {
|
|
|
34051
34752
|
setSheetView: (s, patch3) => setSheetView(ctx, s, patch3),
|
|
34052
34753
|
setDefinedName: (name) => setDefinedName(ctx, name),
|
|
34053
34754
|
deleteDefinedName: (name, localSheet) => deleteDefinedName(ctx, name, localSheet),
|
|
34054
|
-
setDrawingAnchor: (s,
|
|
34755
|
+
setDrawingAnchor: (s, index3, anchor) => setDrawingAnchor(ctx, s, index3, anchor),
|
|
34055
34756
|
createPivotTable: (s, destination, options2) => createPivotTable(ctx, s, destination, options2),
|
|
34056
34757
|
refreshPivotTable: (s, name, patch3) => refreshPivotTable(ctx, s, name, patch3),
|
|
34057
34758
|
deletePivotTable: (s, name) => deletePivotTable(ctx, s, name),
|
|
34058
|
-
deleteDrawing: (s,
|
|
34759
|
+
deleteDrawing: (s, index3) => deleteDrawing(ctx, s, index3),
|
|
34059
34760
|
createSparklineGroup: (s, source2, locations, patch3) => createSparklineGroup(ctx, s, source2, locations, patch3),
|
|
34060
34761
|
setSparklineGroups: (s, ranges, patch3) => setSparklineGroups(ctx, s, ranges, patch3),
|
|
34061
34762
|
setSparklineDateRange: (s, ranges, source2) => setSparklineDateRange(ctx, s, ranges, source2),
|
|
34062
34763
|
deleteSparklines: (s, ranges, wholeGroups) => deleteSparklines(ctx, s, ranges, wholeGroups),
|
|
34063
34764
|
addChart: (s, chart) => addChart(ctx, s, chart),
|
|
34064
|
-
updateChart: (s,
|
|
34765
|
+
updateChart: (s, index3, patch3) => updateChart(ctx, s, index3, patch3),
|
|
34065
34766
|
addImage: (s, bytes, type, anchor, name) => addImage(ctx, s, bytes, type, anchor, name),
|
|
34066
|
-
replaceConditionalFormat: (s,
|
|
34067
|
-
removeConditionalFormat: (s,
|
|
34767
|
+
replaceConditionalFormat: (s, index3, cf) => replaceConditionalFormat(ctx, s, index3, cf),
|
|
34768
|
+
removeConditionalFormat: (s, index3) => removeConditionalFormat(ctx, s, index3),
|
|
34068
34769
|
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
34069
34770
|
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
34070
34771
|
updateTable: (s, table2, patch3) => updateTable(ctx, s, table2, patch3),
|
|
@@ -34308,12 +35009,12 @@ function mergeDxf(acc, next) {
|
|
|
34308
35009
|
return out;
|
|
34309
35010
|
}
|
|
34310
35011
|
function iconIndex(value2, cuts, list) {
|
|
34311
|
-
let
|
|
35012
|
+
let index3 = 0;
|
|
34312
35013
|
for (let i2 = 1; i2 < cuts.length; i2++) {
|
|
34313
35014
|
const cut = cuts[i2] ?? Infinity;
|
|
34314
|
-
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut)
|
|
35015
|
+
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut) index3 = i2;
|
|
34315
35016
|
}
|
|
34316
|
-
return
|
|
35017
|
+
return index3;
|
|
34317
35018
|
}
|
|
34318
35019
|
function scaleColor(value2, cuts, colors) {
|
|
34319
35020
|
if (!cuts.length || cuts.length !== colors.length) return void 0;
|
|
@@ -34692,10 +35393,10 @@ function createConditionalFormatEvaluator(workbook, sheetIndex2, evaluate, optio
|
|
|
34692
35393
|
}
|
|
34693
35394
|
if (rule.type === "iconSet") {
|
|
34694
35395
|
if (result2.icon || typeof value2 !== "number") return false;
|
|
34695
|
-
const
|
|
35396
|
+
const index3 = iconIndex(value2, thresholds(entry3, rule.thresholds), rule.thresholds);
|
|
34696
35397
|
result2.icon = {
|
|
34697
35398
|
set: rule.iconSet,
|
|
34698
|
-
index: rule.reverse ? rule.thresholds.length - 1 -
|
|
35399
|
+
index: rule.reverse ? rule.thresholds.length - 1 - index3 : index3
|
|
34699
35400
|
};
|
|
34700
35401
|
if (rule.showValue === false) result2.hideValue = true;
|
|
34701
35402
|
return true;
|
|
@@ -34827,19 +35528,19 @@ var filled = (sheet, row2, col) => {
|
|
|
34827
35528
|
const cell = sheet.rows.get(row2)?.get(col);
|
|
34828
35529
|
return cell !== void 0 && (cell.value !== null && cell.value !== "" || cell.formula !== void 0);
|
|
34829
35530
|
};
|
|
34830
|
-
function step(
|
|
34831
|
-
for (let i2 =
|
|
34832
|
-
return
|
|
35531
|
+
function step(index3, dir, max, hidden) {
|
|
35532
|
+
for (let i2 = index3 + dir; i2 >= 0 && i2 <= max; i2 += dir) if (!hidden(i2)) return i2;
|
|
35533
|
+
return index3;
|
|
34833
35534
|
}
|
|
34834
35535
|
function edge(dir, max, hidden) {
|
|
34835
35536
|
const start = dir > 0 ? max : 0;
|
|
34836
35537
|
if (!hidden(start)) return start;
|
|
34837
35538
|
return step(start, dir > 0 ? -1 : 1, max, hidden);
|
|
34838
35539
|
}
|
|
34839
|
-
function jump(
|
|
34840
|
-
const next = step(
|
|
34841
|
-
if (next ===
|
|
34842
|
-
if (filledSet.has(
|
|
35540
|
+
function jump(index3, dir, max, hidden, filledSet) {
|
|
35541
|
+
const next = step(index3, dir, max, hidden);
|
|
35542
|
+
if (next === index3) return index3;
|
|
35543
|
+
if (filledSet.has(index3) && filledSet.has(next)) {
|
|
34843
35544
|
let at = next;
|
|
34844
35545
|
for (; ; ) {
|
|
34845
35546
|
const after = step(at, dir, max, hidden);
|
|
@@ -34847,7 +35548,7 @@ function jump(index2, dir, max, hidden, filledSet) {
|
|
|
34847
35548
|
at = after;
|
|
34848
35549
|
}
|
|
34849
35550
|
}
|
|
34850
|
-
const candidates = [...filledSet].filter((i2) => (dir > 0 ? i2 >
|
|
35551
|
+
const candidates = [...filledSet].filter((i2) => (dir > 0 ? i2 > index3 : i2 < index3) && !hidden(i2));
|
|
34851
35552
|
if (!candidates.length) return edge(dir, max, hidden);
|
|
34852
35553
|
return dir > 0 ? Math.min(...candidates) : Math.max(...candidates);
|
|
34853
35554
|
}
|
|
@@ -34952,7 +35653,7 @@ function autoFitColumnWidth(sheet, workbook, col, measure, mdw = DEFAULT_MAX_DIG
|
|
|
34952
35653
|
// chart/render/chart-colors.ts
|
|
34953
35654
|
function chartColorScheme(theme2) {
|
|
34954
35655
|
const slots = Object.fromEntries(
|
|
34955
|
-
THEME_SLOTS.map((slot2,
|
|
35656
|
+
THEME_SLOTS.map((slot2, index3) => [slot2, `#${themeColor(theme2, index3) ?? "000000"}`])
|
|
34956
35657
|
);
|
|
34957
35658
|
return {
|
|
34958
35659
|
...slots,
|
|
@@ -34971,8 +35672,8 @@ function modulateLuminance(hex, lumMod, lumOff = 0) {
|
|
|
34971
35672
|
const out = hslToRgb(hsl.h, hsl.s, l);
|
|
34972
35673
|
return rgbToUpperHex([out.r, out.g, out.b]);
|
|
34973
35674
|
}
|
|
34974
|
-
function autoSeriesColor(theme2,
|
|
34975
|
-
const i2 = Math.max(0, Math.floor(
|
|
35675
|
+
function autoSeriesColor(theme2, index3) {
|
|
35676
|
+
const i2 = Math.max(0, Math.floor(index3));
|
|
34976
35677
|
return chartPaletteSeriesColor(findChartColorPalette(10), i2, i2 + 1, chartColorScheme(theme2));
|
|
34977
35678
|
}
|
|
34978
35679
|
|
|
@@ -35124,10 +35825,10 @@ function resolveChartStyleDefinition(style2, resolve2) {
|
|
|
35124
35825
|
var NATIVE_COINCIDENT_STOP_RAMP = 1 / 256;
|
|
35125
35826
|
function spreadCoincidentStops(stops) {
|
|
35126
35827
|
const out = [];
|
|
35127
|
-
for (const [
|
|
35128
|
-
const source2 = stops[
|
|
35828
|
+
for (const [index3, stop] of stops.entries()) {
|
|
35829
|
+
const source2 = stops[index3 - 1];
|
|
35129
35830
|
const previous = out.at(-1);
|
|
35130
|
-
const next = stops[
|
|
35831
|
+
const next = stops[index3 + 1];
|
|
35131
35832
|
if (!source2 || !previous || stop.offset !== source2.offset || stop.color === source2.color && (stop.opacity ?? 1) === (source2.opacity ?? 1)) {
|
|
35132
35833
|
out.push(stop);
|
|
35133
35834
|
continue;
|
|
@@ -35377,9 +36078,9 @@ function resolveRef(ref, evaluateRef) {
|
|
|
35377
36078
|
return void 0;
|
|
35378
36079
|
}
|
|
35379
36080
|
}
|
|
35380
|
-
function seriesName(series,
|
|
36081
|
+
function seriesName(series, index3, evaluateRef) {
|
|
35381
36082
|
const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText2).filter((t) => t !== "").join(" ");
|
|
35382
|
-
return fromRef || series.name || `Series${
|
|
36083
|
+
return fromRef || series.name || `Series${index3 + 1}`;
|
|
35383
36084
|
}
|
|
35384
36085
|
function chartSummaryView(chart, theme2, options = {}) {
|
|
35385
36086
|
const evaluateRef = options.evaluateRef ?? (() => []);
|
|
@@ -35449,8 +36150,8 @@ function chartSummaryView(chart, theme2, options = {}) {
|
|
|
35449
36150
|
const points = chart.series[seriesIndex]?.pointColors;
|
|
35450
36151
|
if (points) s.pointColors = s.values.map((_, i2) => drawingColor(points[i2]) ?? s.color);
|
|
35451
36152
|
});
|
|
35452
|
-
series.forEach((s,
|
|
35453
|
-
const source2 = chart.series[
|
|
36153
|
+
series.forEach((s, index3) => {
|
|
36154
|
+
const source2 = chart.series[index3];
|
|
35454
36155
|
if (s.gradient && !radial && s.pointColors) {
|
|
35455
36156
|
for (let i2 = 0; i2 < s.pointColors.length; i2++)
|
|
35456
36157
|
if (!source2.pointColors?.[i2]) delete s.pointColors[i2];
|
|
@@ -35604,15 +36305,15 @@ function chartGradientPaint(model, width = 1024, height = 768) {
|
|
|
35604
36305
|
fillColor: paint(entry3.gradient, part, { width, height, shape: "rect" })
|
|
35605
36306
|
};
|
|
35606
36307
|
}
|
|
35607
|
-
const series = model.series.map((source2,
|
|
36308
|
+
const series = model.series.map((source2, index3) => {
|
|
35608
36309
|
const view = { ...source2 };
|
|
35609
|
-
if (source2.shadow) view.shadowFilter = shadowPaint(source2.shadow, `s${
|
|
36310
|
+
if (source2.shadow) view.shadowFilter = shadowPaint(source2.shadow, `s${index3}-shadow`);
|
|
35610
36311
|
const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
|
|
35611
|
-
if (source2.gradient) view.color = paint(source2.gradient, `s${
|
|
36312
|
+
if (source2.gradient) view.color = paint(source2.gradient, `s${index3}`, bounds);
|
|
35612
36313
|
if (source2.pointGradients) {
|
|
35613
36314
|
view.pointColors = [...source2.pointColors ?? []];
|
|
35614
36315
|
for (const [key, gradient] of Object.entries(source2.pointGradients))
|
|
35615
|
-
view.pointColors[Number(key)] = paint(gradient, `s${
|
|
36316
|
+
view.pointColors[Number(key)] = paint(gradient, `s${index3}-p${key}`, bounds);
|
|
35616
36317
|
}
|
|
35617
36318
|
return view;
|
|
35618
36319
|
});
|
|
@@ -36264,8 +36965,8 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36264
36965
|
hardLines.push(line3);
|
|
36265
36966
|
for (const run2 of paragraph2.runs) {
|
|
36266
36967
|
const pieces = run2.text.split("\n");
|
|
36267
|
-
for (const [
|
|
36268
|
-
if (
|
|
36968
|
+
for (const [index3, piece] of pieces.entries()) {
|
|
36969
|
+
if (index3) {
|
|
36269
36970
|
line3 = { ...paragraph2, runs: [] };
|
|
36270
36971
|
hardLines.push(line3);
|
|
36271
36972
|
}
|
|
@@ -36289,11 +36990,11 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36289
36990
|
{ breakWords: true }
|
|
36290
36991
|
);
|
|
36291
36992
|
const { spaceBefore, spaceAfter, ...properties2 } = line3;
|
|
36292
|
-
return wrapped.map((runs,
|
|
36993
|
+
return wrapped.map((runs, index3) => ({
|
|
36293
36994
|
...properties2,
|
|
36294
36995
|
runs,
|
|
36295
|
-
...
|
|
36296
|
-
...
|
|
36996
|
+
...index3 === 0 && spaceBefore ? { spaceBefore } : {},
|
|
36997
|
+
...index3 === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
|
|
36297
36998
|
}));
|
|
36298
36999
|
});
|
|
36299
37000
|
const metrics = lines.map((line3) => {
|
|
@@ -36338,9 +37039,9 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36338
37039
|
);
|
|
36339
37040
|
let baseline = 8 + (metrics[0]?.size ?? base.size ?? 14) + (vertical[0]?.before ?? 0) + (vertical[0]?.leading ?? 0);
|
|
36340
37041
|
const spans2 = [];
|
|
36341
|
-
for (const [
|
|
36342
|
-
if (
|
|
36343
|
-
baseline += vertical[
|
|
37042
|
+
for (const [index3, line3] of metrics.entries()) {
|
|
37043
|
+
if (index3)
|
|
37044
|
+
baseline += vertical[index3 - 1].descent + vertical[index3 - 1].after + vertical[index3].before + vertical[index3].ascent;
|
|
36344
37045
|
let x = line3.align === "l" ? (width - boxWidth) / 2 + 4 : line3.align === "r" ? (width + boxWidth) / 2 - 4 - line3.width : (width - line3.width) / 2;
|
|
36345
37046
|
for (const run2 of line3.runs) {
|
|
36346
37047
|
spans2.push(
|
|
@@ -36731,19 +37432,19 @@ function chunks(indices, size, capacity, breaks) {
|
|
|
36731
37432
|
const out = [];
|
|
36732
37433
|
let line3 = [];
|
|
36733
37434
|
let extent2 = 0;
|
|
36734
|
-
for (const
|
|
37435
|
+
for (const index3 of indices) {
|
|
36735
37436
|
let manual = false;
|
|
36736
|
-
while (cursor < sorted2.length && sorted2[cursor] <=
|
|
37437
|
+
while (cursor < sorted2.length && sorted2[cursor] <= index3) {
|
|
36737
37438
|
cursor++;
|
|
36738
37439
|
manual = true;
|
|
36739
37440
|
}
|
|
36740
|
-
if (line3.length && (manual || extent2 + size(
|
|
37441
|
+
if (line3.length && (manual || extent2 + size(index3) > capacity + 1e-3)) {
|
|
36741
37442
|
out.push(line3);
|
|
36742
37443
|
line3 = [];
|
|
36743
37444
|
extent2 = 0;
|
|
36744
37445
|
}
|
|
36745
|
-
line3.push(
|
|
36746
|
-
extent2 += size(
|
|
37446
|
+
line3.push(index3);
|
|
37447
|
+
extent2 += size(index3);
|
|
36747
37448
|
}
|
|
36748
37449
|
if (line3.length) out.push(line3);
|
|
36749
37450
|
return out;
|
|
@@ -37121,6 +37822,8 @@ exports.patchStyle = patchStyle;
|
|
|
37121
37822
|
exports.percentile = percentile;
|
|
37122
37823
|
exports.pictureAnchorAt = pictureAnchorAt;
|
|
37123
37824
|
exports.pivotGrid = pivotGrid;
|
|
37825
|
+
exports.pivotPageItemLabel = pivotItemLabel;
|
|
37826
|
+
exports.pivotPageItems = pivotPageItems;
|
|
37124
37827
|
exports.pivotSourceData = pivotSourceData;
|
|
37125
37828
|
exports.pivotTableAt = pivotTableAt;
|
|
37126
37829
|
exports.pixelBoxToAnchor = pixelBoxToAnchor;
|