ooxml-core 1.10.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-ADEFY476.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
- package/dist/automation/index.cjs +3293 -2867
- package/dist/automation/index.mjs +3293 -2867
- package/dist/{chunk-3N6XMMTT.cjs → chunk-2UVH6RHI.cjs} +1138 -996
- package/dist/{chunk-ZOUGMAZG.mjs → chunk-7DSZI7S6.mjs} +1 -1
- package/dist/{chunk-S6DOCMQC.cjs → chunk-7QZGRB3T.cjs} +0 -10
- package/dist/chunk-ANZ4Q6I3.cjs +21 -0
- package/dist/{chunk-5NVJN4E6.mjs → chunk-EC2W2MDY.mjs} +1 -1
- package/dist/chunk-EGTRL3QJ.mjs +19 -0
- package/dist/chunk-GXHKNSZX.mjs +9 -0
- package/dist/{chunk-CCHYFCPD.mjs → chunk-HCXUI5UC.mjs} +296 -103
- package/dist/chunk-HDQXPSHY.cjs +17 -0
- package/dist/chunk-KTYBFGEY.mjs +14 -0
- package/dist/chunk-QOO36KG4.cjs +42 -0
- package/dist/chunk-R2KZXD6U.mjs +39 -0
- package/dist/{chunk-A6P7G3UK.mjs → chunk-U2DF3EGK.mjs} +1 -1
- package/dist/{chunk-R6KSBNKX.mjs → chunk-UAY26XOI.mjs} +1 -9
- package/dist/{chunk-WUE5ZHU3.mjs → chunk-W5ARCUJB.mjs} +3 -3
- package/dist/chunk-XZPZHXV4.cjs +12 -0
- package/dist/{chunk-ZE53K7DH.mjs → chunk-YB5SRNFS.mjs} +244 -102
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +125 -56
- package/dist/docx/layout/index.mjs +125 -56
- 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/result.d.ts +7 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/table-border-layout.d.ts +1 -1
- package/dist/docx/layout/table-border-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-frames.d.ts.map +1 -1
- package/dist/docx/layout/table-layout.d.ts +1 -1
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/pptx/automation/index.cjs +266 -114
- package/dist/pptx/automation/index.d.ts +5 -4
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{text-operations-BqHmLaLA.d.ts → elements-DD3UGOMd.d.ts} +17 -3262
- package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-DUCGeZh7.d.ts → index-BZrFyNtU.d.ts} +53 -5
- package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-Cuxtr76Y.d.ts → index-DdX02BSm.d.ts} +5 -3
- package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +266 -114
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +17 -16
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +2 -1
- package/dist/pptx/editor/render/font-family-update.cjs +14 -0
- package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
- package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
- package/dist/pptx/editor/render/font-family-update.mjs +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
- package/dist/pptx/editor/render/slide-operations.cjs +9 -8
- package/dist/pptx/editor/render/slide-operations.mjs +3 -2
- package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
- package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
- package/dist/pptx/editor/render/text-content-style.cjs +18 -0
- package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
- package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-content-style.mjs +5 -0
- package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
- package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
- package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
- package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
- package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
- package/dist/pptx/index.cjs +329 -114
- package/dist/pptx/index.d.ts +7 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/teams/index.cjs +112 -16
- package/dist/teams/index.mjs +112 -16
- package/dist/visio/edit-commands.d.ts +3 -3
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-text-field-commands.d.ts +15 -0
- package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
- package/dist/visio/edit-text-field.d.ts +2 -2
- package/dist/visio/edit-text-field.d.ts.map +1 -1
- package/dist/visio/edit.d.ts +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +382 -210
- package/dist/visio/index.d.ts +1 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +382 -210
- package/dist/visio/model.d.ts +6 -0
- package/dist/visio/model.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-independent.d.ts +4 -0
- package/dist/visio/text-field-independent.d.ts.map +1 -0
- package/dist/visio/text-field-source.d.ts +6 -0
- package/dist/visio/text-field-source.d.ts.map +1 -0
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +394 -211
- package/dist/visio/ui/index.mjs +394 -211
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +773 -514
- package/dist/xlsx/index.mjs +772 -515
- package/dist/xlsx/load/index.cjs +541 -292
- package/dist/xlsx/load/index.mjs +541 -292
- package/dist/xlsx/model-pivots.d.ts +8 -0
- package/dist/xlsx/model-pivots.d.ts.map +1 -1
- package/dist/xlsx/pivot/admission.d.ts.map +1 -1
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
- package/dist/xlsx/pivot/data.d.ts +2 -2
- package/dist/xlsx/pivot/data.d.ts.map +1 -1
- package/dist/xlsx/pivot/index.d.ts +2 -0
- package/dist/xlsx/pivot/index.d.ts.map +1 -1
- package/dist/xlsx/pivot/measures.d.ts +1 -1
- package/dist/xlsx/pivot/measures.d.ts.map +1 -1
- package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
- package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
- package/dist/xlsx/pivot/page-filter.d.ts +11 -0
- package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
- package/dist/xlsx/pivot/read.d.ts.map +1 -1
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
- package/dist/xlsx/pivot/values-axis.d.ts +4 -1
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +95 -12
- package/dist/xlsx/ui/index.mjs +95 -12
- package/package.json +2 -2
- package/dist/PptxHandler-5UURGJEV.mjs +0 -2
- package/dist/PptxHandler-U5XB2HUE.cjs +0 -11
- package/dist/pptx/chunks/index-Cuxtr76Y.d.ts.map +0 -1
- package/dist/pptx/chunks/index-DUCGeZh7.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts +0 -2980
- package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BqHmLaLA.d.ts.map +0 -1
package/dist/xlsx/index.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,6 +15126,7 @@ 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] : [],
|
|
@@ -15105,11 +15199,11 @@ function pivotHeaderDimensions(pivot, columnItems, rowLabels) {
|
|
|
15105
15199
|
const measures = 1 + (pivot.additionalValues?.length ?? 0);
|
|
15106
15200
|
if (pivot.valuesAxis === "rows")
|
|
15107
15201
|
return {
|
|
15108
|
-
rows: pivot.columnField ? 2 : 1,
|
|
15202
|
+
rows: (pivot.columnField ? 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
15109
15203
|
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
15110
15204
|
};
|
|
15111
15205
|
return {
|
|
15112
|
-
rows: pivot.columnField ? measures > 1 ? 3 : 2 : 1,
|
|
15206
|
+
rows: (pivot.columnField ? measures > 1 ? 3 : 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
15113
15207
|
width: rowLabels + (pivot.columnField ? measures === 1 ? Math.max(1, columnItems) + 1 : (columnItems + 1) * measures : measures)
|
|
15114
15208
|
};
|
|
15115
15209
|
}
|
|
@@ -15253,7 +15347,7 @@ function hierarchicalPivotGrid(pivot) {
|
|
|
15253
15347
|
const groups = /* @__PURE__ */ new Map();
|
|
15254
15348
|
const details = /* @__PURE__ */ new Map();
|
|
15255
15349
|
const children2 = /* @__PURE__ */ new Map();
|
|
15256
|
-
const innerIndices = new Map(secondRowItems.map((item,
|
|
15350
|
+
const innerIndices = new Map(secondRowItems.map((item, index3) => [pivotValueKey(item), index3]));
|
|
15257
15351
|
const buckets = /* @__PURE__ */ new Map();
|
|
15258
15352
|
const collect2 = (map, key, record) => {
|
|
15259
15353
|
const list = map.get(key);
|
|
@@ -15445,6 +15539,9 @@ function hierarchicalPivotGrid(pivot) {
|
|
|
15445
15539
|
// xlsx/pivot/aggregate.ts
|
|
15446
15540
|
function pivotGrid(pivot) {
|
|
15447
15541
|
validatePivotFields(pivot);
|
|
15542
|
+
return prependPivotPage(pivotDataGrid(pivotPageProjection(pivot)), pivot);
|
|
15543
|
+
}
|
|
15544
|
+
function pivotDataGrid(pivot) {
|
|
15448
15545
|
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
15449
15546
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
15450
15547
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
@@ -15486,7 +15583,7 @@ function pivotGrid(pivot) {
|
|
|
15486
15583
|
const measures = pivotMeasures(pivot);
|
|
15487
15584
|
const rowEntries = [];
|
|
15488
15585
|
const indents = values2.map(() => 0);
|
|
15489
|
-
const append = (caption, bands,
|
|
15586
|
+
const append = (caption, bands, index3, grand = false) => {
|
|
15490
15587
|
measures.forEach((measure, m) => {
|
|
15491
15588
|
values2.push([
|
|
15492
15589
|
...compact3 ? [grand ? `Total ${measure.caption}` : measure.caption] : [
|
|
@@ -15497,17 +15594,17 @@ function pivotGrid(pivot) {
|
|
|
15497
15594
|
]);
|
|
15498
15595
|
indents.push(compact3 && !grand ? 1 : 0);
|
|
15499
15596
|
rowEntries.push({
|
|
15500
|
-
indices: grand ? [0] : [
|
|
15597
|
+
indices: grand ? [0] : [index3, m],
|
|
15501
15598
|
measure: m,
|
|
15502
15599
|
...grand ? { type: "grand" } : {}
|
|
15503
15600
|
});
|
|
15504
15601
|
});
|
|
15505
15602
|
};
|
|
15506
|
-
rowItems.forEach((item,
|
|
15603
|
+
rowItems.forEach((item, index3) => {
|
|
15507
15604
|
const key = pivotValueKey(item);
|
|
15508
15605
|
if (headings) {
|
|
15509
15606
|
values2.push([label3(item), ...Array(dimensions.width - 1).fill(null)]);
|
|
15510
|
-
rowEntries.push({ indices: [
|
|
15607
|
+
rowEntries.push({ indices: [index3] });
|
|
15511
15608
|
indents.push(0);
|
|
15512
15609
|
}
|
|
15513
15610
|
append(
|
|
@@ -15518,7 +15615,7 @@ function pivotGrid(pivot) {
|
|
|
15518
15615
|
),
|
|
15519
15616
|
pivotNumbers(pivot, groups.get(key) ?? [])
|
|
15520
15617
|
],
|
|
15521
|
-
|
|
15618
|
+
index3
|
|
15522
15619
|
);
|
|
15523
15620
|
});
|
|
15524
15621
|
append(
|
|
@@ -15570,7 +15667,9 @@ var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
|
15570
15667
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
15571
15668
|
var TABLE = {
|
|
15572
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",
|
|
15573
|
-
location: "ref firstHeaderRow firstDataRow firstDataCol",
|
|
15670
|
+
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
15671
|
+
pageFields: "count",
|
|
15672
|
+
pageField: "fld item hier",
|
|
15574
15673
|
pivotFields: "count",
|
|
15575
15674
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal",
|
|
15576
15675
|
items: "count",
|
|
@@ -15705,6 +15804,18 @@ function inlineFragment(xml) {
|
|
|
15705
15804
|
}
|
|
15706
15805
|
|
|
15707
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
|
+
}
|
|
15708
15819
|
function pivotFieldIndex(field) {
|
|
15709
15820
|
const raw2 = field?.getAttribute("x");
|
|
15710
15821
|
if (raw2 === null || raw2 === void 0 || !/^-?\d+$/.test(raw2.trim())) return NaN;
|
|
@@ -15712,15 +15823,15 @@ function pivotFieldIndex(field) {
|
|
|
15712
15823
|
return Number.isSafeInteger(value2) ? value2 : NaN;
|
|
15713
15824
|
}
|
|
15714
15825
|
function pivotValueIndex(root, axis) {
|
|
15715
|
-
const
|
|
15826
|
+
const index3 = axis.findIndex((field) => pivotFieldIndex(field) === -2);
|
|
15716
15827
|
const position = root.getAttribute("dataPosition");
|
|
15717
|
-
if (position !== null && (!/^\d+$/.test(position.trim()) || Number(position) !==
|
|
15828
|
+
if (position !== null && (!/^\d+$/.test(position.trim()) || Number(position) !== index3))
|
|
15718
15829
|
throw new Error("Inconsistent Values axis position");
|
|
15719
|
-
if (axis.length === 3 &&
|
|
15830
|
+
if (axis.length === 3 && index3 < 2 && position === null)
|
|
15720
15831
|
throw new Error("Missing leading or between-field Values position");
|
|
15721
|
-
return
|
|
15832
|
+
return index3;
|
|
15722
15833
|
}
|
|
15723
|
-
function pivotValueAxisItems(measures, columns) {
|
|
15834
|
+
function pivotValueAxisItems(measures, columns, columnIndices) {
|
|
15724
15835
|
const entries = [];
|
|
15725
15836
|
if (columns === void 0) {
|
|
15726
15837
|
for (let measure = 0; measure < measures; measure++)
|
|
@@ -15731,7 +15842,7 @@ function pivotValueAxisItems(measures, columns) {
|
|
|
15731
15842
|
for (let column = 0; column < columns; column++)
|
|
15732
15843
|
for (let measure = 0; measure < measures; measure++) {
|
|
15733
15844
|
entries.push(
|
|
15734
|
-
`<i${attrs({ r: measure ? 1 : void 0, i: measure || void 0 })}>${measure ? "" : `<x${attrs({ v: column || void 0 })}/>`}<x${attrs({ v: measure || void 0 })}/></i>`
|
|
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>`
|
|
15735
15846
|
);
|
|
15736
15847
|
}
|
|
15737
15848
|
for (let measure = 0; measure < measures; measure++)
|
|
@@ -15740,11 +15851,169 @@ function pivotValueAxisItems(measures, columns) {
|
|
|
15740
15851
|
return `<colItems count="${entries.length}">${entries.join("")}</colItems>`;
|
|
15741
15852
|
}
|
|
15742
15853
|
function supportedPivotAxes(rows, columns, measures, valuesOnRows) {
|
|
15743
|
-
const
|
|
15854
|
+
const index3 = pivotFieldIndex;
|
|
15744
15855
|
if (valuesOnRows)
|
|
15745
|
-
return measures > 1 && (rows.length === 2 || rows.length === 3) && (
|
|
15746
|
-
if (rows.some((field) => !Number.isInteger(
|
|
15747
|
-
return measures === 1 ? columns.length <= 1 : columns.length >= 1 && columns.length <= 2 &&
|
|
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
|
+
});
|
|
15748
16017
|
}
|
|
15749
16018
|
|
|
15750
16019
|
// xlsx/pivot/read.ts
|
|
@@ -15784,20 +16053,21 @@ function readOne(workbook, source2, part) {
|
|
|
15784
16053
|
const rowsAxis = att(root, "dataOnRows") === "1";
|
|
15785
16054
|
if (!dataSheet || !dataRange || !recordPart || !workbook.sheets.some((sheet) => sheet.name === dataSheet))
|
|
15786
16055
|
throw new Error("Unsupported pivot source");
|
|
15787
|
-
|
|
16056
|
+
const recordRoot = parseXml(source2.text(recordPart)).documentElement;
|
|
16057
|
+
assertPivotRecords(recordRoot);
|
|
15788
16058
|
const fields = children(first(cache3, "cacheFields", NS.x), "cacheField", NS.x);
|
|
15789
16059
|
if (fields.some((field) => first(field, "fieldGroup", NS.x) || field.hasAttribute("formula")))
|
|
15790
16060
|
throw new Error("Grouped or calculated cache field");
|
|
15791
16061
|
const shared = fields.map(
|
|
15792
16062
|
(field) => elements(first(field, "sharedItems", NS.x) ?? parseXml("<root/>").documentElement).map(value)
|
|
15793
16063
|
);
|
|
15794
|
-
const records = children(
|
|
16064
|
+
const records = children(recordRoot, "r", NS.x).map(
|
|
15795
16065
|
(record) => elements(record).map((node, field) => {
|
|
15796
16066
|
if (node.localName !== "x") return value(node);
|
|
15797
|
-
const
|
|
15798
|
-
if (!Number.isInteger(
|
|
16067
|
+
const index3 = Number(att(node, "v"));
|
|
16068
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= (shared[field]?.length ?? 0))
|
|
15799
16069
|
throw new Error("Invalid pivot cache index");
|
|
15800
|
-
return shared[field][
|
|
16070
|
+
return shared[field][index3];
|
|
15801
16071
|
})
|
|
15802
16072
|
);
|
|
15803
16073
|
if (records.some((record) => record.length !== fields.length) || records.length * fields.length > 1e6)
|
|
@@ -15817,7 +16087,7 @@ function readOne(workbook, source2, part) {
|
|
|
15817
16087
|
"dataField",
|
|
15818
16088
|
NS.x
|
|
15819
16089
|
);
|
|
15820
|
-
if (rowFields.length < 1 || rowFields.length > (rowsAxis ? 3 : 2) || dataFields.length < 1 || dataFields.length > 16 || !supportedPivotAxes(rowFields, colFields, dataFields.length, rowsAxis) || first(root, "
|
|
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")
|
|
15821
16091
|
throw new Error("Unsupported pivot layout");
|
|
15822
16092
|
const valueIndex = pivotValueIndex(root, rowsAxis ? rowFields : colFields);
|
|
15823
16093
|
const measure = dataFields[0];
|
|
@@ -15839,8 +16109,8 @@ function readOne(workbook, source2, part) {
|
|
|
15839
16109
|
"i",
|
|
15840
16110
|
NS.x
|
|
15841
16111
|
)) {
|
|
15842
|
-
const
|
|
15843
|
-
if (!Number.isInteger(
|
|
16112
|
+
const index3 = Number(att(item, "i") ?? "0");
|
|
16113
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= count2)
|
|
15844
16114
|
throw new Error("Unsupported Values axis item");
|
|
15845
16115
|
}
|
|
15846
16116
|
}
|
|
@@ -15851,6 +16121,7 @@ function readOne(workbook, source2, part) {
|
|
|
15851
16121
|
const realRows = rowsAxis ? rowFields.filter((field) => pivotFieldIndex(field) !== -2) : rowFields;
|
|
15852
16122
|
const row2 = names[pivotFieldIndex(realRows[0])];
|
|
15853
16123
|
const second = realRows[1] ? names[Number(att(realRows[1], "x"))] : void 0;
|
|
16124
|
+
const pageFilter = readPivotPageFilter(root, names, shared);
|
|
15854
16125
|
const tableFields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
15855
16126
|
const outer = tableFields[pivotFieldIndex(realRows[0])];
|
|
15856
16127
|
const compact3 = att(outer, "compact") !== "0";
|
|
@@ -15880,7 +16151,12 @@ function readOne(workbook, source2, part) {
|
|
|
15880
16151
|
const location = parseRange(att(first(root, "location", NS.x), "ref") ?? "");
|
|
15881
16152
|
if (!row2 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
|
|
15882
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
|
+
}
|
|
15883
16158
|
const pivot = {
|
|
16159
|
+
...pageFilter ? { pageFilter } : {},
|
|
15884
16160
|
name: att(root, "name") ?? "PivotTable",
|
|
15885
16161
|
source: `${quoteSheetName(dataSheet)}!${formatRange(dataRange)}`,
|
|
15886
16162
|
rowField: row2,
|
|
@@ -15912,6 +16188,7 @@ function readOne(workbook, source2, part) {
|
|
|
15912
16188
|
sourceXml: xml,
|
|
15913
16189
|
...col ? { columnField: col } : {}
|
|
15914
16190
|
};
|
|
16191
|
+
assertPageAxisItems(root, pivot, shared, cache3, recordRoot);
|
|
15915
16192
|
return pivot;
|
|
15916
16193
|
}
|
|
15917
16194
|
function readPivotTables(workbook, source2, warn) {
|
|
@@ -16237,10 +16514,10 @@ function parseDynamicArrayMetadata(xml) {
|
|
|
16237
16514
|
const flag2 = props?.getAttribute("fDynamic");
|
|
16238
16515
|
return flag2 === "1" || flag2 === "true";
|
|
16239
16516
|
});
|
|
16240
|
-
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk,
|
|
16517
|
+
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk, index3) => {
|
|
16241
16518
|
for (const rc of childrenNamed(bk, "rc")) {
|
|
16242
16519
|
const type = types[Number(att(rc, "t")) - 1];
|
|
16243
|
-
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);
|
|
16244
16521
|
}
|
|
16245
16522
|
});
|
|
16246
16523
|
return out;
|
|
@@ -16518,13 +16795,13 @@ function parseStyles(xml, warnings) {
|
|
|
16518
16795
|
const named2 = namesByXf.get(xfId);
|
|
16519
16796
|
if (named2 && xfId !== 0 && named2 !== "Normal") style2.cellStyleName = named2;
|
|
16520
16797
|
const key = styleKey(style2);
|
|
16521
|
-
let
|
|
16522
|
-
if (
|
|
16523
|
-
|
|
16798
|
+
let index3 = keys.get(key);
|
|
16799
|
+
if (index3 === void 0) {
|
|
16800
|
+
index3 = styles.length;
|
|
16524
16801
|
styles.push(style2);
|
|
16525
|
-
keys.set(key,
|
|
16802
|
+
keys.set(key, index3);
|
|
16526
16803
|
}
|
|
16527
|
-
xfMap.push(
|
|
16804
|
+
xfMap.push(index3);
|
|
16528
16805
|
}
|
|
16529
16806
|
if (!styles.length) {
|
|
16530
16807
|
styles.push(fallback);
|
|
@@ -16933,11 +17210,11 @@ function sigmaGradientStops(stops) {
|
|
|
16933
17210
|
const front = hexToRgbChannels(stops[0].color);
|
|
16934
17211
|
const back = hexToRgbChannels(stops[1].color);
|
|
16935
17212
|
if (!front || !back) return void 0;
|
|
16936
|
-
return OFFICE_SIGMA_FACTORS.map((value2,
|
|
17213
|
+
return OFFICE_SIGMA_FACTORS.map((value2, index3) => {
|
|
16937
17214
|
const factor = value2 / 65536;
|
|
16938
17215
|
const mix = (a2, b) => toHex(255 * ((a2 / 255) ** 2.2 * (1 - factor) + (b / 255) ** 2.2 * factor) ** (1 / 2.2));
|
|
16939
17216
|
return {
|
|
16940
|
-
offset: Math.fround(
|
|
17217
|
+
offset: Math.fround(index3 / 255),
|
|
16941
17218
|
color: `#${mix(front.r, back.r)}${mix(front.g, back.g)}${mix(front.b, back.b)}`,
|
|
16942
17219
|
opacity: 1
|
|
16943
17220
|
};
|
|
@@ -16954,47 +17231,6 @@ function parseArgbHex(hex) {
|
|
|
16954
17231
|
var clamp255 = (v) => Math.max(0, Math.min(255, v));
|
|
16955
17232
|
var rgbToUpperHex = (rgb2) => `#${rgb2.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
16956
17233
|
|
|
16957
|
-
// drawingml/dom.ts
|
|
16958
|
-
function attributeReader(element2) {
|
|
16959
|
-
return (name) => {
|
|
16960
|
-
if (!element2) return void 0;
|
|
16961
|
-
const direct = element2.getAttribute(name);
|
|
16962
|
-
if (direct !== null) return direct;
|
|
16963
|
-
const attributes = element2.attributes;
|
|
16964
|
-
for (let index2 = 0; index2 < attributes.length; index2++) {
|
|
16965
|
-
const candidate = attributes.item(index2);
|
|
16966
|
-
if (candidate && candidate.localName === name) return candidate.value;
|
|
16967
|
-
}
|
|
16968
|
-
return void 0;
|
|
16969
|
-
};
|
|
16970
|
-
}
|
|
16971
|
-
function stringAttribute(element2, name) {
|
|
16972
|
-
const value2 = attributeReader(element2)(name)?.trim();
|
|
16973
|
-
return value2 ? value2 : void 0;
|
|
16974
|
-
}
|
|
16975
|
-
function integerAttribute(element2, name) {
|
|
16976
|
-
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
16977
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
16978
|
-
}
|
|
16979
|
-
function booleanAttribute(element2, name) {
|
|
16980
|
-
const value2 = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
16981
|
-
if (value2 === "1" || value2 === "true") return true;
|
|
16982
|
-
if (value2 === "0" || value2 === "false") return false;
|
|
16983
|
-
return void 0;
|
|
16984
|
-
}
|
|
16985
|
-
function descendants2(root, local) {
|
|
16986
|
-
const result2 = [];
|
|
16987
|
-
const visit2 = (node) => {
|
|
16988
|
-
for (const child3 of Array.from(node.childNodes)) {
|
|
16989
|
-
if (!isElement(child3)) continue;
|
|
16990
|
-
if (child3.localName === local) result2.push(child3);
|
|
16991
|
-
visit2(child3);
|
|
16992
|
-
}
|
|
16993
|
-
};
|
|
16994
|
-
visit2(root);
|
|
16995
|
-
return result2;
|
|
16996
|
-
}
|
|
16997
|
-
|
|
16998
17234
|
// drawingml/ordered-color-transforms.ts
|
|
16999
17235
|
function orderedColorTransforms(channels, transforms) {
|
|
17000
17236
|
let { r, g: g2, b } = channels;
|
|
@@ -17316,7 +17552,7 @@ function parseTheme2(xml) {
|
|
|
17316
17552
|
if (!xml) return palette;
|
|
17317
17553
|
const theme2 = parseTheme(parseXml(xml, { label: "XLSX theme" }));
|
|
17318
17554
|
palette.colors = PALETTE_SLOTS.map(
|
|
17319
|
-
(slot2,
|
|
17555
|
+
(slot2, index3) => paletteHex(theme2.colorScheme.colors[slot2]) ?? DEFAULT_THEME.colors[index3] ?? "000000"
|
|
17320
17556
|
);
|
|
17321
17557
|
palette.majorFont = theme2.fontScheme.major.latin ?? palette.majorFont;
|
|
17322
17558
|
palette.minorFont = theme2.fontScheme.minor.latin ?? palette.minorFont;
|
|
@@ -17499,11 +17735,11 @@ function readModernHash(node, prefix = "") {
|
|
|
17499
17735
|
function parseWorkbookPart(xml) {
|
|
17500
17736
|
const root = parseXml(xml, { label: "XLSX workbook" }).documentElement;
|
|
17501
17737
|
const sheets = [];
|
|
17502
|
-
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node,
|
|
17738
|
+
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node, index3) => {
|
|
17503
17739
|
const state = att(node, "state");
|
|
17504
17740
|
sheets.push({
|
|
17505
|
-
name: att(node, "name") ?? `Sheet${
|
|
17506
|
-
sheetId: numAttr(node, "sheetId") ??
|
|
17741
|
+
name: att(node, "name") ?? `Sheet${index3 + 1}`,
|
|
17742
|
+
sheetId: numAttr(node, "sheetId") ?? index3 + 1,
|
|
17507
17743
|
state: state === "hidden" || state === "veryHidden" ? state : "visible",
|
|
17508
17744
|
relId: relAttr(node, "id") ?? ""
|
|
17509
17745
|
});
|
|
@@ -17853,8 +18089,8 @@ function styleRef(element2) {
|
|
|
17853
18089
|
if (element2.localName === "fontRef") {
|
|
17854
18090
|
if (raw2) ref.fontIndex = raw2;
|
|
17855
18091
|
} else {
|
|
17856
|
-
const
|
|
17857
|
-
if (Number.isFinite(
|
|
18092
|
+
const index3 = Number.parseInt(raw2 ?? "", 10);
|
|
18093
|
+
if (Number.isFinite(index3)) ref.index = index3;
|
|
17858
18094
|
}
|
|
17859
18095
|
const color = parseDrawingColorIn(element2);
|
|
17860
18096
|
if (color) ref.color = color;
|
|
@@ -18242,11 +18478,11 @@ function groupTransform(group, parent) {
|
|
|
18242
18478
|
scaleY: parent.scaleY * local.scaleY
|
|
18243
18479
|
};
|
|
18244
18480
|
}
|
|
18245
|
-
function parseShape(sp,
|
|
18481
|
+
function parseShape(sp, index3, group, issues) {
|
|
18246
18482
|
const spPr = first(sp, "spPr", NS.dsp);
|
|
18247
18483
|
const transform6 = parseTransform(first(spPr, "xfrm", NS.a));
|
|
18248
18484
|
if (!transform6) return void 0;
|
|
18249
|
-
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}`;
|
|
18250
18486
|
const { geometry, adjustments, paths, issue } = parseDrawingGeometry(spPr);
|
|
18251
18487
|
if (issue) issues.push({ code: issue, message: `Shape ${modelId}: ${issue}.` });
|
|
18252
18488
|
const frame = applyGroup(transform6.frame, group);
|
|
@@ -18464,8 +18700,8 @@ function drawingFillXml(fill) {
|
|
|
18464
18700
|
const stops = children(list, "gs", NS.a).filter(
|
|
18465
18701
|
(node) => parseDrawingColorIn(node) && Number.isFinite(Number.parseInt(node.getAttribute("pos") ?? "", 10))
|
|
18466
18702
|
);
|
|
18467
|
-
fill.stops.forEach((stop,
|
|
18468
|
-
const node = stops[
|
|
18703
|
+
fill.stops.forEach((stop, index3) => {
|
|
18704
|
+
const node = stops[index3] ?? doc.createElementNS(NS.a, "a:gs");
|
|
18469
18705
|
if (!node.parentNode) list.appendChild(node);
|
|
18470
18706
|
node.setAttribute("pos", String(Math.round(stop.position * 1e3)));
|
|
18471
18707
|
for (const old of elements(node))
|
|
@@ -18823,8 +19059,8 @@ var OFFICE_GRADIENT_PRESET_DATA = [
|
|
|
18823
19059
|
];
|
|
18824
19060
|
|
|
18825
19061
|
// drawingml/gradient-presets.ts
|
|
18826
|
-
OFFICE_GRADIENT_PRESET_DATA.map(([label3],
|
|
18827
|
-
id:
|
|
19062
|
+
OFFICE_GRADIENT_PRESET_DATA.map(([label3], index3) => ({
|
|
19063
|
+
id: index3 + 1,
|
|
18828
19064
|
label: label3
|
|
18829
19065
|
}));
|
|
18830
19066
|
function officeGradientPresetFill(id) {
|
|
@@ -19441,8 +19677,8 @@ function writeSettings(node, rule) {
|
|
|
19441
19677
|
if (rule.minLength !== void 0) bar.setAttribute("minLength", String(rule.minLength));
|
|
19442
19678
|
if (rule.maxLength !== void 0) bar.setAttribute("maxLength", String(rule.maxLength));
|
|
19443
19679
|
const thresholds = children(bar, "cfvo", NS.x14);
|
|
19444
|
-
for (const [
|
|
19445
|
-
const target = thresholds[
|
|
19680
|
+
for (const [index3, threshold] of [rule.min, rule.max].entries()) {
|
|
19681
|
+
const target = thresholds[index3];
|
|
19446
19682
|
if (!target) continue;
|
|
19447
19683
|
const oldType = target.getAttribute("type");
|
|
19448
19684
|
if (oldType === "autoMin" && threshold.type === "min" || oldType === "autoMax" && threshold.type === "max")
|
|
@@ -19752,7 +19988,7 @@ function chartCacheValues(cache3) {
|
|
|
19752
19988
|
out[point.index ?? out.length] = numeric2 && text3.trim() !== "" && Number.isFinite(Number(text3)) ? Number(text3) : text3;
|
|
19753
19989
|
}
|
|
19754
19990
|
const size = Math.max(cache3.pointCount ?? 0, out.length);
|
|
19755
|
-
for (let
|
|
19991
|
+
for (let index3 = 0; index3 < size; index3++) if (out[index3] === void 0) out[index3] = "";
|
|
19756
19992
|
return out;
|
|
19757
19993
|
}
|
|
19758
19994
|
var chartSourceValues = (source2) => chartCacheValues(source2?.cache ?? source2?.levels?.[0]);
|
|
@@ -19887,8 +20123,8 @@ function parseCache(node) {
|
|
|
19887
20123
|
type: node.localName === "numCache" || node.localName === "numLit" ? "number" : "string",
|
|
19888
20124
|
points: children(node, "pt", NS.c).map((pt) => {
|
|
19889
20125
|
const point = { value: cChild(pt, "v")?.textContent ?? "" };
|
|
19890
|
-
const
|
|
19891
|
-
if (Number.isInteger(
|
|
20126
|
+
const index3 = Number(attribute(pt, "idx") ?? Number.NaN);
|
|
20127
|
+
if (Number.isInteger(index3) && index3 >= 0) point.index = index3;
|
|
19892
20128
|
const formatCode2 = attribute(pt, "formatCode");
|
|
19893
20129
|
if (formatCode2 !== void 0) point.formatCode = formatCode2;
|
|
19894
20130
|
return point;
|
|
@@ -20114,11 +20350,11 @@ var POINT = /* @__PURE__ */ new Set([
|
|
|
20114
20350
|
]);
|
|
20115
20351
|
function parseDataPoint(context, element2) {
|
|
20116
20352
|
reportUnmodelled(context, element2, POINT);
|
|
20117
|
-
const
|
|
20353
|
+
const index3 = cNumber(context, element2, "idx");
|
|
20118
20354
|
return assignDefined(
|
|
20119
20355
|
{},
|
|
20120
20356
|
{
|
|
20121
|
-
index:
|
|
20357
|
+
index: index3 !== void 0 && Number.isInteger(index3) && index3 >= 0 ? index3 : void 0,
|
|
20122
20358
|
invertIfNegative: cBool(context, element2, "invertIfNegative"),
|
|
20123
20359
|
bubble3D: cBool(context, element2, "bubble3D"),
|
|
20124
20360
|
explosion: cNumber(context, element2, "explosion"),
|
|
@@ -20655,8 +20891,8 @@ var SCHEME_INDEX = {
|
|
|
20655
20891
|
function legacyColor(color) {
|
|
20656
20892
|
if (color?.kind === "srgb") return color.value ? { rgb: color.value.toUpperCase() } : void 0;
|
|
20657
20893
|
if (color?.kind === "scheme") {
|
|
20658
|
-
const
|
|
20659
|
-
return
|
|
20894
|
+
const index3 = SCHEME_INDEX[color.value];
|
|
20895
|
+
return index3 === void 0 ? void 0 : { theme: index3 };
|
|
20660
20896
|
}
|
|
20661
20897
|
return void 0;
|
|
20662
20898
|
}
|
|
@@ -21593,14 +21829,14 @@ var PersonRegistry = class {
|
|
|
21593
21829
|
return `${XML_HEADER}<personList xmlns="${NS.tc}" xmlns:x="${NS.x}">${people}</personList>`;
|
|
21594
21830
|
}
|
|
21595
21831
|
};
|
|
21596
|
-
function vmlShape(comment,
|
|
21832
|
+
function vmlShape(comment, index3, id) {
|
|
21597
21833
|
const { row: row2, col } = comment.address;
|
|
21598
21834
|
const anchor = `${col + 1}, 15, ${Math.max(0, row2 - 1)}, 10, ${col + 3}, 15, ${row2 + 3}, 4`;
|
|
21599
|
-
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>`;
|
|
21600
21836
|
}
|
|
21601
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>';
|
|
21602
21838
|
function vmlXml(comments, layout2) {
|
|
21603
|
-
const shapes = comments.map((comment,
|
|
21839
|
+
const shapes = comments.map((comment, index3) => vmlShape(comment, index3, layout2.ids[index3] ?? 0)).join("");
|
|
21604
21840
|
const data = layout2.blocks.join(",");
|
|
21605
21841
|
const base = layout2.base;
|
|
21606
21842
|
if (base && /<\/xml>\s*$/.test(base)) {
|
|
@@ -21631,8 +21867,8 @@ function commentParts(comments, sheetNumber, persons, sheetName, layout2) {
|
|
|
21631
21867
|
const id = guidFrom(`${sheetName}!${ref}:${comment.text}`);
|
|
21632
21868
|
const personId = persons.id(comment.author);
|
|
21633
21869
|
threaded += `<threadedComment ref="${ref}" personId="${personId}" id="${id}"><text>${escapeText2(comment.text)}</text></threadedComment>`;
|
|
21634
|
-
comment.replies.forEach((reply,
|
|
21635
|
-
const replyId = guidFrom(`${id}:reply:${
|
|
21870
|
+
comment.replies.forEach((reply, index3) => {
|
|
21871
|
+
const replyId = guidFrom(`${id}:reply:${index3}:${reply.text}`);
|
|
21636
21872
|
const dT = reply.date ? ` dT="${escapeAttr3(reply.date)}"` : "";
|
|
21637
21873
|
threaded += `<threadedComment ref="${ref}"${dT} personId="${persons.id(reply.author)}" id="${replyId}" parentId="${id}"><text>${escapeText2(reply.text)}</text></threadedComment>`;
|
|
21638
21874
|
});
|
|
@@ -21649,7 +21885,7 @@ Reply:
|
|
|
21649
21885
|
sorted2,
|
|
21650
21886
|
layout2 ?? {
|
|
21651
21887
|
blocks: [sheetNumber],
|
|
21652
|
-
ids: sorted2.map((_,
|
|
21888
|
+
ids: sorted2.map((_, index3) => 1024 * sheetNumber + index3 + 1)
|
|
21653
21889
|
}
|
|
21654
21890
|
);
|
|
21655
21891
|
const parts = { comments: commentsXml, vml };
|
|
@@ -22361,11 +22597,11 @@ var GRAY_VARIATIONS = [
|
|
|
22361
22597
|
{ tint: 8e4 }
|
|
22362
22598
|
];
|
|
22363
22599
|
var ACCENTS2 = ["accent1", "accent2", "accent3", "accent4", "accent5", "accent6"];
|
|
22364
|
-
function colorful(id,
|
|
22365
|
-
return { id, group: "colorful", index:
|
|
22600
|
+
function colorful(id, index3, base) {
|
|
22601
|
+
return { id, group: "colorful", index: index3, meth: "cycle", base, variations: COLORFUL_VARIATIONS };
|
|
22366
22602
|
}
|
|
22367
|
-
function mono(id,
|
|
22368
|
-
return { id, group: "monochromatic", index:
|
|
22603
|
+
function mono(id, index3, accent, meth) {
|
|
22604
|
+
return { id, group: "monochromatic", index: index3, meth, base: [accent], variations: [] };
|
|
22369
22605
|
}
|
|
22370
22606
|
var CHART_COLOR_PALETTES = [
|
|
22371
22607
|
colorful(10, 1, ACCENTS2),
|
|
@@ -22409,9 +22645,9 @@ function chartPaletteSeriesColorChoice(palette, i2, n2) {
|
|
|
22409
22645
|
const round3 = Math.floor(i2 / palette.base.length);
|
|
22410
22646
|
transform6 = (palette.variations.length ? palette.variations[round3 % palette.variations.length] : {}) ?? {};
|
|
22411
22647
|
} else {
|
|
22412
|
-
const
|
|
22648
|
+
const index3 = palette.meth === "withinLinearReversed" ? n2 - 1 - i2 : i2;
|
|
22413
22649
|
base = palette.base[0];
|
|
22414
|
-
transform6 = withinLinearTransform(
|
|
22650
|
+
transform6 = withinLinearTransform(index3, n2);
|
|
22415
22651
|
}
|
|
22416
22652
|
if (!base) throw new RangeError("A chart palette must have a base color");
|
|
22417
22653
|
return {
|
|
@@ -22460,18 +22696,18 @@ function chartColorPalettePatch(chart, id) {
|
|
|
22460
22696
|
const previous = findChartColorPalette(chart.colorPalette ?? 10);
|
|
22461
22697
|
if (!next) return void 0;
|
|
22462
22698
|
const radial = chart.chartType === "pie" || chart.chartType === "doughnut";
|
|
22463
|
-
const series = chart.series.map((series2,
|
|
22699
|
+
const series = chart.series.map((series2, index3) => {
|
|
22464
22700
|
const copy = structuredClone(series2);
|
|
22465
22701
|
if (!previous) return copy;
|
|
22466
|
-
const previousChoice = chartPaletteSeriesColorChoice(previous,
|
|
22467
|
-
const nextChoice = chartPaletteSeriesColorChoice(next,
|
|
22702
|
+
const previousChoice = chartPaletteSeriesColorChoice(previous, index3, chart.series.length);
|
|
22703
|
+
const nextChoice = chartPaletteSeriesColorChoice(next, index3, chart.series.length);
|
|
22468
22704
|
const fill = recolorGradient(copy.fill, previousChoice, nextChoice);
|
|
22469
22705
|
if (fill) copy.fill = fill;
|
|
22470
22706
|
if (sameChartColor(
|
|
22471
22707
|
series2.drawingColor,
|
|
22472
|
-
chartPaletteSeriesColorChoice(previous,
|
|
22708
|
+
chartPaletteSeriesColorChoice(previous, index3, chart.series.length)
|
|
22473
22709
|
)) {
|
|
22474
|
-
copy.drawingColor = chartPaletteSeriesColorChoice(next,
|
|
22710
|
+
copy.drawingColor = chartPaletteSeriesColorChoice(next, index3, chart.series.length);
|
|
22475
22711
|
delete copy.color;
|
|
22476
22712
|
}
|
|
22477
22713
|
if (radial && copy.pointColors) {
|
|
@@ -22579,8 +22815,8 @@ var DEFAULT_THEME_COLORS = [
|
|
|
22579
22815
|
"0563C1",
|
|
22580
22816
|
"954F72"
|
|
22581
22817
|
];
|
|
22582
|
-
function themeColor(theme2,
|
|
22583
|
-
const hex = theme2.colors[
|
|
22818
|
+
function themeColor(theme2, index3) {
|
|
22819
|
+
const hex = theme2.colors[index3] ?? DEFAULT_THEME_COLORS[index3];
|
|
22584
22820
|
return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
|
|
22585
22821
|
}
|
|
22586
22822
|
|
|
@@ -22676,18 +22912,18 @@ function mixColors(a2, b, t, rounding = "nearest") {
|
|
|
22676
22912
|
}
|
|
22677
22913
|
|
|
22678
22914
|
// xlsx/edit/chart-series-target.ts
|
|
22679
|
-
function chartSeriesAt(chart,
|
|
22680
|
-
const target = isSeriesPosition(chart,
|
|
22681
|
-
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)}`);
|
|
22682
22918
|
return target;
|
|
22683
22919
|
}
|
|
22684
|
-
function cloneChartSeriesForEdit(chart,
|
|
22685
|
-
chartSeriesAt(chart,
|
|
22920
|
+
function cloneChartSeriesForEdit(chart, index3) {
|
|
22921
|
+
chartSeriesAt(chart, index3);
|
|
22686
22922
|
const series = structuredClone(chart.series);
|
|
22687
|
-
return { series, target: series.find((_, position) => position ===
|
|
22923
|
+
return { series, target: series.find((_, position) => position === index3) };
|
|
22688
22924
|
}
|
|
22689
|
-
function isSeriesPosition(chart,
|
|
22690
|
-
return typeof
|
|
22925
|
+
function isSeriesPosition(chart, index3) {
|
|
22926
|
+
return typeof index3 === "number" && Number.isSafeInteger(index3) && index3 >= 0 && index3 < chart.series.length;
|
|
22691
22927
|
}
|
|
22692
22928
|
|
|
22693
22929
|
// xlsx/edit/chart-series-fill.ts
|
|
@@ -22703,8 +22939,8 @@ function chartDrawingColor(color) {
|
|
|
22703
22939
|
if (!Number.isFinite(tint) || tint < -1 || tint > 1) return void 0;
|
|
22704
22940
|
return tint !== 0 ? withDrawingColorBrightness(choice, tint * 100) : choice;
|
|
22705
22941
|
}
|
|
22706
|
-
function chartSeriesFillPatch(chart,
|
|
22707
|
-
const current = chartSeriesAt(chart,
|
|
22942
|
+
function chartSeriesFillPatch(chart, index3, color) {
|
|
22943
|
+
const current = chartSeriesAt(chart, index3);
|
|
22708
22944
|
const choice = color === null ? void 0 : chartDrawingColor(color);
|
|
22709
22945
|
if (color !== null && !choice) throw new RangeError("Invalid chart fill color");
|
|
22710
22946
|
const previous = current.fill?.kind === "solid" ? current.fill.color : current.drawingColor;
|
|
@@ -22716,27 +22952,27 @@ function chartSeriesFillPatch(chart, index2, color) {
|
|
|
22716
22952
|
) ?? []
|
|
22717
22953
|
)
|
|
22718
22954
|
);
|
|
22719
|
-
return replaceSeriesPaint(chart,
|
|
22955
|
+
return replaceSeriesPaint(chart, index3, choice);
|
|
22720
22956
|
}
|
|
22721
|
-
function chartSeriesSolidFillPatch(chart,
|
|
22722
|
-
const current = chartSeriesAt(chart,
|
|
22957
|
+
function chartSeriesSolidFillPatch(chart, index3) {
|
|
22958
|
+
const current = chartSeriesAt(chart, index3);
|
|
22723
22959
|
if (!current.fill || current.fill.kind === "solid") return void 0;
|
|
22724
22960
|
const choice = current.fill.kind === "gradient" ? current.fill.stops[0]?.color : void 0;
|
|
22725
22961
|
return replaceSeriesPaint(
|
|
22726
22962
|
chart,
|
|
22727
|
-
|
|
22963
|
+
index3,
|
|
22728
22964
|
choice ?? current.drawingColor ?? chartDrawingColor(current.color) ?? chartPaletteSeriesColorChoice(
|
|
22729
22965
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
22730
|
-
|
|
22966
|
+
index3,
|
|
22731
22967
|
chart.series.length
|
|
22732
22968
|
)
|
|
22733
22969
|
);
|
|
22734
22970
|
}
|
|
22735
|
-
function replaceSeriesPaint(chart,
|
|
22736
|
-
const current = chartSeriesAt(chart,
|
|
22971
|
+
function replaceSeriesPaint(chart, index3, choice) {
|
|
22972
|
+
const current = chartSeriesAt(chart, index3);
|
|
22737
22973
|
if (!Object.keys(current.pointColors ?? {}).length && !Object.keys(current.pointFills ?? {}).length && (!choice ? current.fill?.kind === "none" : !current.fill && sameChartColor(current.drawingColor, choice)))
|
|
22738
22974
|
return void 0;
|
|
22739
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
22975
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
22740
22976
|
delete next.fill;
|
|
22741
22977
|
delete next.color;
|
|
22742
22978
|
delete next.drawingColor;
|
|
@@ -22880,18 +23116,18 @@ var PackageWriter = class {
|
|
|
22880
23116
|
var rank2 = (name) => name === "_rels/.rels" ? 0 : name.startsWith("docProps/") ? 1 : name === "xl/workbook.xml" ? 2 : 3;
|
|
22881
23117
|
|
|
22882
23118
|
// xlsx/write/chart-colors.ts
|
|
22883
|
-
function chartSeriesFill(chart, series,
|
|
23119
|
+
function chartSeriesFill(chart, series, index3) {
|
|
22884
23120
|
const imported = series.fill && drawingFillXml(series.fill);
|
|
22885
23121
|
if (imported) return imported;
|
|
22886
|
-
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series,
|
|
23122
|
+
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series, index3))}</a:solidFill>`;
|
|
22887
23123
|
}
|
|
22888
|
-
function chartSeriesDrawingFill(chart, series,
|
|
23124
|
+
function chartSeriesDrawingFill(chart, series, index3) {
|
|
22889
23125
|
if (series.fill && drawingFillXml(series.fill)) return series.fill;
|
|
22890
|
-
return { kind: "solid", color: chartSeriesColor(chart, series,
|
|
23126
|
+
return { kind: "solid", color: chartSeriesColor(chart, series, index3) };
|
|
22891
23127
|
}
|
|
22892
|
-
function chartSeriesColor(chart, series,
|
|
23128
|
+
function chartSeriesColor(chart, series, index3) {
|
|
22893
23129
|
const palette = findChartColorPalette(chart.colorPalette ?? 10);
|
|
22894
|
-
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);
|
|
22895
23131
|
}
|
|
22896
23132
|
function recolorMarker(marker3, previous, next) {
|
|
22897
23133
|
for (const paint of [marker3, first(marker3, "ln", NS.a)]) {
|
|
@@ -22909,10 +23145,10 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
22909
23145
|
const palette = findChartColorPalette(model.colorPalette ?? 10);
|
|
22910
23146
|
const lineLike = ["line", "scatter", "radar"].includes(model.chartType);
|
|
22911
23147
|
const markerOnly = model.chartType === "scatter" && first(plot2, "scatterStyle", NS.c)?.getAttribute("val") === "marker";
|
|
22912
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
22913
|
-
const series = model.series[
|
|
23148
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
23149
|
+
const series = model.series[index3];
|
|
22914
23150
|
if (!series) return;
|
|
22915
|
-
const old = before.series[
|
|
23151
|
+
const old = before.series[index3];
|
|
22916
23152
|
if (old?.effectsXml !== series.effectsXml) {
|
|
22917
23153
|
let shape2 = first(ser, "spPr", NS.c);
|
|
22918
23154
|
if (!shape2 && series.effectsXml) {
|
|
@@ -22958,12 +23194,12 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
22958
23194
|
paint = doc.createElementNS(NS.a, "a:ln");
|
|
22959
23195
|
spPr.appendChild(paint);
|
|
22960
23196
|
}
|
|
22961
|
-
setDrawingFillXml(paint, chartSeriesFill(model, series,
|
|
23197
|
+
setDrawingFillXml(paint, chartSeriesFill(model, series, index3));
|
|
22962
23198
|
}
|
|
22963
23199
|
if (previousPalette && palette && before.colorPalette !== model.colorPalette) {
|
|
22964
23200
|
const marker3 = first(first(ser, "marker", NS.c), "spPr", NS.c);
|
|
22965
|
-
const previous = chartPaletteSeriesColorChoice(previousPalette,
|
|
22966
|
-
const next = chartPaletteSeriesColorChoice(palette,
|
|
23201
|
+
const previous = chartPaletteSeriesColorChoice(previousPalette, index3, model.series.length);
|
|
23202
|
+
const next = chartPaletteSeriesColorChoice(palette, index3, model.series.length);
|
|
22967
23203
|
recolorMarker(marker3, previous, next);
|
|
22968
23204
|
for (const point of children(ser, "dPt", NS.c))
|
|
22969
23205
|
recolorMarker(first(first(point, "marker", NS.c), "spPr", NS.c), previous, next);
|
|
@@ -23058,7 +23294,7 @@ var FIRST_AXIS = 500000001;
|
|
|
23058
23294
|
var SECOND_AXIS = 500000002;
|
|
23059
23295
|
function source(kind, formula, values2) {
|
|
23060
23296
|
const points = values2.flatMap(
|
|
23061
|
-
(value2,
|
|
23297
|
+
(value2, index3) => value2 === null || value2 === "" ? [] : [{ index: index3, value: String(value2) }]
|
|
23062
23298
|
);
|
|
23063
23299
|
return {
|
|
23064
23300
|
kind: formula ? kind === "str" ? "strRef" : "numRef" : kind === "str" ? "strLit" : "numLit",
|
|
@@ -23091,9 +23327,9 @@ function dataPoints(series) {
|
|
|
23091
23327
|
return /^\d+$/.test(key) && paint ? [{ index: Number(key), spPr: { fill: paint } }] : [];
|
|
23092
23328
|
});
|
|
23093
23329
|
}
|
|
23094
|
-
function seriesModel(chart, series,
|
|
23330
|
+
function seriesModel(chart, series, index3) {
|
|
23095
23331
|
const type = chart.chartType;
|
|
23096
|
-
const out = { index:
|
|
23332
|
+
const out = { index: index3, order: index3, dataPoints: dataPoints(series) };
|
|
23097
23333
|
if (series.nameRef)
|
|
23098
23334
|
out.tx = {
|
|
23099
23335
|
reference: source("str", series.nameRef, series.name === void 0 ? [] : [series.name])
|
|
@@ -23102,7 +23338,7 @@ function seriesModel(chart, series, index2) {
|
|
|
23102
23338
|
const lineLike = type === "line" || type === "scatter" || type === "radar";
|
|
23103
23339
|
const effectsXml = effects(series);
|
|
23104
23340
|
if (type !== "pie" && type !== "doughnut" || series.fill || series.color || series.drawingColor || effectsXml) {
|
|
23105
|
-
const fill = chartSeriesDrawingFill(chart, series,
|
|
23341
|
+
const fill = chartSeriesDrawingFill(chart, series, index3);
|
|
23106
23342
|
const shape2 = lineLike ? { line: { widthEmu: 28575, cap: "rnd", fill } } : { fill };
|
|
23107
23343
|
if (effectsXml) shape2.effectsXml = effectsXml;
|
|
23108
23344
|
out.spPr = shape2;
|
|
@@ -23226,7 +23462,7 @@ function style(chart) {
|
|
|
23226
23462
|
return id > 100 ? { c14Style: id, style: id - 100 } : { style: id };
|
|
23227
23463
|
}
|
|
23228
23464
|
function chartSpaceFromObject(chart) {
|
|
23229
|
-
const series = chart.series.map((entry3,
|
|
23465
|
+
const series = chart.series.map((entry3, index3) => seriesModel(chart, entry3, index3));
|
|
23230
23466
|
const [group, chartAxes] = plot(chart, series);
|
|
23231
23467
|
const space = {
|
|
23232
23468
|
roundedCorners: false,
|
|
@@ -23267,8 +23503,8 @@ function patchChartReferences(xml, chart) {
|
|
|
23267
23503
|
changed = true;
|
|
23268
23504
|
}
|
|
23269
23505
|
};
|
|
23270
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
23271
|
-
const model = chart.series[
|
|
23506
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
23507
|
+
const model = chart.series[index3];
|
|
23272
23508
|
if (!model) return;
|
|
23273
23509
|
setRef(first(ser, "tx", NS.c), model.nameRef);
|
|
23274
23510
|
setRef(first(ser, "cat", NS.c) ?? first(ser, "xVal", NS.c), model.categoriesRef);
|
|
@@ -23575,14 +23811,14 @@ function shiftSpan(start, end, shift2) {
|
|
|
23575
23811
|
const e = end >= max ? max : end < at ? end : end > last ? end - n2 : at - 1;
|
|
23576
23812
|
return s > e ? void 0 : { start: s, end: e };
|
|
23577
23813
|
}
|
|
23578
|
-
function shiftIndex(
|
|
23814
|
+
function shiftIndex(index3, shift2) {
|
|
23579
23815
|
const { at, count: count2 } = shift2;
|
|
23580
|
-
if (
|
|
23581
|
-
if (count2 > 0) return
|
|
23582
|
-
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;
|
|
23583
23819
|
}
|
|
23584
|
-
function shiftIndexClamped(
|
|
23585
|
-
const moved = shiftIndex(
|
|
23820
|
+
function shiftIndexClamped(index3, shift2) {
|
|
23821
|
+
const moved = shiftIndex(index3, shift2);
|
|
23586
23822
|
if (moved !== void 0) return moved;
|
|
23587
23823
|
return shift2.count > 0 ? axisMax(shift2.axis) : shift2.at;
|
|
23588
23824
|
}
|
|
@@ -24073,9 +24309,9 @@ function readSourceStyles(xml) {
|
|
|
24073
24309
|
(node) => inlineFragment(outerXml(node))
|
|
24074
24310
|
);
|
|
24075
24311
|
const dxfKeys = /* @__PURE__ */ new Map();
|
|
24076
|
-
parseStyles(xml, []).dxfs.forEach((dxf,
|
|
24312
|
+
parseStyles(xml, []).dxfs.forEach((dxf, index3) => {
|
|
24077
24313
|
const key = styleKey(dxf);
|
|
24078
|
-
if (!dxfKeys.has(key)) dxfKeys.set(key,
|
|
24314
|
+
if (!dxfKeys.has(key)) dxfKeys.set(key, index3);
|
|
24079
24315
|
});
|
|
24080
24316
|
const result2 = { numFmts, dxfXml, dxfKeys };
|
|
24081
24317
|
const tableStyles = xFirst(root, "tableStyles");
|
|
@@ -24183,7 +24419,7 @@ var StyleWriter = class {
|
|
|
24183
24419
|
});
|
|
24184
24420
|
const seen = /* @__PURE__ */ new Set();
|
|
24185
24421
|
const unique2 = named2.filter((entry3) => !seen.has(entry3.name) && seen.add(entry3.name));
|
|
24186
|
-
const xfIdOf = new Map(unique2.map((entry3,
|
|
24422
|
+
const xfIdOf = new Map(unique2.map((entry3, index3) => [entry3.name, index3]));
|
|
24187
24423
|
const base = this.workbook.styles[0] ?? defaultCellStyle();
|
|
24188
24424
|
this.fonts.id(fontXml(base.font));
|
|
24189
24425
|
this.borders.id(borderXml({}));
|
|
@@ -24192,7 +24428,7 @@ var StyleWriter = class {
|
|
|
24192
24428
|
(style2) => this.xf(style2, xfIdOf.get(style2.cellStyleName ?? "Normal") ?? 0)
|
|
24193
24429
|
);
|
|
24194
24430
|
const cellStyles = unique2.map(
|
|
24195
|
-
(entry3,
|
|
24431
|
+
(entry3, index3) => el("cellStyle", { name: entry3.name, xfId: index3, builtinId: entry3.builtinId })
|
|
24196
24432
|
);
|
|
24197
24433
|
const custom = [...this.numFmts].filter(([code]) => builtinFormatIdOf(code) === void 0).sort((a2, b) => a2[1] - b[1]);
|
|
24198
24434
|
let out = `${XML_HEADER}<styleSheet xmlns="${NS.x}" xmlns:mc="${NS.mc}" mc:Ignorable="x14ac" xmlns:x14ac="${NS.x14ac}">`;
|
|
@@ -24357,13 +24593,13 @@ function definedNamesOf(workbook) {
|
|
|
24357
24593
|
const names = workbook.definedNames.filter(
|
|
24358
24594
|
(name) => name.name && (name.localSheet === void 0 || name.localSheet >= 0 && name.localSheet < workbook.sheets.length)
|
|
24359
24595
|
);
|
|
24360
|
-
workbook.sheets.forEach((sheet,
|
|
24596
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
24361
24597
|
const area = sheet.pageSetup?.printArea;
|
|
24362
|
-
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;
|
|
24363
24599
|
names.push({
|
|
24364
24600
|
name: "_xlnm.Print_Area",
|
|
24365
24601
|
formula: `${quoteSheetName(sheet.name)}!${absoluteRange(area)}`,
|
|
24366
|
-
localSheet:
|
|
24602
|
+
localSheet: index3
|
|
24367
24603
|
});
|
|
24368
24604
|
});
|
|
24369
24605
|
return names;
|
|
@@ -24808,8 +25044,8 @@ function extent(values2) {
|
|
|
24808
25044
|
function sparklineValues(group, values2) {
|
|
24809
25045
|
return group.displayEmptyCellsAs === "zero" ? values2.map((v) => v ?? 0) : [...values2];
|
|
24810
25046
|
}
|
|
24811
|
-
function sparklineScale(group, all2,
|
|
24812
|
-
const own = extent(sparklineValues(group, all2[
|
|
25047
|
+
function sparklineScale(group, all2, index3) {
|
|
25048
|
+
const own = extent(sparklineValues(group, all2[index3]?.values ?? []));
|
|
24813
25049
|
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
24814
25050
|
const shared = needsGroup ? extent(all2.flatMap((data) => sparklineValues(group, data.values))) : void 0;
|
|
24815
25051
|
const end = (type, manual, key) => {
|
|
@@ -24927,17 +25163,17 @@ var MAX_POINTS = 1e4;
|
|
|
24927
25163
|
var hostIndex = /* @__PURE__ */ new WeakMap();
|
|
24928
25164
|
function hosts(sheet) {
|
|
24929
25165
|
const groups = sheetSparklineGroups(sheet);
|
|
24930
|
-
let
|
|
24931
|
-
if (!
|
|
24932
|
-
|
|
25166
|
+
let index3 = hostIndex.get(groups);
|
|
25167
|
+
if (!index3) {
|
|
25168
|
+
index3 = /* @__PURE__ */ new Map();
|
|
24933
25169
|
for (const group of groups)
|
|
24934
25170
|
group.sparklines.forEach((line3, i2) => {
|
|
24935
25171
|
const key = cellKey(line3.host.start.row, line3.host.start.col);
|
|
24936
|
-
if (!
|
|
25172
|
+
if (!index3.has(key)) index3.set(key, { group, index: i2 });
|
|
24937
25173
|
});
|
|
24938
|
-
hostIndex.set(groups,
|
|
25174
|
+
hostIndex.set(groups, index3);
|
|
24939
25175
|
}
|
|
24940
|
-
return
|
|
25176
|
+
return index3;
|
|
24941
25177
|
}
|
|
24942
25178
|
function hasSparklineAt(sheet, row2, col) {
|
|
24943
25179
|
return hosts(sheet).has(cellKey(row2, col));
|
|
@@ -25003,10 +25239,10 @@ function sparklineViewAt(workbook, sheetIndex2, row2, col) {
|
|
|
25003
25239
|
if (!sheet) return void 0;
|
|
25004
25240
|
const entry3 = hosts(sheet).get(cellKey(row2, col));
|
|
25005
25241
|
if (!entry3) return void 0;
|
|
25006
|
-
const { group, index:
|
|
25242
|
+
const { group, index: index3 } = entry3;
|
|
25007
25243
|
const needsGroup = group.minAxisType === "group" || group.maxAxisType === "group";
|
|
25008
|
-
const data = needsGroup ? groupData(workbook, sheet, group) : groupData(workbook, sheet, { ...group, sparklines: [group.sparklines[
|
|
25009
|
-
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;
|
|
25010
25246
|
return sparklineView(
|
|
25011
25247
|
group,
|
|
25012
25248
|
data[at] ?? { values: [] },
|
|
@@ -25171,9 +25407,9 @@ function sourceColumnsForPatch(root, table2, names) {
|
|
|
25171
25407
|
const byName = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
25172
25408
|
const tracked = table2.partName !== void 0 || table2.columns.some((c2) => c2.sourceId !== void 0);
|
|
25173
25409
|
const used = /* @__PURE__ */ new Set();
|
|
25174
|
-
return names.map((name,
|
|
25175
|
-
const id = table2.columns[
|
|
25176
|
-
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());
|
|
25177
25413
|
if (!match2 || used.has(match2)) return void 0;
|
|
25178
25414
|
used.add(match2);
|
|
25179
25415
|
return match2;
|
|
@@ -25190,12 +25426,12 @@ function patchAutoFilter(doc, root, table2, before, names) {
|
|
|
25190
25426
|
filter2.setAttribute("ref", formatRange(range));
|
|
25191
25427
|
const list = xKid(root, "tableColumns");
|
|
25192
25428
|
const original = list ? xKids(list, "tableColumn") : [];
|
|
25193
|
-
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2,
|
|
25429
|
+
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2, index3) => [c2, index3]));
|
|
25194
25430
|
for (const column of xKids(filter2, "filterColumn")) {
|
|
25195
25431
|
const old = original[Number(column.getAttribute("colId") ?? "0")];
|
|
25196
|
-
const
|
|
25197
|
-
if (
|
|
25198
|
-
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));
|
|
25199
25435
|
}
|
|
25200
25436
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
25201
25437
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
@@ -25240,11 +25476,11 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
25240
25476
|
for (const column of sourceColumns) list.removeChild(column);
|
|
25241
25477
|
let nextId = Math.max(0, ...ids) + 1;
|
|
25242
25478
|
const totalsRow = table2.range.end.row;
|
|
25243
|
-
names.forEach((name,
|
|
25244
|
-
const column = picked[
|
|
25479
|
+
names.forEach((name, index3) => {
|
|
25480
|
+
const column = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
25245
25481
|
if (!column.getAttribute("id")) column.setAttribute("id", num2(nextId++));
|
|
25246
25482
|
column.setAttribute("name", name);
|
|
25247
|
-
const model = table2.columns[
|
|
25483
|
+
const model = table2.columns[index3];
|
|
25248
25484
|
const fn = table2.totalsRow ? model?.totalsRowFunction : void 0;
|
|
25249
25485
|
setOrRemove(column, "totalsRowFunction", fn);
|
|
25250
25486
|
setOrRemove(column, "totalsRowLabel", table2.totalsRow ? model?.totalsRowLabel : void 0);
|
|
@@ -25258,7 +25494,7 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
25258
25494
|
);
|
|
25259
25495
|
if (fn !== "custom") setChildText(doc, column, "totalsRowFormula", void 0, []);
|
|
25260
25496
|
else {
|
|
25261
|
-
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;
|
|
25262
25498
|
if (cellFormula)
|
|
25263
25499
|
setChildText(
|
|
25264
25500
|
doc,
|
|
@@ -25339,11 +25575,11 @@ function tableXml(table2, id, names) {
|
|
|
25339
25575
|
const range = formatRange(table2.range);
|
|
25340
25576
|
const filterEnd = { ...table2.range.end, row: table2.range.end.row - (table2.totalsRow ? 1 : 0) };
|
|
25341
25577
|
const filter2 = table2.headerRow && !table2.totalsRow ? `<autoFilter ref="${range}"/>` : table2.headerRow ? `<autoFilter ref="${formatRange({ start: table2.range.start, end: filterEnd })}"/>` : "";
|
|
25342
|
-
const columns = names.map((name,
|
|
25343
|
-
const column = table2.columns[
|
|
25578
|
+
const columns = names.map((name, index3) => {
|
|
25579
|
+
const column = table2.columns[index3];
|
|
25344
25580
|
const calculated = column?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText2(addFuturePrefixes(column.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
25345
25581
|
const values2 = attrs({
|
|
25346
|
-
id:
|
|
25582
|
+
id: index3 + 1,
|
|
25347
25583
|
name,
|
|
25348
25584
|
totalsRowFunction: table2.totalsRow ? column?.totalsRowFunction : void 0,
|
|
25349
25585
|
totalsRowLabel: table2.totalsRow ? column?.totalsRowLabel : void 0
|
|
@@ -25382,27 +25618,27 @@ function totalsRowFormulas(sheet, table2, names) {
|
|
|
25382
25618
|
const out = /* @__PURE__ */ new Map();
|
|
25383
25619
|
if (!table2.totalsRow) return out;
|
|
25384
25620
|
const row2 = table2.range.end.row;
|
|
25385
|
-
names.forEach((name,
|
|
25386
|
-
const code = SUBTOTAL_CODES[table2.columns[
|
|
25621
|
+
names.forEach((name, index3) => {
|
|
25622
|
+
const code = SUBTOTAL_CODES[table2.columns[index3]?.totalsRowFunction ?? ""];
|
|
25387
25623
|
if (code === void 0) return;
|
|
25388
|
-
const col = table2.range.start.col +
|
|
25624
|
+
const col = table2.range.start.col + index3;
|
|
25389
25625
|
const escaped = name.replace(/['#[\]]/g, "'$&");
|
|
25390
25626
|
const formula = `SUBTOTAL(${code},${table2.displayName || table2.name}[${escaped}])`;
|
|
25391
25627
|
if (sheet.rows.get(row2)?.get(col)?.formula !== formula) out.set(`${row2}:${col}`, formula);
|
|
25392
25628
|
});
|
|
25393
25629
|
return out;
|
|
25394
25630
|
}
|
|
25395
|
-
function resolveTableNames(table2, before,
|
|
25631
|
+
function resolveTableNames(table2, before, index3) {
|
|
25396
25632
|
const display = table2.displayName || table2.name;
|
|
25397
|
-
const displayName = before && before.displayName === display ? display : safeTableName(display,
|
|
25398
|
-
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);
|
|
25399
25635
|
return { name, displayName };
|
|
25400
25636
|
}
|
|
25401
|
-
function safeTableName(name,
|
|
25637
|
+
function safeTableName(name, index3) {
|
|
25402
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;
|
|
25403
25639
|
if (valid) return name;
|
|
25404
25640
|
const cleaned = name.replace(/[^A-Za-z0-9_.]/g, "_");
|
|
25405
|
-
return `Table_${cleaned ||
|
|
25641
|
+
return `Table_${cleaned || index3}`;
|
|
25406
25642
|
}
|
|
25407
25643
|
|
|
25408
25644
|
// xlsx/write/sheet-parts.ts
|
|
@@ -25415,7 +25651,7 @@ function sourceRelIds(source2, partName) {
|
|
|
25415
25651
|
if (legacy) out.legacy = legacy;
|
|
25416
25652
|
return out;
|
|
25417
25653
|
}
|
|
25418
|
-
function writeComments(ctx, sheet,
|
|
25654
|
+
function writeComments(ctx, sheet, index3, partName, rels) {
|
|
25419
25655
|
const { writer, source: source2 } = ctx;
|
|
25420
25656
|
const name = (pattern) => writer.uniqueName(pattern, ctx.reserved);
|
|
25421
25657
|
const fromSource = source2 && sheet.partName && source2.has(sheet.partName);
|
|
@@ -25460,8 +25696,8 @@ function writeComments(ctx, sheet, index2, partName, rels) {
|
|
|
25460
25696
|
}
|
|
25461
25697
|
}
|
|
25462
25698
|
const own = base ? vmlIdmapBlocks(base) : [];
|
|
25463
|
-
const layout2 = vmlAllocatorFor(ctx, source2).allocate(sheet.comments.length,
|
|
25464
|
-
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, {
|
|
25465
25701
|
...layout2,
|
|
25466
25702
|
...base ? { base } : {}
|
|
25467
25703
|
});
|
|
@@ -25483,11 +25719,11 @@ function sourceVmlPart(source2, sheetPart) {
|
|
|
25483
25719
|
}
|
|
25484
25720
|
function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
25485
25721
|
const ids = [];
|
|
25486
|
-
for (const [
|
|
25722
|
+
for (const [index3, original] of sheet.tables.entries()) {
|
|
25487
25723
|
const { writer, source: source2 } = ctx;
|
|
25488
25724
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
25489
25725
|
const before = sourceXml && original.partName ? parseTable(sourceXml, original.partName) : void 0;
|
|
25490
|
-
const { name, displayName } = resolveTableNames(original, before,
|
|
25726
|
+
const { name, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
25491
25727
|
const table2 = name === original.name && displayName === original.displayName ? original : { ...original, name, displayName };
|
|
25492
25728
|
const { names, headerText: forced } = resolveTableColumns(sheet, table2);
|
|
25493
25729
|
for (const [key, text3] of forced) headerText.set(key, text3);
|
|
@@ -25769,7 +26005,7 @@ var REGENERATED = /* @__PURE__ */ new Set([
|
|
|
25769
26005
|
]);
|
|
25770
26006
|
var NS_XR2 = "http://schemas.microsoft.com/office/spreadsheetml/2015/revision2";
|
|
25771
26007
|
var NS_XR3 = "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3";
|
|
25772
|
-
function writeWorksheet(ctx, sheet,
|
|
26008
|
+
function writeWorksheet(ctx, sheet, index3, partName) {
|
|
25773
26009
|
const { writer, source: source2 } = ctx;
|
|
25774
26010
|
const rels = new RelationshipSet();
|
|
25775
26011
|
let sourceDrawing;
|
|
@@ -25792,7 +26028,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
25792
26028
|
const tableParts = writeTables(ctx, sheet, partName, rels, headerText, formulas);
|
|
25793
26029
|
blocks.set("sheetPr", sheetPrXml(sheet));
|
|
25794
26030
|
blocks.set("dimension", dimensionXml(sheet));
|
|
25795
|
-
blocks.set("sheetViews", sheetViewsXml(sheet,
|
|
26031
|
+
blocks.set("sheetViews", sheetViewsXml(sheet, index3 === ctx.workbook.activeSheet));
|
|
25796
26032
|
blocks.set("sheetFormatPr", sheetFormatXml(sheet));
|
|
25797
26033
|
blocks.set("cols", colsXml(sheet, ctx.workbook.styles.length));
|
|
25798
26034
|
blocks.set(
|
|
@@ -25831,7 +26067,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
25831
26067
|
);
|
|
25832
26068
|
blocks.set("headerFooter", page.headerFooter);
|
|
25833
26069
|
blocks.set("drawing", writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing));
|
|
25834
|
-
blocks.set("legacyDrawing", writeComments(ctx, sheet,
|
|
26070
|
+
blocks.set("legacyDrawing", writeComments(ctx, sheet, index3, partName, rels));
|
|
25835
26071
|
blocks.set("tableParts", tableParts);
|
|
25836
26072
|
ctx.pivots?.writeSheet(writer, sheet, partName, rels);
|
|
25837
26073
|
blocks.set("extLst", conditionalExtensionsXml(sheet));
|
|
@@ -25856,12 +26092,12 @@ function pivotCacheData(pivot) {
|
|
|
25856
26092
|
const items = pivot.fields.map(() => []);
|
|
25857
26093
|
const indices = pivot.fields.map(() => /* @__PURE__ */ new Map());
|
|
25858
26094
|
for (const record of pivot.records)
|
|
25859
|
-
pivot.fields.forEach((_field,
|
|
25860
|
-
const value2 = record[
|
|
26095
|
+
pivot.fields.forEach((_field, index3) => {
|
|
26096
|
+
const value2 = record[index3] ?? null;
|
|
25861
26097
|
const key = pivotValueKey(value2);
|
|
25862
|
-
if (!indices[
|
|
25863
|
-
indices[
|
|
25864
|
-
items[
|
|
26098
|
+
if (!indices[index3].has(key)) {
|
|
26099
|
+
indices[index3].set(key, items[index3].length);
|
|
26100
|
+
items[index3].push(value2);
|
|
25865
26101
|
}
|
|
25866
26102
|
});
|
|
25867
26103
|
return { items, indices };
|
|
@@ -25876,8 +26112,8 @@ function valueXml(value2) {
|
|
|
25876
26112
|
}
|
|
25877
26113
|
function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
25878
26114
|
const source2 = sparklineDataRange(workbook, 0, pivot.source);
|
|
25879
|
-
const fields = pivot.fields.map((name,
|
|
25880
|
-
const items = data.items[
|
|
26115
|
+
const fields = pivot.fields.map((name, index3) => {
|
|
26116
|
+
const items = data.items[index3];
|
|
25881
26117
|
const types = new Set(
|
|
25882
26118
|
items.map((value2) => value2 === null || value2 === "" ? "blank" : typeof value2)
|
|
25883
26119
|
);
|
|
@@ -25889,7 +26125,7 @@ function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
|
25889
26125
|
}
|
|
25890
26126
|
function pivotCacheRecordsXml(pivot, data) {
|
|
25891
26127
|
const records = pivot.records.map(
|
|
25892
|
-
(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>`
|
|
25893
26129
|
).join("");
|
|
25894
26130
|
return `${XML_HEADER}<pivotCacheRecords xmlns="${NS.x}" count="${pivot.records.length}">${records}</pivotCacheRecords>`;
|
|
25895
26131
|
}
|
|
@@ -25899,6 +26135,19 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25899
26135
|
const grid = pivotGrid(pivot);
|
|
25900
26136
|
const row2 = pivot.fields.indexOf(pivot.rowField);
|
|
25901
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;
|
|
25902
26151
|
const col = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
25903
26152
|
const measures = pivotMeasures(pivot);
|
|
25904
26153
|
const multiple = measures.length > 1;
|
|
@@ -25906,32 +26155,34 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25906
26155
|
const compact3 = pivot.layout === "compact";
|
|
25907
26156
|
const outline = pivot.layout === "compact" || pivot.layout === "outline";
|
|
25908
26157
|
const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
|
|
25909
|
-
const fields = pivot.fields.map((_field,
|
|
25910
|
-
const items2 =
|
|
25911
|
-
const subtotal = !(
|
|
25912
|
-
const repeated = pivot.repeatLabels && (
|
|
25913
|
-
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>`;
|
|
25914
26163
|
}).join("");
|
|
25915
|
-
const items = (count2) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
25916
|
-
const header = grid.firstHeaderRow
|
|
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;
|
|
25917
26166
|
const rowIndices = rowsAxis && pivot.valuesPosition === "first" ? [-2, row2, second] : rowsAxis && pivot.valuesPosition === "between" ? [row2, -2, second] : [row2, ...second >= 0 ? [second] : [], ...rowsAxis ? [-2] : []];
|
|
25918
26167
|
let previous = [];
|
|
25919
|
-
const rowItems =
|
|
26168
|
+
const rowItems = rowEntries?.map((entry3) => {
|
|
25920
26169
|
let prefix = 0;
|
|
25921
26170
|
if (entry3.type === "default" && rowsAxis && pivot.valuesPosition === "first") prefix = 1;
|
|
25922
26171
|
else if (!entry3.type)
|
|
25923
26172
|
while (prefix < entry3.indices.length - 1 && entry3.indices[prefix] === previous[prefix])
|
|
25924
26173
|
prefix++;
|
|
25925
26174
|
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
25926
|
-
return `<i${attrs({ t: entry3.type, r: prefix || void 0, i: entry3.measure || void 0 })}>${entry3.indices.slice(prefix).map((
|
|
25927
|
-
}).join("") ?? items(grid.rowItems.length);
|
|
25928
|
-
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((
|
|
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>`;
|
|
25929
26178
|
if (multiple && !rowsAxis)
|
|
25930
|
-
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)}`;
|
|
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)}`;
|
|
25931
26180
|
else if (col >= 0)
|
|
25932
|
-
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length)}</colItems>`;
|
|
26181
|
+
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length, columnIndicesFull)}</colItems>`;
|
|
25933
26182
|
else
|
|
25934
|
-
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
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>`;
|
|
25935
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>`;
|
|
25936
26187
|
const doc = parseXml(
|
|
25937
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>`
|
|
@@ -25986,7 +26237,8 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
25986
26237
|
"rowItems",
|
|
25987
26238
|
"colFields",
|
|
25988
26239
|
"colItems",
|
|
25989
|
-
"dataFields"
|
|
26240
|
+
"dataFields",
|
|
26241
|
+
"pageFields"
|
|
25990
26242
|
]);
|
|
25991
26243
|
for (const child3 of elements(root)) if (replaced.has(child3.localName)) root.removeChild(child3);
|
|
25992
26244
|
const replacement = parseXml(`<root xmlns="${NS.x}">${body}</root>`).documentElement;
|
|
@@ -26171,8 +26423,8 @@ async function saveXlsx(workbook) {
|
|
|
26171
26423
|
return void 0;
|
|
26172
26424
|
});
|
|
26173
26425
|
const sheetRefs = [];
|
|
26174
|
-
workbook.sheets.forEach((sheet,
|
|
26175
|
-
let partName = partNames[
|
|
26426
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
26427
|
+
let partName = partNames[index3];
|
|
26176
26428
|
const sourceType = partName && source2?.has(partName) ? source2.contentType(partName) : void 0;
|
|
26177
26429
|
const special = sourceType ? SHEET_TYPES[sourceType] : void 0;
|
|
26178
26430
|
if (!partName) {
|
|
@@ -26183,11 +26435,11 @@ async function saveXlsx(workbook) {
|
|
|
26183
26435
|
claimed.add(partName);
|
|
26184
26436
|
}
|
|
26185
26437
|
if (special) writer.carry(partName);
|
|
26186
|
-
else writeWorksheet(ctx, sheet,
|
|
26438
|
+
else writeWorksheet(ctx, sheet, index3, partName);
|
|
26187
26439
|
sheetRefs.push({
|
|
26188
26440
|
name: sheet.name,
|
|
26189
26441
|
sheetId: sheet.sheetId,
|
|
26190
|
-
state: states[
|
|
26442
|
+
state: states[index3] ?? "visible",
|
|
26191
26443
|
relId: rels.add(special ?? RELATIONSHIP_TYPES.worksheet, relativeTarget(bookPart, partName))
|
|
26192
26444
|
});
|
|
26193
26445
|
});
|
|
@@ -26249,9 +26501,9 @@ async function saveXlsx(workbook) {
|
|
|
26249
26501
|
}
|
|
26250
26502
|
|
|
26251
26503
|
// xlsx/edit/context.ts
|
|
26252
|
-
function sheetAt(workbook,
|
|
26253
|
-
const sheet = Number.isInteger(
|
|
26254
|
-
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}`);
|
|
26255
26507
|
return sheet;
|
|
26256
26508
|
}
|
|
26257
26509
|
function baseStyleId(sheet, row2, col) {
|
|
@@ -26485,7 +26737,7 @@ function rewriteFormulas(workbook, rewrite2, formulaCells) {
|
|
|
26485
26737
|
else bySheet.set(cell.sheet, [cell]);
|
|
26486
26738
|
}
|
|
26487
26739
|
workbook.sheets.forEach(
|
|
26488
|
-
(sheet,
|
|
26740
|
+
(sheet, index3) => rewriteSheetFormulas(sheet, rewrite2, bySheet ? bySheet.get(index3) ?? [] : void 0)
|
|
26489
26741
|
);
|
|
26490
26742
|
for (const definedName of workbook.definedNames) {
|
|
26491
26743
|
const local = definedName.localSheet === void 0 ? void 0 : workbook.sheets[definedName.localSheet];
|
|
@@ -26504,11 +26756,11 @@ function rewriteSheetFormulas(sheet, rewrite2, formulaCells) {
|
|
|
26504
26756
|
{
|
|
26505
26757
|
const name = sheet.name;
|
|
26506
26758
|
for (const table2 of sheet.tables)
|
|
26507
|
-
for (const [
|
|
26759
|
+
for (const [index3, column] of table2.columns.entries())
|
|
26508
26760
|
if (column.calculatedColumnFormula !== void 0)
|
|
26509
26761
|
column.calculatedColumnFormula = safe(rewrite2, column.calculatedColumnFormula, name, {
|
|
26510
26762
|
row: table2.range.start.row + (table2.headerRow ? 1 : 0),
|
|
26511
|
-
col: table2.range.start.col +
|
|
26763
|
+
col: table2.range.start.col + index3
|
|
26512
26764
|
});
|
|
26513
26765
|
if (formulaCells) {
|
|
26514
26766
|
for (const at of formulaCells) {
|
|
@@ -26584,8 +26836,8 @@ function syncTableHeader(ctx, sheet, row2, col, formulaCells) {
|
|
|
26584
26836
|
const newName = uniqueHeaders([...others, text3]).at(-1);
|
|
26585
26837
|
column.name = newName;
|
|
26586
26838
|
if (newName !== text3) writeValue(sheet, row2, col, newName);
|
|
26587
|
-
const
|
|
26588
|
-
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 }]);
|
|
26589
26841
|
rewriteFormulas(
|
|
26590
26842
|
ctx.workbook,
|
|
26591
26843
|
(formula, formulaSheet, at) => renameTableColumnInFormula(
|
|
@@ -26598,7 +26850,7 @@ function syncTableHeader(ctx, sheet, row2, col, formulaCells) {
|
|
|
26598
26850
|
cells
|
|
26599
26851
|
);
|
|
26600
26852
|
}
|
|
26601
|
-
function writeScopes(sheet,
|
|
26853
|
+
function writeScopes(sheet, index3, range, parts = []) {
|
|
26602
26854
|
const r = normalizeRange(range);
|
|
26603
26855
|
const touchesHeader = sheet.tables.some(
|
|
26604
26856
|
(t) => t.headerRow && rangesIntersect(
|
|
@@ -26606,9 +26858,9 @@ function writeScopes(sheet, index2, range, parts = []) {
|
|
|
26606
26858
|
cellRange(t.range.start.row, t.range.start.col, t.range.start.row, t.range.end.col)
|
|
26607
26859
|
)
|
|
26608
26860
|
);
|
|
26609
|
-
if (touchesHeader) return [{ kind: "refs" }, { kind: "cells", sheet:
|
|
26610
|
-
const scopes = [{ kind: "cells", sheet:
|
|
26611
|
-
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 });
|
|
26612
26864
|
return scopes;
|
|
26613
26865
|
}
|
|
26614
26866
|
function writeInput(ctx, sheet, row2, col, text3) {
|
|
@@ -26906,10 +27158,10 @@ function patchRangeWith(sheet, range, patcher) {
|
|
|
26906
27158
|
pruneCell(sheet, row2, col);
|
|
26907
27159
|
});
|
|
26908
27160
|
}
|
|
26909
|
-
function formatScopes(
|
|
26910
|
-
const cells = { kind: "cells", sheet:
|
|
27161
|
+
function formatScopes(index3, ranges) {
|
|
27162
|
+
const cells = { kind: "cells", sheet: index3, ranges };
|
|
26911
27163
|
const whole = ranges.some((r) => isWholeColumns(r) || isWholeRows(r));
|
|
26912
|
-
return whole ? [cells, { kind: "parts", sheet:
|
|
27164
|
+
return whole ? [cells, { kind: "parts", sheet: index3, parts: ["columns", "rowInfo"] }] : [cells];
|
|
26913
27165
|
}
|
|
26914
27166
|
function applyStyle(ctx, s, ranges, patch3) {
|
|
26915
27167
|
const sheet = sheetAt(ctx.workbook, s);
|
|
@@ -26952,8 +27204,8 @@ var LISTS = [
|
|
|
26952
27204
|
function listMatch(text3) {
|
|
26953
27205
|
const lower2 = text3.toLowerCase();
|
|
26954
27206
|
for (const list of LISTS) {
|
|
26955
|
-
const
|
|
26956
|
-
if (
|
|
27207
|
+
const index3 = list.findIndex((item) => item.toLowerCase() === lower2);
|
|
27208
|
+
if (index3 >= 0) return { list, index: index3 };
|
|
26957
27209
|
}
|
|
26958
27210
|
return void 0;
|
|
26959
27211
|
}
|
|
@@ -27165,9 +27417,9 @@ function removeValidationArea(rules, area) {
|
|
|
27165
27417
|
}
|
|
27166
27418
|
|
|
27167
27419
|
// xlsx/edit/conditional-formats.ts
|
|
27168
|
-
function formatAt(sheet,
|
|
27169
|
-
const format = sheet.conditionalFormats[
|
|
27170
|
-
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}`);
|
|
27171
27423
|
return format;
|
|
27172
27424
|
}
|
|
27173
27425
|
function rulesByPriority(sheet) {
|
|
@@ -27178,9 +27430,9 @@ function renumber(rules) {
|
|
|
27178
27430
|
rule.priority = i2 + 1;
|
|
27179
27431
|
});
|
|
27180
27432
|
}
|
|
27181
|
-
function replaceConditionalFormat(ctx, s,
|
|
27433
|
+
function replaceConditionalFormat(ctx, s, index3, format) {
|
|
27182
27434
|
const sheet = sheetAt(ctx.workbook, s);
|
|
27183
|
-
formatAt(sheet,
|
|
27435
|
+
formatAt(sheet, index3);
|
|
27184
27436
|
if (!format.ranges.length || !format.rules.length)
|
|
27185
27437
|
throw new Error("A conditional format needs at least one range and one rule.");
|
|
27186
27438
|
ctx.run(
|
|
@@ -27190,21 +27442,21 @@ function replaceConditionalFormat(ctx, s, index2, format) {
|
|
|
27190
27442
|
() => {
|
|
27191
27443
|
const next = structuredClone(format);
|
|
27192
27444
|
next.ranges = next.ranges.map(normalizeRange);
|
|
27193
|
-
sheet.conditionalFormats[
|
|
27445
|
+
sheet.conditionalFormats[index3] = next;
|
|
27194
27446
|
renumber(rulesByPriority(sheet));
|
|
27195
27447
|
},
|
|
27196
27448
|
{ sheet: s, ranges: format.ranges }
|
|
27197
27449
|
);
|
|
27198
27450
|
}
|
|
27199
|
-
function removeConditionalFormat(ctx, s,
|
|
27451
|
+
function removeConditionalFormat(ctx, s, index3) {
|
|
27200
27452
|
const sheet = sheetAt(ctx.workbook, s);
|
|
27201
|
-
const format = formatAt(sheet,
|
|
27453
|
+
const format = formatAt(sheet, index3);
|
|
27202
27454
|
ctx.run(
|
|
27203
27455
|
"Delete rule",
|
|
27204
27456
|
"format",
|
|
27205
27457
|
[{ kind: "sheet", sheet: s }],
|
|
27206
27458
|
() => {
|
|
27207
|
-
sheet.conditionalFormats.splice(
|
|
27459
|
+
sheet.conditionalFormats.splice(index3, 1);
|
|
27208
27460
|
renumber(rulesByPriority(sheet));
|
|
27209
27461
|
},
|
|
27210
27462
|
{ sheet: s, ranges: format.ranges }
|
|
@@ -27368,20 +27620,20 @@ function pasteConditionalFormats(sheet, dest, cells, transpose2, skipBlanks, cut
|
|
|
27368
27620
|
// xlsx/edit/annotations.ts
|
|
27369
27621
|
function setComment(ctx, s, at, text3, author) {
|
|
27370
27622
|
const sheet = sheetAt(ctx.workbook, s);
|
|
27371
|
-
const
|
|
27623
|
+
const index3 = sheet.comments.findIndex(
|
|
27372
27624
|
(c2) => c2.address.row === at.row && c2.address.col === at.col
|
|
27373
27625
|
);
|
|
27374
|
-
if (
|
|
27626
|
+
if (index3 < 0 && text3 === void 0) return;
|
|
27375
27627
|
ctx.run(
|
|
27376
|
-
text3 === void 0 ? "Delete comment" :
|
|
27628
|
+
text3 === void 0 ? "Delete comment" : index3 < 0 ? "New comment" : "Edit comment",
|
|
27377
27629
|
"annotations",
|
|
27378
27630
|
[{ kind: "sheet", sheet: s }],
|
|
27379
27631
|
() => {
|
|
27380
27632
|
if (text3 === void 0) {
|
|
27381
|
-
sheet.comments.splice(
|
|
27633
|
+
sheet.comments.splice(index3, 1);
|
|
27382
27634
|
return;
|
|
27383
27635
|
}
|
|
27384
|
-
const existing = sheet.comments[
|
|
27636
|
+
const existing = sheet.comments[index3];
|
|
27385
27637
|
if (existing) {
|
|
27386
27638
|
existing.text = text3;
|
|
27387
27639
|
existing.author = author;
|
|
@@ -29299,7 +29551,7 @@ function replaceAll(ctx, query, replacement) {
|
|
|
29299
29551
|
)
|
|
29300
29552
|
);
|
|
29301
29553
|
const uniqueScopes = scopes.filter(
|
|
29302
|
-
(scope,
|
|
29554
|
+
(scope, index3) => scope.kind !== "refs" || scopes.findIndex((entry3) => entry3.kind === "refs") === index3
|
|
29303
29555
|
);
|
|
29304
29556
|
return ctx.run(
|
|
29305
29557
|
"Replace",
|
|
@@ -29828,9 +30080,9 @@ function setDocumentProperties(ctx, patch3) {
|
|
|
29828
30080
|
}
|
|
29829
30081
|
|
|
29830
30082
|
// xlsx/edit/drawings.ts
|
|
29831
|
-
function drawingAt(ctx, s,
|
|
29832
|
-
const drawing = sheetAt(ctx.workbook, s).drawings[
|
|
29833
|
-
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}`);
|
|
29834
30086
|
return drawing;
|
|
29835
30087
|
}
|
|
29836
30088
|
function checkAnchor(anchor) {
|
|
@@ -29841,8 +30093,8 @@ function checkAnchor(anchor) {
|
|
|
29841
30093
|
if (anchor.ext && !(anchor.ext.cx >= 0 && anchor.ext.cy >= 0))
|
|
29842
30094
|
throw new RangeError("A drawing extent cannot be negative.");
|
|
29843
30095
|
}
|
|
29844
|
-
function setDrawingAnchor(ctx, s,
|
|
29845
|
-
const drawing = drawingAt(ctx, s,
|
|
30096
|
+
function setDrawingAnchor(ctx, s, index3, anchor) {
|
|
30097
|
+
const drawing = drawingAt(ctx, s, index3);
|
|
29846
30098
|
checkAnchor(anchor);
|
|
29847
30099
|
ctx.run(
|
|
29848
30100
|
"Move object",
|
|
@@ -29854,15 +30106,15 @@ function setDrawingAnchor(ctx, s, index2, anchor) {
|
|
|
29854
30106
|
{ sheet: s }
|
|
29855
30107
|
);
|
|
29856
30108
|
}
|
|
29857
|
-
function deleteDrawing(ctx, s,
|
|
29858
|
-
drawingAt(ctx, s,
|
|
30109
|
+
function deleteDrawing(ctx, s, index3) {
|
|
30110
|
+
drawingAt(ctx, s, index3);
|
|
29859
30111
|
const sheet = sheetAt(ctx.workbook, s);
|
|
29860
30112
|
ctx.run(
|
|
29861
30113
|
"Delete object",
|
|
29862
30114
|
"annotations",
|
|
29863
30115
|
[{ kind: "sheet", sheet: s }],
|
|
29864
30116
|
() => {
|
|
29865
|
-
sheet.drawings.splice(
|
|
30117
|
+
sheet.drawings.splice(index3, 1);
|
|
29866
30118
|
},
|
|
29867
30119
|
{ sheet: s }
|
|
29868
30120
|
);
|
|
@@ -29923,8 +30175,8 @@ function patchSparklineNode(node, patch3) {
|
|
|
29923
30175
|
if (old) node.replaceChild(replacement, old);
|
|
29924
30176
|
else {
|
|
29925
30177
|
const before = elements(node).find((child3) => {
|
|
29926
|
-
const
|
|
29927
|
-
return
|
|
30178
|
+
const index3 = COLORS2.indexOf(child3.localName);
|
|
30179
|
+
return index3 > COLORS2.indexOf(key) || child3.localName === "f" || child3.localName === "sparklines";
|
|
29928
30180
|
});
|
|
29929
30181
|
node.insertBefore(replacement, before ?? null);
|
|
29930
30182
|
}
|
|
@@ -29952,8 +30204,8 @@ function editSparklineXml(sheet, edit) {
|
|
|
29952
30204
|
function appendSparklineXml(sheet, groupXml2) {
|
|
29953
30205
|
const source2 = [...sheet.preserved.get("extLst") ?? []];
|
|
29954
30206
|
const found = source2.findIndex((xml) => xml.includes("sparklineGroups"));
|
|
29955
|
-
const
|
|
29956
|
-
const doc = parseXml(source2[
|
|
30207
|
+
const index3 = found >= 0 ? found : 0;
|
|
30208
|
+
const doc = parseXml(source2[index3] ?? `<extLst xmlns="${NS.x}"/>`);
|
|
29957
30209
|
const root = doc.documentElement;
|
|
29958
30210
|
let ext = children(root, "ext", NS.x).find(
|
|
29959
30211
|
(node) => node.getAttribute("uri")?.toUpperCase() === URI2.toUpperCase()
|
|
@@ -29980,7 +30232,7 @@ function appendSparklineXml(sheet, groupXml2) {
|
|
|
29980
30232
|
fresh.setAttributeNS(revision, "xr2:uid", `{${globalThis.crypto.randomUUID().toUpperCase()}}`);
|
|
29981
30233
|
}
|
|
29982
30234
|
groups.appendChild(fresh);
|
|
29983
|
-
source2[
|
|
30235
|
+
source2[index3] = buildXml(root);
|
|
29984
30236
|
return source2;
|
|
29985
30237
|
}
|
|
29986
30238
|
|
|
@@ -30258,6 +30510,7 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
30258
30510
|
valueField: options.valueField,
|
|
30259
30511
|
aggregate: aggregate3,
|
|
30260
30512
|
valueCaption: pivotCaption(aggregate3, options.valueField),
|
|
30513
|
+
...options.pageFilter !== void 0 ? { pageFilter: structuredClone(options.pageFilter) } : {},
|
|
30261
30514
|
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
30262
30515
|
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
30263
30516
|
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
@@ -30293,6 +30546,10 @@ function refreshPivotTable(ctx, s, name, patch3 = {}) {
|
|
|
30293
30546
|
if (patch3.layout !== void 0) next.layout = patch3.layout;
|
|
30294
30547
|
if (patch3.subtotalPosition !== void 0) next.subtotalPosition = patch3.subtotalPosition;
|
|
30295
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
|
+
}
|
|
30296
30553
|
if (patch3.valuesPosition !== void 0) next.valuesPosition = patch3.valuesPosition;
|
|
30297
30554
|
else if (patch3.valuesAxis === "columns" || patch3.secondRowField === "")
|
|
30298
30555
|
delete next.valuesPosition;
|
|
@@ -30387,22 +30644,22 @@ function applyCellStyle(ctx, s, ranges, name) {
|
|
|
30387
30644
|
function sortGradientStops(stops) {
|
|
30388
30645
|
return stops.slice().sort((a2, b) => a2.position - b.position);
|
|
30389
30646
|
}
|
|
30390
|
-
function removeGradientStop(stops,
|
|
30391
|
-
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);
|
|
30392
30649
|
}
|
|
30393
30650
|
|
|
30394
30651
|
// xlsx/edit/chart-series-transparency.ts
|
|
30395
|
-
function chartSeriesSolidColor(chart,
|
|
30396
|
-
const series = chart.series[
|
|
30652
|
+
function chartSeriesSolidColor(chart, index3) {
|
|
30653
|
+
const series = chart.series[index3];
|
|
30397
30654
|
if (!series || series.fill && series.fill.kind !== "solid") return void 0;
|
|
30398
30655
|
return series.fill?.kind === "solid" ? series.fill.color : series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(
|
|
30399
30656
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
30400
|
-
|
|
30657
|
+
index3,
|
|
30401
30658
|
chart.series.length
|
|
30402
30659
|
);
|
|
30403
30660
|
}
|
|
30404
|
-
function chartSeriesTransparency(chart,
|
|
30405
|
-
const color = chartSeriesSolidColor(chart,
|
|
30661
|
+
function chartSeriesTransparency(chart, index3) {
|
|
30662
|
+
const color = chartSeriesSolidColor(chart, index3);
|
|
30406
30663
|
if (!color) return void 0;
|
|
30407
30664
|
const resolved = resolveDrawingColor(
|
|
30408
30665
|
color,
|
|
@@ -30411,11 +30668,11 @@ function chartSeriesTransparency(chart, index2) {
|
|
|
30411
30668
|
);
|
|
30412
30669
|
return resolved ? Math.round((1 - resolved.alpha) * 1e5) / 1e3 : void 0;
|
|
30413
30670
|
}
|
|
30414
|
-
function chartSeriesTransparencyPatch(chart,
|
|
30671
|
+
function chartSeriesTransparencyPatch(chart, index3, percent2) {
|
|
30415
30672
|
if (!Number.isFinite(percent2) || percent2 < 0 || percent2 > 100)
|
|
30416
30673
|
throw new RangeError("Chart transparency must be from 0 to 100");
|
|
30417
|
-
const current = chartSeriesAt(chart,
|
|
30418
|
-
const color = chartSeriesSolidColor(chart,
|
|
30674
|
+
const current = chartSeriesAt(chart, index3);
|
|
30675
|
+
const color = chartSeriesSolidColor(chart, index3);
|
|
30419
30676
|
if (!color) return void 0;
|
|
30420
30677
|
const choice = structuredClone(color);
|
|
30421
30678
|
choice.transforms = choice.transforms.filter(
|
|
@@ -30425,7 +30682,7 @@ function chartSeriesTransparencyPatch(chart, index2, percent2) {
|
|
|
30425
30682
|
choice.transforms.push({ name: "alpha", value: String(Math.round((100 - percent2) * 1e3)) });
|
|
30426
30683
|
if (sameChartColor(choice, color) && !Object.keys(current.pointColors ?? {}).length && !Object.keys(current.pointFills ?? {}).length)
|
|
30427
30684
|
return void 0;
|
|
30428
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
30685
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
30429
30686
|
delete next.fill;
|
|
30430
30687
|
delete next.color;
|
|
30431
30688
|
delete next.pointColors;
|
|
@@ -30435,8 +30692,8 @@ function chartSeriesTransparencyPatch(chart, index2, percent2) {
|
|
|
30435
30692
|
}
|
|
30436
30693
|
|
|
30437
30694
|
// xlsx/edit/chart-series-gradient.ts
|
|
30438
|
-
function chartGradientStopTransparency(fill,
|
|
30439
|
-
const color = fill.stops[
|
|
30695
|
+
function chartGradientStopTransparency(fill, index3) {
|
|
30696
|
+
const color = fill.stops[index3]?.color;
|
|
30440
30697
|
const value2 = color && resolveDrawingColor(color, { scheme: () => "#000000" }, { transformOrder: "document" });
|
|
30441
30698
|
return value2 ? Math.round((1 - value2.alpha) * 1e5) / 1e3 : 0;
|
|
30442
30699
|
}
|
|
@@ -30444,19 +30701,19 @@ function percent(value2) {
|
|
|
30444
30701
|
if (!Number.isFinite(value2) || value2 < 0 || value2 > 100)
|
|
30445
30702
|
throw new RangeError("Gradient value must be from 0 to 100");
|
|
30446
30703
|
}
|
|
30447
|
-
function chartSeriesGradientPatch(chart,
|
|
30448
|
-
const current = chartSeriesAt(chart,
|
|
30704
|
+
function chartSeriesGradientPatch(chart, index3, edit) {
|
|
30705
|
+
const current = chartSeriesAt(chart, index3);
|
|
30449
30706
|
const result2 = chartGradientFillEdit(
|
|
30450
30707
|
current.fill,
|
|
30451
30708
|
edit,
|
|
30452
|
-
chartSeriesSolidColor(chart,
|
|
30709
|
+
chartSeriesSolidColor(chart, index3) ?? chartPaletteSeriesColorChoice(
|
|
30453
30710
|
findChartColorPalette(chart.colorPalette ?? 10) ?? findChartColorPalette(10),
|
|
30454
|
-
|
|
30711
|
+
index3,
|
|
30455
30712
|
chart.series.length
|
|
30456
30713
|
)
|
|
30457
30714
|
);
|
|
30458
30715
|
if (!result2) return void 0;
|
|
30459
|
-
const { series, target: next } = cloneChartSeriesForEdit(chart,
|
|
30716
|
+
const { series, target: next } = cloneChartSeriesForEdit(chart, index3);
|
|
30460
30717
|
next.fill = result2.fill;
|
|
30461
30718
|
delete next.color;
|
|
30462
30719
|
delete next.drawingColor;
|
|
@@ -30652,18 +30909,18 @@ function addChart(ctx, s, chart) {
|
|
|
30652
30909
|
{ sheet: s }
|
|
30653
30910
|
);
|
|
30654
30911
|
}
|
|
30655
|
-
function updateChart(ctx, s,
|
|
30912
|
+
function updateChart(ctx, s, index3, patch3) {
|
|
30656
30913
|
assertBarClusterOptions(patch3);
|
|
30657
30914
|
const sheet = sheetAt(ctx.workbook, s);
|
|
30658
|
-
const chart = sheet.drawings[
|
|
30659
|
-
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}`);
|
|
30660
30917
|
const formatting = patch3.elementFills ? chartWithElementFills(chart, patch3.elementFills).formatting : void 0;
|
|
30661
30918
|
ctx.run(
|
|
30662
30919
|
"Edit chart",
|
|
30663
30920
|
"annotations",
|
|
30664
30921
|
[{ kind: "sheet", sheet: s }],
|
|
30665
30922
|
() => {
|
|
30666
|
-
const live = sheet.drawings[
|
|
30923
|
+
const live = sheet.drawings[index3];
|
|
30667
30924
|
const changes = structuredClone(patch3);
|
|
30668
30925
|
delete changes.elementFills;
|
|
30669
30926
|
if (formatting) live.formatting = formatting;
|
|
@@ -30781,9 +31038,9 @@ function applyTotalsRow(sheet, table2) {
|
|
|
30781
31038
|
|
|
30782
31039
|
// xlsx/edit/table-edits.ts
|
|
30783
31040
|
function tableIndex(sheet, ref) {
|
|
30784
|
-
const
|
|
30785
|
-
if (!sheet.tables[
|
|
30786
|
-
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;
|
|
30787
31044
|
}
|
|
30788
31045
|
var TABLE_NAME = /^[A-Za-z_\\][A-Za-z0-9_.\\]*$/;
|
|
30789
31046
|
function validateTableName(workbook, name, self) {
|
|
@@ -30945,8 +31202,8 @@ function updateTable(ctx, s, ref, patch3) {
|
|
|
30945
31202
|
if (patch3.columns.length !== width) throw new Error("Give one column per table column.");
|
|
30946
31203
|
const before = table2.columns;
|
|
30947
31204
|
table2.columns = structuredClone(patch3.columns);
|
|
30948
|
-
for (const [
|
|
30949
|
-
const sourceId = before[
|
|
31205
|
+
for (const [index3, column] of table2.columns.entries()) {
|
|
31206
|
+
const sourceId = before[index3]?.sourceId;
|
|
30950
31207
|
if (column.sourceId === void 0 && sourceId !== void 0) column.sourceId = sourceId;
|
|
30951
31208
|
}
|
|
30952
31209
|
}
|
|
@@ -31203,8 +31460,8 @@ function setPageBreak(ctx, s, axis, before, present = true) {
|
|
|
31203
31460
|
const sheet = sheetAt(ctx.workbook, s);
|
|
31204
31461
|
const key = axis === "row" ? "rowBreaks" : "colBreaks";
|
|
31205
31462
|
const source2 = sheet.preserved.get(key) ?? [`<${key} xmlns="${NS.x}"/>`];
|
|
31206
|
-
const result2 = source2.flatMap((xml,
|
|
31207
|
-
const next = patch2(xml, before, present &&
|
|
31463
|
+
const result2 = source2.flatMap((xml, index3) => {
|
|
31464
|
+
const next = patch2(xml, before, present && index3 === 0, axis);
|
|
31208
31465
|
return next ? [next] : [];
|
|
31209
31466
|
});
|
|
31210
31467
|
ctx.run(
|
|
@@ -31347,16 +31604,16 @@ function setDefinedName(ctx, name) {
|
|
|
31347
31604
|
entry3.formula = entry3.formula.replace(/^=/, "");
|
|
31348
31605
|
ctx.run("Define name", "names", [{ kind: "meta" }], () => {
|
|
31349
31606
|
const { definedNames } = ctx.workbook;
|
|
31350
|
-
const
|
|
31351
|
-
if (
|
|
31607
|
+
const index3 = definedNames.findIndex((n2) => sameName(n2, name.name, name.localSheet));
|
|
31608
|
+
if (index3 >= 0) definedNames[index3] = entry3;
|
|
31352
31609
|
else definedNames.push(entry3);
|
|
31353
31610
|
});
|
|
31354
31611
|
}
|
|
31355
31612
|
function deleteDefinedName(ctx, name, localSheet) {
|
|
31356
|
-
const
|
|
31357
|
-
if (
|
|
31613
|
+
const index3 = ctx.workbook.definedNames.findIndex((n2) => sameName(n2, name, localSheet));
|
|
31614
|
+
if (index3 < 0) return;
|
|
31358
31615
|
ctx.run("Delete name", "names", [{ kind: "meta" }], () => {
|
|
31359
|
-
ctx.workbook.definedNames.splice(
|
|
31616
|
+
ctx.workbook.definedNames.splice(index3, 1);
|
|
31360
31617
|
});
|
|
31361
31618
|
}
|
|
31362
31619
|
|
|
@@ -31394,7 +31651,7 @@ function normalizeDigestAlgorithmName(name) {
|
|
|
31394
31651
|
|
|
31395
31652
|
// digest/base64.ts
|
|
31396
31653
|
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
31397
|
-
var VALUES = new Map([...ALPHABET].map((char,
|
|
31654
|
+
var VALUES = new Map([...ALPHABET].map((char, index3) => [char, index3]));
|
|
31398
31655
|
function encodeBase64(bytes) {
|
|
31399
31656
|
let out = "";
|
|
31400
31657
|
for (let i2 = 0; i2 < bytes.length; i2 += 3) {
|
|
@@ -31416,7 +31673,7 @@ function decodeBase64(text3) {
|
|
|
31416
31673
|
const out = new Uint8Array(Math.floor(body.length * 3 / 4));
|
|
31417
31674
|
let bits = 0;
|
|
31418
31675
|
let buffer = 0;
|
|
31419
|
-
let
|
|
31676
|
+
let index3 = 0;
|
|
31420
31677
|
for (const char of body) {
|
|
31421
31678
|
const value2 = VALUES.get(char);
|
|
31422
31679
|
if (value2 === void 0) return void 0;
|
|
@@ -31424,7 +31681,7 @@ function decodeBase64(text3) {
|
|
|
31424
31681
|
bits += 6;
|
|
31425
31682
|
if (bits >= 8) {
|
|
31426
31683
|
bits -= 8;
|
|
31427
|
-
out[
|
|
31684
|
+
out[index3++] = buffer >> bits & 255;
|
|
31428
31685
|
}
|
|
31429
31686
|
}
|
|
31430
31687
|
return out;
|
|
@@ -31813,7 +32070,7 @@ function i(x, y, z) {
|
|
|
31813
32070
|
}
|
|
31814
32071
|
var T = Array.from(
|
|
31815
32072
|
{ length: 64 },
|
|
31816
|
-
(_,
|
|
32073
|
+
(_, index3) => Math.floor(Math.abs(Math.sin(index3 + 1)) * 2 ** 32)
|
|
31817
32074
|
);
|
|
31818
32075
|
var SHIFTS = [
|
|
31819
32076
|
[7, 12, 17, 22],
|
|
@@ -33571,14 +33828,14 @@ var AxisMetrics = class {
|
|
|
33571
33828
|
constructor(defaultSize, count2, overrides) {
|
|
33572
33829
|
this.defaultSize = defaultSize;
|
|
33573
33830
|
this.count = count2;
|
|
33574
|
-
const sorted2 = [...overrides].filter(([
|
|
33831
|
+
const sorted2 = [...overrides].filter(([index3, size]) => index3 >= 0 && index3 < count2 && size !== defaultSize).sort((a2, b) => a2[0] - b[0]);
|
|
33575
33832
|
this.indices = [];
|
|
33576
33833
|
this.sizes = [];
|
|
33577
33834
|
this.prefix = [];
|
|
33578
33835
|
let delta = 0;
|
|
33579
|
-
for (const [
|
|
33580
|
-
if (this.indices.at(-1) ===
|
|
33581
|
-
this.indices.push(
|
|
33836
|
+
for (const [index3, size] of sorted2) {
|
|
33837
|
+
if (this.indices.at(-1) === index3) continue;
|
|
33838
|
+
this.indices.push(index3);
|
|
33582
33839
|
this.sizes.push(Math.max(0, size));
|
|
33583
33840
|
this.prefix.push(delta);
|
|
33584
33841
|
delta += Math.max(0, size) - defaultSize;
|
|
@@ -33595,24 +33852,24 @@ var AxisMetrics = class {
|
|
|
33595
33852
|
prefix;
|
|
33596
33853
|
totalDelta;
|
|
33597
33854
|
/** Number of custom entries strictly before `index` (binary search). */
|
|
33598
|
-
rank(
|
|
33855
|
+
rank(index3) {
|
|
33599
33856
|
let lo = 0;
|
|
33600
33857
|
let hi = this.indices.length;
|
|
33601
33858
|
while (lo < hi) {
|
|
33602
33859
|
const mid = lo + hi >> 1;
|
|
33603
|
-
if ((this.indices[mid] ?? 0) <
|
|
33860
|
+
if ((this.indices[mid] ?? 0) < index3) lo = mid + 1;
|
|
33604
33861
|
else hi = mid;
|
|
33605
33862
|
}
|
|
33606
33863
|
return lo;
|
|
33607
33864
|
}
|
|
33608
|
-
size(
|
|
33609
|
-
if (
|
|
33610
|
-
const k = this.rank(
|
|
33611
|
-
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;
|
|
33612
33869
|
}
|
|
33613
33870
|
/** Offset of the leading edge of `index` (`index` may equal `count` for the axis end). */
|
|
33614
|
-
start(
|
|
33615
|
-
const i2 = Math.max(0, Math.min(
|
|
33871
|
+
start(index3) {
|
|
33872
|
+
const i2 = Math.max(0, Math.min(index3, this.count));
|
|
33616
33873
|
const k = this.rank(i2);
|
|
33617
33874
|
const before = k < this.indices.length ? this.prefix[k] ?? 0 : this.totalDelta;
|
|
33618
33875
|
return i2 * this.defaultSize + before;
|
|
@@ -33647,13 +33904,13 @@ var AxisMetrics = class {
|
|
|
33647
33904
|
return Math.min(line3, this.count - 1);
|
|
33648
33905
|
}
|
|
33649
33906
|
/** The first line at or after `index` with a non-zero size (or `count - 1`). */
|
|
33650
|
-
firstVisible(
|
|
33651
|
-
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;
|
|
33652
33909
|
return this.count - 1;
|
|
33653
33910
|
}
|
|
33654
33911
|
/** The last line at or before `index` with a non-zero size (or 0). */
|
|
33655
|
-
lastVisible(
|
|
33656
|
-
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;
|
|
33657
33914
|
return 0;
|
|
33658
33915
|
}
|
|
33659
33916
|
/** Largest custom-entry index, or -1. */
|
|
@@ -33870,10 +34127,10 @@ function remapSheets(workbook, map) {
|
|
|
33870
34127
|
});
|
|
33871
34128
|
}
|
|
33872
34129
|
var visibleCount = (workbook) => workbook.sheets.filter((s) => s.state === "visible").length;
|
|
33873
|
-
function nearestVisible(workbook,
|
|
33874
|
-
for (let i2 =
|
|
34130
|
+
function nearestVisible(workbook, index3) {
|
|
34131
|
+
for (let i2 = index3; i2 < workbook.sheets.length; i2++)
|
|
33875
34132
|
if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
33876
|
-
for (let i2 =
|
|
34133
|
+
for (let i2 = index3 - 1; i2 >= 0; i2--) if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
33877
34134
|
return 0;
|
|
33878
34135
|
}
|
|
33879
34136
|
function addSheet(ctx, name, at) {
|
|
@@ -33882,24 +34139,24 @@ function addSheet(ctx, name, at) {
|
|
|
33882
34139
|
const sheetName = name ?? nextSheetName(workbook, ctx.defaultSheetBase);
|
|
33883
34140
|
const problem = validateSheetName(workbook, sheetName);
|
|
33884
34141
|
if (problem) throw new Error(problem);
|
|
33885
|
-
const
|
|
34142
|
+
const index3 = Math.max(0, Math.min(at ?? workbook.sheets.length, workbook.sheets.length));
|
|
33886
34143
|
return ctx.run(
|
|
33887
34144
|
"Insert sheet",
|
|
33888
34145
|
"sheets",
|
|
33889
34146
|
[{ kind: "workbook" }],
|
|
33890
34147
|
() => {
|
|
33891
|
-
workbook.sheets.splice(
|
|
33892
|
-
remapSheets(workbook, (i2) => i2 >=
|
|
33893
|
-
workbook.activeSheet =
|
|
33894
|
-
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;
|
|
33895
34152
|
},
|
|
33896
|
-
{ sheet:
|
|
34153
|
+
{ sheet: index3, structural: true }
|
|
33897
34154
|
);
|
|
33898
34155
|
}
|
|
33899
|
-
function deleteSheet(ctx,
|
|
34156
|
+
function deleteSheet(ctx, index3) {
|
|
33900
34157
|
const { workbook } = ctx;
|
|
33901
34158
|
assertUnlocked(workbook);
|
|
33902
|
-
const sheet = sheetAt(workbook,
|
|
34159
|
+
const sheet = sheetAt(workbook, index3);
|
|
33903
34160
|
if (sheet.state === "visible" && visibleCount(workbook) <= 1)
|
|
33904
34161
|
throw new Error("A workbook must contain at least one visible sheet.");
|
|
33905
34162
|
if (workbook.sheets.some(
|
|
@@ -33914,26 +34171,26 @@ function deleteSheet(ctx, index2) {
|
|
|
33914
34171
|
[{ kind: "workbook" }],
|
|
33915
34172
|
() => {
|
|
33916
34173
|
const tables = sheet.tables.map((t) => t.name);
|
|
33917
|
-
workbook.sheets.splice(
|
|
33918
|
-
remapSheets(workbook, (i2) => i2 ===
|
|
34174
|
+
workbook.sheets.splice(index3, 1);
|
|
34175
|
+
remapSheets(workbook, (i2) => i2 === index3 ? void 0 : i2 > index3 ? i2 - 1 : i2);
|
|
33919
34176
|
rewriteFormulas(workbook, (formula) => deleteSheetInFormula(formula, sheet.name, tables));
|
|
33920
|
-
if (workbook.activeSheet >
|
|
33921
|
-
else if (workbook.activeSheet ===
|
|
34177
|
+
if (workbook.activeSheet > index3) workbook.activeSheet--;
|
|
34178
|
+
else if (workbook.activeSheet === index3)
|
|
33922
34179
|
workbook.activeSheet = nearestVisible(
|
|
33923
34180
|
workbook,
|
|
33924
|
-
Math.min(
|
|
34181
|
+
Math.min(index3, workbook.sheets.length - 1)
|
|
33925
34182
|
);
|
|
33926
34183
|
},
|
|
33927
34184
|
{ structural: true }
|
|
33928
34185
|
);
|
|
33929
34186
|
}
|
|
33930
|
-
function renameSheet(ctx,
|
|
34187
|
+
function renameSheet(ctx, index3, name) {
|
|
33931
34188
|
const { workbook } = ctx;
|
|
33932
34189
|
assertUnlocked(workbook);
|
|
33933
|
-
const sheet = sheetAt(workbook,
|
|
34190
|
+
const sheet = sheetAt(workbook, index3);
|
|
33934
34191
|
const old = sheet.name;
|
|
33935
34192
|
if (old === name) return;
|
|
33936
|
-
const problem = validateSheetName(workbook, name,
|
|
34193
|
+
const problem = validateSheetName(workbook, name, index3);
|
|
33937
34194
|
if (problem) throw new Error(problem);
|
|
33938
34195
|
ctx.run(
|
|
33939
34196
|
"Rename sheet",
|
|
@@ -33943,7 +34200,7 @@ function renameSheet(ctx, index2, name) {
|
|
|
33943
34200
|
rewriteFormulas(workbook, (formula) => renameSheetInFormula(formula, old, name));
|
|
33944
34201
|
sheet.name = name;
|
|
33945
34202
|
},
|
|
33946
|
-
{ sheet:
|
|
34203
|
+
{ sheet: index3, structural: true, calc: { kind: "rename", from: old, to: name } }
|
|
33947
34204
|
);
|
|
33948
34205
|
}
|
|
33949
34206
|
function moveSheet(ctx, from, to) {
|
|
@@ -33986,8 +34243,8 @@ function uniqueTableName(workbook, base, extra) {
|
|
|
33986
34243
|
const stem = base.replace(/_\d+$/, "") || "Table";
|
|
33987
34244
|
for (let n2 = 2; ; n2++) if (!taken.has(`${stem}_${n2}`.toLowerCase())) return `${stem}_${n2}`;
|
|
33988
34245
|
}
|
|
33989
|
-
function namesForCopy(workbook,
|
|
33990
|
-
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);
|
|
33991
34248
|
const taken = new Set(local.map((n2) => n2.name.toLowerCase()));
|
|
33992
34249
|
const global = workbook.definedNames.filter(
|
|
33993
34250
|
(n2) => n2.localSheet === void 0 && !taken.has(n2.name.toLowerCase()) && renameSheetInFormula(n2.formula, from, to) !== n2.formula
|
|
@@ -33997,11 +34254,11 @@ function namesForCopy(workbook, index2, from, to) {
|
|
|
33997
34254
|
formula: renameSheetInFormula(n2.formula, from, to)
|
|
33998
34255
|
}));
|
|
33999
34256
|
}
|
|
34000
|
-
function duplicateSheet(ctx,
|
|
34257
|
+
function duplicateSheet(ctx, index3) {
|
|
34001
34258
|
const { workbook } = ctx;
|
|
34002
34259
|
assertUnlocked(workbook);
|
|
34003
|
-
const sheet = sheetAt(workbook,
|
|
34004
|
-
const at =
|
|
34260
|
+
const sheet = sheetAt(workbook, index3);
|
|
34261
|
+
const at = index3 + 1;
|
|
34005
34262
|
return ctx.run(
|
|
34006
34263
|
"Duplicate sheet",
|
|
34007
34264
|
"sheets",
|
|
@@ -34039,7 +34296,7 @@ function duplicateSheet(ctx, index2) {
|
|
|
34039
34296
|
);
|
|
34040
34297
|
rewriteSheetFormulas(copy, rewrite2);
|
|
34041
34298
|
for (const drawing of copy.drawings) if (drawing.kind === "chart") delete drawing.partName;
|
|
34042
|
-
const copiedNames = namesForCopy(workbook,
|
|
34299
|
+
const copiedNames = namesForCopy(workbook, index3, sheet.name, copy.name);
|
|
34043
34300
|
for (const name of copiedNames) name.formula = rewrite2(name.formula);
|
|
34044
34301
|
workbook.sheets.splice(at, 0, copy);
|
|
34045
34302
|
remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
|
|
@@ -34050,9 +34307,9 @@ function duplicateSheet(ctx, index2) {
|
|
|
34050
34307
|
{ sheet: at, structural: true }
|
|
34051
34308
|
);
|
|
34052
34309
|
}
|
|
34053
|
-
function setSheetState(ctx,
|
|
34310
|
+
function setSheetState(ctx, index3, state) {
|
|
34054
34311
|
const { workbook } = ctx;
|
|
34055
|
-
const sheet = sheetAt(workbook,
|
|
34312
|
+
const sheet = sheetAt(workbook, index3);
|
|
34056
34313
|
if (sheet.state === state) return;
|
|
34057
34314
|
assertUnlocked(workbook);
|
|
34058
34315
|
if (state !== "visible") {
|
|
@@ -34062,26 +34319,26 @@ function setSheetState(ctx, index2, state) {
|
|
|
34062
34319
|
ctx.run(
|
|
34063
34320
|
state === "visible" ? "Unhide sheet" : "Hide sheet",
|
|
34064
34321
|
"sheets",
|
|
34065
|
-
[{ kind: "sheet", sheet:
|
|
34322
|
+
[{ kind: "sheet", sheet: index3 }, { kind: "meta" }],
|
|
34066
34323
|
() => {
|
|
34067
34324
|
sheet.state = state;
|
|
34068
|
-
if (state !== "visible" && workbook.activeSheet ===
|
|
34069
|
-
workbook.activeSheet = nearestVisible(workbook,
|
|
34325
|
+
if (state !== "visible" && workbook.activeSheet === index3)
|
|
34326
|
+
workbook.activeSheet = nearestVisible(workbook, index3);
|
|
34070
34327
|
},
|
|
34071
|
-
{ sheet:
|
|
34328
|
+
{ sheet: index3, structural: true }
|
|
34072
34329
|
);
|
|
34073
34330
|
}
|
|
34074
|
-
function setTabColor(ctx,
|
|
34075
|
-
const sheet = sheetAt(ctx.workbook,
|
|
34331
|
+
function setTabColor(ctx, index3, color) {
|
|
34332
|
+
const sheet = sheetAt(ctx.workbook, index3);
|
|
34076
34333
|
ctx.run(
|
|
34077
34334
|
"Tab color",
|
|
34078
34335
|
"sheets",
|
|
34079
|
-
[{ kind: "sheet", sheet:
|
|
34336
|
+
[{ kind: "sheet", sheet: index3 }],
|
|
34080
34337
|
() => {
|
|
34081
34338
|
if (color) sheet.tabColor = { ...color };
|
|
34082
34339
|
else Reflect.deleteProperty(sheet, "tabColor");
|
|
34083
34340
|
},
|
|
34084
|
-
{ sheet:
|
|
34341
|
+
{ sheet: index3 }
|
|
34085
34342
|
);
|
|
34086
34343
|
}
|
|
34087
34344
|
|
|
@@ -34495,20 +34752,20 @@ function createEditSession(workbook, options = {}) {
|
|
|
34495
34752
|
setSheetView: (s, patch3) => setSheetView(ctx, s, patch3),
|
|
34496
34753
|
setDefinedName: (name) => setDefinedName(ctx, name),
|
|
34497
34754
|
deleteDefinedName: (name, localSheet) => deleteDefinedName(ctx, name, localSheet),
|
|
34498
|
-
setDrawingAnchor: (s,
|
|
34755
|
+
setDrawingAnchor: (s, index3, anchor) => setDrawingAnchor(ctx, s, index3, anchor),
|
|
34499
34756
|
createPivotTable: (s, destination, options2) => createPivotTable(ctx, s, destination, options2),
|
|
34500
34757
|
refreshPivotTable: (s, name, patch3) => refreshPivotTable(ctx, s, name, patch3),
|
|
34501
34758
|
deletePivotTable: (s, name) => deletePivotTable(ctx, s, name),
|
|
34502
|
-
deleteDrawing: (s,
|
|
34759
|
+
deleteDrawing: (s, index3) => deleteDrawing(ctx, s, index3),
|
|
34503
34760
|
createSparklineGroup: (s, source2, locations, patch3) => createSparklineGroup(ctx, s, source2, locations, patch3),
|
|
34504
34761
|
setSparklineGroups: (s, ranges, patch3) => setSparklineGroups(ctx, s, ranges, patch3),
|
|
34505
34762
|
setSparklineDateRange: (s, ranges, source2) => setSparklineDateRange(ctx, s, ranges, source2),
|
|
34506
34763
|
deleteSparklines: (s, ranges, wholeGroups) => deleteSparklines(ctx, s, ranges, wholeGroups),
|
|
34507
34764
|
addChart: (s, chart) => addChart(ctx, s, chart),
|
|
34508
|
-
updateChart: (s,
|
|
34765
|
+
updateChart: (s, index3, patch3) => updateChart(ctx, s, index3, patch3),
|
|
34509
34766
|
addImage: (s, bytes, type, anchor, name) => addImage(ctx, s, bytes, type, anchor, name),
|
|
34510
|
-
replaceConditionalFormat: (s,
|
|
34511
|
-
removeConditionalFormat: (s,
|
|
34767
|
+
replaceConditionalFormat: (s, index3, cf) => replaceConditionalFormat(ctx, s, index3, cf),
|
|
34768
|
+
removeConditionalFormat: (s, index3) => removeConditionalFormat(ctx, s, index3),
|
|
34512
34769
|
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
34513
34770
|
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
34514
34771
|
updateTable: (s, table2, patch3) => updateTable(ctx, s, table2, patch3),
|
|
@@ -34752,12 +35009,12 @@ function mergeDxf(acc, next) {
|
|
|
34752
35009
|
return out;
|
|
34753
35010
|
}
|
|
34754
35011
|
function iconIndex(value2, cuts, list) {
|
|
34755
|
-
let
|
|
35012
|
+
let index3 = 0;
|
|
34756
35013
|
for (let i2 = 1; i2 < cuts.length; i2++) {
|
|
34757
35014
|
const cut = cuts[i2] ?? Infinity;
|
|
34758
|
-
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut)
|
|
35015
|
+
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut) index3 = i2;
|
|
34759
35016
|
}
|
|
34760
|
-
return
|
|
35017
|
+
return index3;
|
|
34761
35018
|
}
|
|
34762
35019
|
function scaleColor(value2, cuts, colors) {
|
|
34763
35020
|
if (!cuts.length || cuts.length !== colors.length) return void 0;
|
|
@@ -35136,10 +35393,10 @@ function createConditionalFormatEvaluator(workbook, sheetIndex2, evaluate, optio
|
|
|
35136
35393
|
}
|
|
35137
35394
|
if (rule.type === "iconSet") {
|
|
35138
35395
|
if (result2.icon || typeof value2 !== "number") return false;
|
|
35139
|
-
const
|
|
35396
|
+
const index3 = iconIndex(value2, thresholds(entry3, rule.thresholds), rule.thresholds);
|
|
35140
35397
|
result2.icon = {
|
|
35141
35398
|
set: rule.iconSet,
|
|
35142
|
-
index: rule.reverse ? rule.thresholds.length - 1 -
|
|
35399
|
+
index: rule.reverse ? rule.thresholds.length - 1 - index3 : index3
|
|
35143
35400
|
};
|
|
35144
35401
|
if (rule.showValue === false) result2.hideValue = true;
|
|
35145
35402
|
return true;
|
|
@@ -35271,19 +35528,19 @@ var filled = (sheet, row2, col) => {
|
|
|
35271
35528
|
const cell = sheet.rows.get(row2)?.get(col);
|
|
35272
35529
|
return cell !== void 0 && (cell.value !== null && cell.value !== "" || cell.formula !== void 0);
|
|
35273
35530
|
};
|
|
35274
|
-
function step(
|
|
35275
|
-
for (let i2 =
|
|
35276
|
-
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;
|
|
35277
35534
|
}
|
|
35278
35535
|
function edge(dir, max, hidden) {
|
|
35279
35536
|
const start = dir > 0 ? max : 0;
|
|
35280
35537
|
if (!hidden(start)) return start;
|
|
35281
35538
|
return step(start, dir > 0 ? -1 : 1, max, hidden);
|
|
35282
35539
|
}
|
|
35283
|
-
function jump(
|
|
35284
|
-
const next = step(
|
|
35285
|
-
if (next ===
|
|
35286
|
-
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)) {
|
|
35287
35544
|
let at = next;
|
|
35288
35545
|
for (; ; ) {
|
|
35289
35546
|
const after = step(at, dir, max, hidden);
|
|
@@ -35291,7 +35548,7 @@ function jump(index2, dir, max, hidden, filledSet) {
|
|
|
35291
35548
|
at = after;
|
|
35292
35549
|
}
|
|
35293
35550
|
}
|
|
35294
|
-
const candidates = [...filledSet].filter((i2) => (dir > 0 ? i2 >
|
|
35551
|
+
const candidates = [...filledSet].filter((i2) => (dir > 0 ? i2 > index3 : i2 < index3) && !hidden(i2));
|
|
35295
35552
|
if (!candidates.length) return edge(dir, max, hidden);
|
|
35296
35553
|
return dir > 0 ? Math.min(...candidates) : Math.max(...candidates);
|
|
35297
35554
|
}
|
|
@@ -35396,7 +35653,7 @@ function autoFitColumnWidth(sheet, workbook, col, measure, mdw = DEFAULT_MAX_DIG
|
|
|
35396
35653
|
// chart/render/chart-colors.ts
|
|
35397
35654
|
function chartColorScheme(theme2) {
|
|
35398
35655
|
const slots = Object.fromEntries(
|
|
35399
|
-
THEME_SLOTS.map((slot2,
|
|
35656
|
+
THEME_SLOTS.map((slot2, index3) => [slot2, `#${themeColor(theme2, index3) ?? "000000"}`])
|
|
35400
35657
|
);
|
|
35401
35658
|
return {
|
|
35402
35659
|
...slots,
|
|
@@ -35415,8 +35672,8 @@ function modulateLuminance(hex, lumMod, lumOff = 0) {
|
|
|
35415
35672
|
const out = hslToRgb(hsl.h, hsl.s, l);
|
|
35416
35673
|
return rgbToUpperHex([out.r, out.g, out.b]);
|
|
35417
35674
|
}
|
|
35418
|
-
function autoSeriesColor(theme2,
|
|
35419
|
-
const i2 = Math.max(0, Math.floor(
|
|
35675
|
+
function autoSeriesColor(theme2, index3) {
|
|
35676
|
+
const i2 = Math.max(0, Math.floor(index3));
|
|
35420
35677
|
return chartPaletteSeriesColor(findChartColorPalette(10), i2, i2 + 1, chartColorScheme(theme2));
|
|
35421
35678
|
}
|
|
35422
35679
|
|
|
@@ -35568,10 +35825,10 @@ function resolveChartStyleDefinition(style2, resolve2) {
|
|
|
35568
35825
|
var NATIVE_COINCIDENT_STOP_RAMP = 1 / 256;
|
|
35569
35826
|
function spreadCoincidentStops(stops) {
|
|
35570
35827
|
const out = [];
|
|
35571
|
-
for (const [
|
|
35572
|
-
const source2 = stops[
|
|
35828
|
+
for (const [index3, stop] of stops.entries()) {
|
|
35829
|
+
const source2 = stops[index3 - 1];
|
|
35573
35830
|
const previous = out.at(-1);
|
|
35574
|
-
const next = stops[
|
|
35831
|
+
const next = stops[index3 + 1];
|
|
35575
35832
|
if (!source2 || !previous || stop.offset !== source2.offset || stop.color === source2.color && (stop.opacity ?? 1) === (source2.opacity ?? 1)) {
|
|
35576
35833
|
out.push(stop);
|
|
35577
35834
|
continue;
|
|
@@ -35821,9 +36078,9 @@ function resolveRef(ref, evaluateRef) {
|
|
|
35821
36078
|
return void 0;
|
|
35822
36079
|
}
|
|
35823
36080
|
}
|
|
35824
|
-
function seriesName(series,
|
|
36081
|
+
function seriesName(series, index3, evaluateRef) {
|
|
35825
36082
|
const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText2).filter((t) => t !== "").join(" ");
|
|
35826
|
-
return fromRef || series.name || `Series${
|
|
36083
|
+
return fromRef || series.name || `Series${index3 + 1}`;
|
|
35827
36084
|
}
|
|
35828
36085
|
function chartSummaryView(chart, theme2, options = {}) {
|
|
35829
36086
|
const evaluateRef = options.evaluateRef ?? (() => []);
|
|
@@ -35893,8 +36150,8 @@ function chartSummaryView(chart, theme2, options = {}) {
|
|
|
35893
36150
|
const points = chart.series[seriesIndex]?.pointColors;
|
|
35894
36151
|
if (points) s.pointColors = s.values.map((_, i2) => drawingColor(points[i2]) ?? s.color);
|
|
35895
36152
|
});
|
|
35896
|
-
series.forEach((s,
|
|
35897
|
-
const source2 = chart.series[
|
|
36153
|
+
series.forEach((s, index3) => {
|
|
36154
|
+
const source2 = chart.series[index3];
|
|
35898
36155
|
if (s.gradient && !radial && s.pointColors) {
|
|
35899
36156
|
for (let i2 = 0; i2 < s.pointColors.length; i2++)
|
|
35900
36157
|
if (!source2.pointColors?.[i2]) delete s.pointColors[i2];
|
|
@@ -36048,15 +36305,15 @@ function chartGradientPaint(model, width = 1024, height = 768) {
|
|
|
36048
36305
|
fillColor: paint(entry3.gradient, part, { width, height, shape: "rect" })
|
|
36049
36306
|
};
|
|
36050
36307
|
}
|
|
36051
|
-
const series = model.series.map((source2,
|
|
36308
|
+
const series = model.series.map((source2, index3) => {
|
|
36052
36309
|
const view = { ...source2 };
|
|
36053
|
-
if (source2.shadow) view.shadowFilter = shadowPaint(source2.shadow, `s${
|
|
36310
|
+
if (source2.shadow) view.shadowFilter = shadowPaint(source2.shadow, `s${index3}-shadow`);
|
|
36054
36311
|
const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
|
|
36055
|
-
if (source2.gradient) view.color = paint(source2.gradient, `s${
|
|
36312
|
+
if (source2.gradient) view.color = paint(source2.gradient, `s${index3}`, bounds);
|
|
36056
36313
|
if (source2.pointGradients) {
|
|
36057
36314
|
view.pointColors = [...source2.pointColors ?? []];
|
|
36058
36315
|
for (const [key, gradient] of Object.entries(source2.pointGradients))
|
|
36059
|
-
view.pointColors[Number(key)] = paint(gradient, `s${
|
|
36316
|
+
view.pointColors[Number(key)] = paint(gradient, `s${index3}-p${key}`, bounds);
|
|
36060
36317
|
}
|
|
36061
36318
|
return view;
|
|
36062
36319
|
});
|
|
@@ -36708,8 +36965,8 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36708
36965
|
hardLines.push(line3);
|
|
36709
36966
|
for (const run2 of paragraph2.runs) {
|
|
36710
36967
|
const pieces = run2.text.split("\n");
|
|
36711
|
-
for (const [
|
|
36712
|
-
if (
|
|
36968
|
+
for (const [index3, piece] of pieces.entries()) {
|
|
36969
|
+
if (index3) {
|
|
36713
36970
|
line3 = { ...paragraph2, runs: [] };
|
|
36714
36971
|
hardLines.push(line3);
|
|
36715
36972
|
}
|
|
@@ -36733,11 +36990,11 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36733
36990
|
{ breakWords: true }
|
|
36734
36991
|
);
|
|
36735
36992
|
const { spaceBefore, spaceAfter, ...properties2 } = line3;
|
|
36736
|
-
return wrapped.map((runs,
|
|
36993
|
+
return wrapped.map((runs, index3) => ({
|
|
36737
36994
|
...properties2,
|
|
36738
36995
|
runs,
|
|
36739
|
-
...
|
|
36740
|
-
...
|
|
36996
|
+
...index3 === 0 && spaceBefore ? { spaceBefore } : {},
|
|
36997
|
+
...index3 === wrapped.length - 1 && spaceAfter ? { spaceAfter } : {}
|
|
36741
36998
|
}));
|
|
36742
36999
|
});
|
|
36743
37000
|
const metrics = lines.map((line3) => {
|
|
@@ -36782,9 +37039,9 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
|
|
|
36782
37039
|
);
|
|
36783
37040
|
let baseline = 8 + (metrics[0]?.size ?? base.size ?? 14) + (vertical[0]?.before ?? 0) + (vertical[0]?.leading ?? 0);
|
|
36784
37041
|
const spans2 = [];
|
|
36785
|
-
for (const [
|
|
36786
|
-
if (
|
|
36787
|
-
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;
|
|
36788
37045
|
let x = line3.align === "l" ? (width - boxWidth) / 2 + 4 : line3.align === "r" ? (width + boxWidth) / 2 - 4 - line3.width : (width - line3.width) / 2;
|
|
36789
37046
|
for (const run2 of line3.runs) {
|
|
36790
37047
|
spans2.push(
|
|
@@ -37175,19 +37432,19 @@ function chunks(indices, size, capacity, breaks) {
|
|
|
37175
37432
|
const out = [];
|
|
37176
37433
|
let line3 = [];
|
|
37177
37434
|
let extent2 = 0;
|
|
37178
|
-
for (const
|
|
37435
|
+
for (const index3 of indices) {
|
|
37179
37436
|
let manual = false;
|
|
37180
|
-
while (cursor < sorted2.length && sorted2[cursor] <=
|
|
37437
|
+
while (cursor < sorted2.length && sorted2[cursor] <= index3) {
|
|
37181
37438
|
cursor++;
|
|
37182
37439
|
manual = true;
|
|
37183
37440
|
}
|
|
37184
|
-
if (line3.length && (manual || extent2 + size(
|
|
37441
|
+
if (line3.length && (manual || extent2 + size(index3) > capacity + 1e-3)) {
|
|
37185
37442
|
out.push(line3);
|
|
37186
37443
|
line3 = [];
|
|
37187
37444
|
extent2 = 0;
|
|
37188
37445
|
}
|
|
37189
|
-
line3.push(
|
|
37190
|
-
extent2 += size(
|
|
37446
|
+
line3.push(index3);
|
|
37447
|
+
extent2 += size(index3);
|
|
37191
37448
|
}
|
|
37192
37449
|
if (line3.length) out.push(line3);
|
|
37193
37450
|
return out;
|
|
@@ -37565,6 +37822,8 @@ exports.patchStyle = patchStyle;
|
|
|
37565
37822
|
exports.percentile = percentile;
|
|
37566
37823
|
exports.pictureAnchorAt = pictureAnchorAt;
|
|
37567
37824
|
exports.pivotGrid = pivotGrid;
|
|
37825
|
+
exports.pivotPageItemLabel = pivotItemLabel;
|
|
37826
|
+
exports.pivotPageItems = pivotPageItems;
|
|
37568
37827
|
exports.pivotSourceData = pivotSourceData;
|
|
37569
37828
|
exports.pivotTableAt = pivotTableAt;
|
|
37570
37829
|
exports.pixelBoxToAnchor = pixelBoxToAnchor;
|