ooxml-core 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PptxHandler-DNZHAHUY.cjs +12 -0
- package/dist/PptxHandler-E44KDHMQ.mjs +3 -0
- package/dist/{PptxHandler-EX4WBIQQ.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
- package/dist/automation/index.cjs +3236 -2258
- package/dist/automation/index.mjs +3236 -2258
- package/dist/{chunk-SWF7KVL5.cjs → chunk-2UVH6RHI.cjs} +1608 -1163
- package/dist/{chunk-M76PHYRR.mjs → chunk-7DSZI7S6.mjs} +1 -1
- package/dist/{chunk-AT66SA5M.cjs → chunk-7QZGRB3T.cjs} +28 -10
- package/dist/chunk-ANZ4Q6I3.cjs +21 -0
- package/dist/{chunk-CPKNMQLX.cjs → chunk-AWIDASUW.cjs} +25 -2
- package/dist/{chunk-SVQZXP3F.mjs → chunk-CBNKBVX5.mjs} +25 -2
- package/dist/{chunk-FIELY5PI.mjs → chunk-EC2W2MDY.mjs} +30 -2
- package/dist/chunk-EGTRL3QJ.mjs +19 -0
- package/dist/chunk-GXHKNSZX.mjs +9 -0
- package/dist/{chunk-OXHMZS7B.mjs → chunk-HCXUI5UC.mjs} +943 -273
- package/dist/chunk-HDQXPSHY.cjs +17 -0
- package/dist/chunk-KTYBFGEY.mjs +14 -0
- package/dist/chunk-QOO36KG4.cjs +42 -0
- package/dist/chunk-R2KZXD6U.mjs +39 -0
- package/dist/{chunk-IGOA57LE.mjs → chunk-U2DF3EGK.mjs} +1 -1
- package/dist/{chunk-OB277ZGE.mjs → chunk-UAY26XOI.mjs} +27 -9
- package/dist/{chunk-WSO4T2LJ.mjs → chunk-W5ARCUJB.mjs} +26 -3
- package/dist/chunk-XZPZHXV4.cjs +12 -0
- package/dist/{chunk-LCS3J3QI.mjs → chunk-YB5SRNFS.mjs} +717 -272
- package/dist/docx/layout/adapt-table.d.ts +2 -2
- package/dist/docx/layout/adapt-table.d.ts.map +1 -1
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +554 -83
- package/dist/docx/layout/index.mjs +554 -84
- package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
- package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
- package/dist/docx/layout/nested-frame-profile.d.ts +9 -0
- package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -0
- package/dist/docx/layout/page-cursor.d.ts +2 -0
- package/dist/docx/layout/page-cursor.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +20 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/table-border-layout.d.ts +16 -0
- package/dist/docx/layout/table-border-layout.d.ts.map +1 -0
- package/dist/docx/layout/table-cell-layout.d.ts +3 -2
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-content.d.ts +4 -0
- package/dist/docx/layout/table-content.d.ts.map +1 -0
- package/dist/docx/layout/table-footnotes.d.ts +5 -0
- package/dist/docx/layout/table-footnotes.d.ts.map +1 -1
- package/dist/docx/layout/table-frames.d.ts +4 -0
- package/dist/docx/layout/table-frames.d.ts.map +1 -0
- package/dist/docx/layout/table-layout.d.ts +8 -3
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-note-completion.d.ts +5 -0
- package/dist/docx/layout/table-note-completion.d.ts.map +1 -0
- package/dist/docx/layout/table-note-stories.d.ts +6 -0
- package/dist/docx/layout/table-note-stories.d.ts.map +1 -0
- package/dist/pptx/automation/index.cjs +801 -296
- package/dist/pptx/automation/index.d.ts +5 -4
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{text-operations-BLodkuXE.d.ts → elements-DD3UGOMd.d.ts} +27 -3248
- package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-B4cnSPNz.d.ts → index-BZrFyNtU.d.ts} +113 -5
- package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-BZh-IMkN.d.ts → index-DdX02BSm.d.ts} +19 -3
- package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
- package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
- package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
- package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +801 -296
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +1 -0
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +2 -2
- package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +19 -18
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +3 -2
- package/dist/pptx/editor/render/font-family-update.cjs +14 -0
- package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
- package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
- package/dist/pptx/editor/render/font-family-update.mjs +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
- package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
- package/dist/pptx/editor/render/remap-text.cjs +2 -2
- package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
- package/dist/pptx/editor/render/remap-text.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +9 -8
- package/dist/pptx/editor/render/slide-operations.mjs +3 -2
- package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
- package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
- package/dist/pptx/editor/render/text-content-style.cjs +18 -0
- package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
- package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-content-style.mjs +5 -0
- package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
- package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
- package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
- package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
- package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
- package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
- package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
- package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
- package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
- package/dist/pptx/index.cjs +1091 -296
- package/dist/pptx/index.d.ts +7 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/teams/index.cjs +590 -122
- package/dist/teams/index.mjs +590 -122
- package/dist/visio/date-cache.d.ts +3 -0
- package/dist/visio/date-cache.d.ts.map +1 -0
- package/dist/visio/edit-commands.d.ts +3 -3
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-text-field-commands.d.ts +15 -0
- package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
- package/dist/visio/edit-text-field.d.ts +2 -2
- package/dist/visio/edit-text-field.d.ts.map +1 -1
- package/dist/visio/edit.d.ts +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +501 -220
- package/dist/visio/index.d.ts +1 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +501 -220
- package/dist/visio/model.d.ts +6 -0
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/shape-metadata.d.ts.map +1 -1
- package/dist/visio/shapes.d.ts.map +1 -1
- package/dist/visio/style.d.ts +1 -1
- package/dist/visio/style.d.ts.map +1 -1
- package/dist/visio/text-field-display.d.ts +3 -0
- package/dist/visio/text-field-display.d.ts.map +1 -1
- package/dist/visio/text-field-editability.d.ts +6 -0
- package/dist/visio/text-field-editability.d.ts.map +1 -0
- package/dist/visio/text-field-fraction.d.ts +3 -0
- package/dist/visio/text-field-fraction.d.ts.map +1 -0
- package/dist/visio/text-field-independent.d.ts +4 -0
- package/dist/visio/text-field-independent.d.ts.map +1 -0
- package/dist/visio/text-field-numeric.d.ts +1 -1
- package/dist/visio/text-field-numeric.d.ts.map +1 -1
- package/dist/visio/text-field-source.d.ts +6 -0
- package/dist/visio/text-field-source.d.ts.map +1 -0
- package/dist/visio/text-field-system-date.d.ts +4 -0
- package/dist/visio/text-field-system-date.d.ts.map +1 -0
- package/dist/visio/text-fields.d.ts +1 -0
- package/dist/visio/text-fields.d.ts.map +1 -1
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +514 -221
- package/dist/visio/ui/index.mjs +514 -221
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/visio/ui/text-field-catalog.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1362 -659
- package/dist/xlsx/index.mjs +1361 -660
- package/dist/xlsx/load/index.cjs +1091 -430
- package/dist/xlsx/load/index.mjs +1091 -430
- package/dist/xlsx/model-pivots.d.ts +31 -2
- package/dist/xlsx/model-pivots.d.ts.map +1 -1
- package/dist/xlsx/pivot/admission.d.ts.map +1 -1
- package/dist/xlsx/pivot/aggregate.d.ts +3 -1
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
- package/dist/xlsx/pivot/data.d.ts +2 -2
- package/dist/xlsx/pivot/data.d.ts.map +1 -1
- package/dist/xlsx/pivot/hierarchy-first.d.ts +21 -0
- package/dist/xlsx/pivot/hierarchy-first.d.ts.map +1 -0
- package/dist/xlsx/pivot/hierarchy.d.ts +2 -4
- package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -1
- package/dist/xlsx/pivot/index.d.ts +2 -0
- package/dist/xlsx/pivot/index.d.ts.map +1 -1
- package/dist/xlsx/pivot/measures.d.ts +13 -0
- package/dist/xlsx/pivot/measures.d.ts.map +1 -0
- package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
- package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
- package/dist/xlsx/pivot/page-filter.d.ts +11 -0
- package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
- package/dist/xlsx/pivot/read.d.ts.map +1 -1
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
- package/dist/xlsx/pivot/values-axis.d.ts +12 -0
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +640 -137
- package/dist/xlsx/ui/index.mjs +640 -137
- package/package.json +2 -2
- package/dist/PptxHandler-AT7FVG5Q.mjs +0 -2
- package/dist/PptxHandler-VFSCECPL.cjs +0 -11
- package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +0 -1
- package/dist/pptx/chunks/index-BZh-IMkN.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts +0 -2970
- package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BLodkuXE.d.ts.map +0 -1
package/dist/xlsx/load/index.cjs
CHANGED
|
@@ -1009,7 +1009,7 @@ function i(x, y, z) {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
var T = Array.from(
|
|
1011
1011
|
{ length: 64 },
|
|
1012
|
-
(_,
|
|
1012
|
+
(_, index3) => Math.floor(Math.abs(Math.sin(index3 + 1)) * 2 ** 32)
|
|
1013
1013
|
);
|
|
1014
1014
|
var SHIFTS = [
|
|
1015
1015
|
[7, 12, 17, 22],
|
|
@@ -2537,7 +2537,7 @@ function toArrayBuffer(bytes) {
|
|
|
2537
2537
|
}
|
|
2538
2538
|
function isCompoundFile(input) {
|
|
2539
2539
|
const bytes = toBytes(input);
|
|
2540
|
-
return bytes.length >= 8 && OLE_MAGIC2.every((value2,
|
|
2540
|
+
return bytes.length >= 8 && OLE_MAGIC2.every((value2, index3) => bytes[index3] === value2);
|
|
2541
2541
|
}
|
|
2542
2542
|
function openEncryptedPackage(input) {
|
|
2543
2543
|
const bytes = toBytes(input);
|
|
@@ -3718,7 +3718,7 @@ var PartPatch = class {
|
|
|
3718
3718
|
const { root, children: children2 } = scan(xml);
|
|
3719
3719
|
const kids2 = elements(rootElement);
|
|
3720
3720
|
if (kids2.length !== children2.length) throw new Error("Property part markup is not supported");
|
|
3721
|
-
kids2.forEach((kid,
|
|
3721
|
+
kids2.forEach((kid, index3) => this.spans.set(kid, children2[index3]));
|
|
3722
3722
|
this.root = root;
|
|
3723
3723
|
for (const attribute2 of Array.from(rootElement.attributes)) {
|
|
3724
3724
|
if (attribute2.name === "xmlns") this.defaultNs = attribute2.value;
|
|
@@ -3968,7 +3968,7 @@ function writeAppProperties(props, sourceXml) {
|
|
|
3968
3968
|
const patch = new PartPatch(xml, root);
|
|
3969
3969
|
const prior = readKnown(root, ns);
|
|
3970
3970
|
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
3971
|
-
FIELDS2.forEach(([field, local, kind],
|
|
3971
|
+
FIELDS2.forEach(([field, local, kind], index3) => {
|
|
3972
3972
|
const value2 = props[field];
|
|
3973
3973
|
const existing = first(root, local, ns.app);
|
|
3974
3974
|
if (value2 === void 0 || kind === "text" && value2 === "") {
|
|
@@ -3982,7 +3982,7 @@ function writeAppProperties(props, sourceXml) {
|
|
|
3982
3982
|
patch.setContent(existing, body);
|
|
3983
3983
|
return;
|
|
3984
3984
|
}
|
|
3985
|
-
const next = FIELDS2.slice(
|
|
3985
|
+
const next = FIELDS2.slice(index3 + 1).map(([, name]) => first(root, name, ns.app)).find((node) => node !== void 0);
|
|
3986
3986
|
patch.insert(`<${ownPrefix}${local}>${body}</${ownPrefix}${local}>`, next);
|
|
3987
3987
|
});
|
|
3988
3988
|
return patch.toString();
|
|
@@ -4077,9 +4077,9 @@ function writeCustomProperties(properties2) {
|
|
|
4077
4077
|
});
|
|
4078
4078
|
if (!unique2.length) return void 0;
|
|
4079
4079
|
const pids = allocateCustomPropertyIds(unique2);
|
|
4080
|
-
const body = unique2.map((property,
|
|
4080
|
+
const body = unique2.map((property, index3) => {
|
|
4081
4081
|
const link = property.linkTarget ? ` linkTarget="${escape(property.linkTarget, true)}"` : "";
|
|
4082
|
-
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[
|
|
4082
|
+
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[index3] ?? index3 + 2}" name="${escape(property.name, true)}"${link}>${variantXml(property)}</property>`;
|
|
4083
4083
|
}).join("");
|
|
4084
4084
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
4085
4085
|
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
@@ -5304,10 +5304,10 @@ var MONTH_NAMES = [
|
|
|
5304
5304
|
function monthFromName(name) {
|
|
5305
5305
|
const lower2 = name.toLowerCase();
|
|
5306
5306
|
if (lower2.length < 3) return void 0;
|
|
5307
|
-
const
|
|
5307
|
+
const index3 = MONTH_NAMES.findIndex(
|
|
5308
5308
|
(m) => m.startsWith(lower2) || lower2.length > 3 && lower2 === m
|
|
5309
5309
|
);
|
|
5310
|
-
return
|
|
5310
|
+
return index3 < 0 ? void 0 : index3 + 1;
|
|
5311
5311
|
}
|
|
5312
5312
|
function fullYear(text) {
|
|
5313
5313
|
const y = Number(text);
|
|
@@ -5534,10 +5534,10 @@ function internStyle(workbook, style2) {
|
|
|
5534
5534
|
const known = cache2.get(key);
|
|
5535
5535
|
if (known !== void 0 && workbook.styles[known] && styleKey(workbook.styles[known]) === key)
|
|
5536
5536
|
return known;
|
|
5537
|
-
const
|
|
5538
|
-
if (
|
|
5539
|
-
cache2.set(key,
|
|
5540
|
-
return
|
|
5537
|
+
const index3 = workbook.styles.findIndex((candidate) => styleKey(candidate) === key);
|
|
5538
|
+
if (index3 >= 0) {
|
|
5539
|
+
cache2.set(key, index3);
|
|
5540
|
+
return index3;
|
|
5541
5541
|
}
|
|
5542
5542
|
workbook.styles.push(style2);
|
|
5543
5543
|
cache2.set(key, workbook.styles.length - 1);
|
|
@@ -5644,7 +5644,7 @@ function createWorksheet(name, sheetId) {
|
|
|
5644
5644
|
function createWorkbook(options = {}) {
|
|
5645
5645
|
const names = options.sheets?.length ? options.sheets : ["Sheet1"];
|
|
5646
5646
|
return {
|
|
5647
|
-
sheets: names.map((name,
|
|
5647
|
+
sheets: names.map((name, index3) => createWorksheet(name, index3 + 1)),
|
|
5648
5648
|
styles: [defaultCellStyle()],
|
|
5649
5649
|
namedStyles: [{ name: "Normal", style: defaultCellStyle(), builtinId: 0 }],
|
|
5650
5650
|
definedNames: [],
|
|
@@ -6419,9 +6419,99 @@ function sparklineDataRange(workbook, sheet, source2) {
|
|
|
6419
6419
|
}
|
|
6420
6420
|
if (ast.type !== "ref" || !ast.ref || !["cell", "area"].includes(ast.ref.kind) || ast.prefix?.book || ast.prefix?.sheet2 || ast.spill)
|
|
6421
6421
|
throw new Error("The reference is not valid.");
|
|
6422
|
-
const
|
|
6423
|
-
if (!workbook.sheets[
|
|
6424
|
-
return { sheet:
|
|
6422
|
+
const index3 = ast.prefix ? workbook.sheets.findIndex((ws) => ws.name.toLowerCase() === ast.prefix.sheet.toLowerCase()) : sheet;
|
|
6423
|
+
if (!workbook.sheets[index3]) throw new Error("The reference is not valid.");
|
|
6424
|
+
return { sheet: index3, range: checkedSparklineRange({ start: ast.ref.start, end: ast.ref.end }) };
|
|
6425
|
+
}
|
|
6426
|
+
|
|
6427
|
+
// xlsx/pivot/page-filter.ts
|
|
6428
|
+
function validatePivotPageFilter(pivot) {
|
|
6429
|
+
const filter2 = pivot.pageFilter;
|
|
6430
|
+
const extras = Array.isArray(pivot.additionalValues) ? pivot.additionalValues : [];
|
|
6431
|
+
if (filter2 === void 0) return;
|
|
6432
|
+
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) || [
|
|
6433
|
+
pivot.rowField,
|
|
6434
|
+
pivot.secondRowField,
|
|
6435
|
+
pivot.columnField,
|
|
6436
|
+
pivot.valueField,
|
|
6437
|
+
...extras.map((v) => v?.field)
|
|
6438
|
+
].includes(filter2.field) || pivot.valuesAxis === "rows")
|
|
6439
|
+
throw new Error("Report filters require Values on columns and a separate source field.");
|
|
6440
|
+
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))
|
|
6441
|
+
throw new Error("Choose a cached literal report filter item.");
|
|
6442
|
+
}
|
|
6443
|
+
function pivotPageProjection(pivot) {
|
|
6444
|
+
const filter2 = pivot.pageFilter;
|
|
6445
|
+
if (!filter2) return pivot;
|
|
6446
|
+
const labels = /* @__PURE__ */ new Map();
|
|
6447
|
+
for (const item of pivotItems(pivot, filter2.field)) {
|
|
6448
|
+
const label3 = String(pivotItemLabel(item)).toLowerCase(), key2 = pivotValueKey(item);
|
|
6449
|
+
if (label3 === "(all)" || labels.has(label3) && labels.get(label3) !== key2)
|
|
6450
|
+
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
6451
|
+
labels.set(label3, key2);
|
|
6452
|
+
}
|
|
6453
|
+
if (filter2.item === void 0) return pivot;
|
|
6454
|
+
const index3 = pivot.fields.indexOf(filter2.field), key = pivotValueKey(filter2.item);
|
|
6455
|
+
const records = pivot.records.filter((record) => pivotValueKey(record[index3] ?? null) === key);
|
|
6456
|
+
if (!records.length) throw new Error("The report filter item is missing from the source.");
|
|
6457
|
+
if (JSON.stringify(records[0][index3] ?? null) !== JSON.stringify(filter2.item))
|
|
6458
|
+
throw new Error("Choose an exact cached literal report filter item.");
|
|
6459
|
+
return { ...pivot, records };
|
|
6460
|
+
}
|
|
6461
|
+
function prependPivotPage(grid, pivot) {
|
|
6462
|
+
if (!pivot.pageFilter) return grid;
|
|
6463
|
+
const width = grid.values[0].length;
|
|
6464
|
+
return {
|
|
6465
|
+
...grid,
|
|
6466
|
+
values: [
|
|
6467
|
+
[
|
|
6468
|
+
pivot.pageFilter.field,
|
|
6469
|
+
pivot.pageFilter.item === void 0 ? "(All)" : pivotItemLabel(pivot.pageFilter.item),
|
|
6470
|
+
...Array(width - 2).fill(null)
|
|
6471
|
+
],
|
|
6472
|
+
Array(width).fill(null),
|
|
6473
|
+
...grid.values
|
|
6474
|
+
],
|
|
6475
|
+
firstDataRow: grid.firstDataRow + 2,
|
|
6476
|
+
...grid.firstHeaderRow !== void 0 ? { firstHeaderRow: grid.firstHeaderRow + 2 } : {},
|
|
6477
|
+
...grid.indents ? { indents: [0, 0, ...grid.indents] } : {}
|
|
6478
|
+
};
|
|
6479
|
+
}
|
|
6480
|
+
var index = (raw2) => raw2 !== null && /^\d+$/.test(raw2.trim()) && Number.isSafeInteger(Number(raw2)) ? Number(raw2) : NaN;
|
|
6481
|
+
function readPivotPageFilter(root, fields, shared) {
|
|
6482
|
+
const list = first(root, "pageFields", NS.x), location = first(root, "location", NS.x);
|
|
6483
|
+
const definitions = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
6484
|
+
if (!list) {
|
|
6485
|
+
if (definitions.some((n) => n.getAttribute("axis") === "axisPage") || location?.hasAttribute("rowPageCount") || location?.hasAttribute("colPageCount"))
|
|
6486
|
+
throw new Error("Unmodeled report filter metadata");
|
|
6487
|
+
return;
|
|
6488
|
+
}
|
|
6489
|
+
if (root.getAttribute("multipleFieldFilters") === "1")
|
|
6490
|
+
throw new Error("Multiple report filters are preserved");
|
|
6491
|
+
const pages = children(list, "pageField", NS.x);
|
|
6492
|
+
if (pages.length !== 1 || list.getAttribute("count") !== "1" || location?.getAttribute("rowPageCount") !== "1" || location.getAttribute("colPageCount") !== "1")
|
|
6493
|
+
throw new Error("Only one report filter is modeled");
|
|
6494
|
+
const page = pages[0], field = index(page.getAttribute("fld"));
|
|
6495
|
+
if (page.getAttribute("hier") !== "-1" || !fields[field] || definitions[field]?.getAttribute("axis") !== "axisPage" || definitions.filter((n) => n.getAttribute("axis") === "axisPage").length !== 1)
|
|
6496
|
+
throw new Error("Unsupported report field");
|
|
6497
|
+
const container2 = first(definitions[field], "items", NS.x);
|
|
6498
|
+
const items = children(container2, "item", NS.x);
|
|
6499
|
+
if (!container2 || index(container2.getAttribute("count")) !== items.length || items.filter((n) => n.getAttribute("t") === "default").length !== 1 || items.at(-1)?.getAttribute("t") !== "default" || items.at(-1)?.hasAttribute("x"))
|
|
6500
|
+
throw new Error("Unsupported report field items");
|
|
6501
|
+
const data = items.slice(0, -1).map((item2) => {
|
|
6502
|
+
const i2 = index(item2.getAttribute("x"));
|
|
6503
|
+
if (item2.hasAttribute("t") || !Number.isInteger(i2) || i2 >= shared[field].length)
|
|
6504
|
+
throw new Error("Invalid report cache item");
|
|
6505
|
+
return i2;
|
|
6506
|
+
});
|
|
6507
|
+
if (new Set(data).size !== data.length || data.length !== shared[field].length)
|
|
6508
|
+
throw new Error("Incomplete report cache items");
|
|
6509
|
+
const item = page.getAttribute("item");
|
|
6510
|
+
if (item === null) return { field: fields[field] };
|
|
6511
|
+
const selected2 = index(item);
|
|
6512
|
+
if (!Number.isInteger(selected2) || selected2 >= data.length)
|
|
6513
|
+
throw new Error("Invalid report item selection");
|
|
6514
|
+
return { field: fields[field], item: shared[field][data[selected2]] };
|
|
6425
6515
|
}
|
|
6426
6516
|
|
|
6427
6517
|
// xlsx/pivot/data.ts
|
|
@@ -6430,10 +6520,10 @@ function pivotValueKey(value2) {
|
|
|
6430
6520
|
return value2 === null || value2 === "" ? "blank" : isCellError(value2) ? `error:${value2.error}` : `${typeof value2}:${String(value2).toLowerCase()}`;
|
|
6431
6521
|
}
|
|
6432
6522
|
function pivotItems(pivot, field) {
|
|
6433
|
-
const
|
|
6523
|
+
const index3 = pivot.fields.indexOf(field);
|
|
6434
6524
|
const items = /* @__PURE__ */ new Map();
|
|
6435
6525
|
for (const record of pivot.records) {
|
|
6436
|
-
const value2 = record[
|
|
6526
|
+
const value2 = record[index3] ?? null;
|
|
6437
6527
|
const key = pivotValueKey(value2);
|
|
6438
6528
|
if (!items.has(key)) items.set(key, value2);
|
|
6439
6529
|
}
|
|
@@ -6451,35 +6541,209 @@ function pivotItemLabel(value2) {
|
|
|
6451
6541
|
return isCellError(value2) ? value2.error : value2;
|
|
6452
6542
|
}
|
|
6453
6543
|
function validatePivotFields(pivot) {
|
|
6544
|
+
validatePivotPageFilter(pivot);
|
|
6454
6545
|
const used = [
|
|
6455
6546
|
pivot.rowField,
|
|
6456
6547
|
...pivot.secondRowField ? [pivot.secondRowField] : [],
|
|
6457
6548
|
...pivot.columnField ? [pivot.columnField] : [],
|
|
6458
6549
|
pivot.valueField
|
|
6459
6550
|
];
|
|
6551
|
+
const extras = pivot.additionalValues ?? [];
|
|
6552
|
+
if (pivot.valuesAxis !== void 0 && !["columns", "rows"].includes(pivot.valuesAxis))
|
|
6553
|
+
throw new Error("Choose a valid Values axis.");
|
|
6554
|
+
if (pivot.valuesPosition !== void 0 && !["last", "between", "first"].includes(pivot.valuesPosition))
|
|
6555
|
+
throw new Error("Choose a valid Values position.");
|
|
6556
|
+
if ((pivot.valuesPosition === "between" || pivot.valuesPosition === "first") && (pivot.valuesAxis !== "rows" || !pivot.secondRowField))
|
|
6557
|
+
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
6558
|
+
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
6559
|
+
throw new Error("Values on rows require multiple measures.");
|
|
6560
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== "Values")
|
|
6561
|
+
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
6562
|
+
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
6563
|
+
(measure) => !measure || !pivot.fields.includes(measure.field) || !PIVOT_AGGREGATES.includes(measure.aggregate) || typeof measure.caption !== "string" || !measure.caption.trim() || measure.caption.length > 255 || pivot.fields.some((field) => field.toLowerCase() === measure.caption.toLowerCase())
|
|
6564
|
+
) || new Set(
|
|
6565
|
+
[pivot.valueCaption, ...extras.map((measure) => measure.caption)].map(
|
|
6566
|
+
(caption) => caption?.toLowerCase()
|
|
6567
|
+
)
|
|
6568
|
+
).size !== extras.length + 1)
|
|
6569
|
+
throw new Error("Choose PivotTable value fields with valid aggregates and unique captions.");
|
|
6460
6570
|
if (pivot.layout !== void 0 && !["tabular", "compact", "outline"].includes(pivot.layout) || pivot.subtotalPosition !== void 0 && !["top", "bottom"].includes(pivot.subtotalPosition) || !PIVOT_AGGREGATES.includes(pivot.aggregate) || used.some((field) => !pivot.fields.includes(field)) || new Set([pivot.rowField, pivot.secondRowField, pivot.columnField].filter(Boolean)).size !== [pivot.rowField, pivot.secondRowField, pivot.columnField].filter(Boolean).length || pivot.subtotals !== void 0 && typeof pivot.subtotals !== "boolean" || pivot.repeatLabels !== void 0 && typeof pivot.repeatLabels !== "boolean")
|
|
6461
6571
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
6462
6572
|
}
|
|
6463
6573
|
|
|
6574
|
+
// xlsx/pivot/measures.ts
|
|
6575
|
+
var pivotMeasures = (pivot) => [
|
|
6576
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
6577
|
+
...pivot.additionalValues ?? []
|
|
6578
|
+
];
|
|
6579
|
+
function aggregate(records, field, type) {
|
|
6580
|
+
if (!records.length) return null;
|
|
6581
|
+
const values2 = records.map((record) => record[field] ?? null);
|
|
6582
|
+
if (type === "count") return values2.filter((value2) => value2 !== null && value2 !== "").length;
|
|
6583
|
+
const error = values2.find(isCellError);
|
|
6584
|
+
if (error) return error;
|
|
6585
|
+
const numbers3 = values2.filter((value2) => typeof value2 === "number");
|
|
6586
|
+
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
6587
|
+
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
6588
|
+
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
6589
|
+
const sum2 = numbers3.reduce((total2, value2) => total2 + value2, 0);
|
|
6590
|
+
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
6591
|
+
}
|
|
6592
|
+
var pivotMeasureNumber = (pivot, records, measure) => aggregate(records, pivot.fields.indexOf(measure.field), measure.aggregate);
|
|
6593
|
+
var pivotNumbers = (pivot, records) => pivotMeasures(pivot).map((measure) => pivotMeasureNumber(pivot, records, measure));
|
|
6594
|
+
function pivotHeaderDimensions(pivot, columnItems, rowLabels) {
|
|
6595
|
+
const measures = 1 + (pivot.additionalValues?.length ?? 0);
|
|
6596
|
+
if (pivot.valuesAxis === "rows")
|
|
6597
|
+
return {
|
|
6598
|
+
rows: (pivot.columnField ? 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
6599
|
+
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
6600
|
+
};
|
|
6601
|
+
return {
|
|
6602
|
+
rows: (pivot.columnField ? measures > 1 ? 3 : 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
6603
|
+
width: rowLabels + (pivot.columnField ? measures === 1 ? Math.max(1, columnItems) + 1 : (columnItems + 1) * measures : measures)
|
|
6604
|
+
};
|
|
6605
|
+
}
|
|
6606
|
+
function pivotHeaders(pivot, columns, labels, label3) {
|
|
6607
|
+
const measures = pivotMeasures(pivot);
|
|
6608
|
+
if (pivot.valuesAxis === "rows") {
|
|
6609
|
+
const rowLabels = pivot.layout === "compact" ? ["Row Labels"] : pivot.valuesPosition === "first" ? ["Values", ...labels] : pivot.valuesPosition === "between" ? [labels[0], "Values", labels[1]] : [...labels, "Values"];
|
|
6610
|
+
return pivot.columnField ? [
|
|
6611
|
+
[
|
|
6612
|
+
...rowLabels.map(() => null),
|
|
6613
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
6614
|
+
...columns.map(() => null)
|
|
6615
|
+
],
|
|
6616
|
+
[...rowLabels, ...columns.map(label3), "Grand Total"]
|
|
6617
|
+
] : [[...rowLabels, null]];
|
|
6618
|
+
}
|
|
6619
|
+
if (!pivot.columnField) return [[...labels, ...measures.map((measure) => measure.caption)]];
|
|
6620
|
+
if (measures.length === 1)
|
|
6621
|
+
return [
|
|
6622
|
+
[
|
|
6623
|
+
pivot.valueCaption,
|
|
6624
|
+
...labels.slice(1).map(() => null),
|
|
6625
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
6626
|
+
...columns.slice(1).map(() => null),
|
|
6627
|
+
null
|
|
6628
|
+
],
|
|
6629
|
+
[...labels, ...columns.map(label3), "Grand Total"]
|
|
6630
|
+
];
|
|
6631
|
+
const { width } = pivotHeaderDimensions(pivot, columns.length, labels.length);
|
|
6632
|
+
const first2 = Array(width).fill(null);
|
|
6633
|
+
first2[labels.length] = pivot.layout === "compact" ? "Column Labels" : pivot.columnField;
|
|
6634
|
+
if (pivot.layout !== "compact") first2[labels.length + 1] = "Values";
|
|
6635
|
+
return [
|
|
6636
|
+
first2,
|
|
6637
|
+
[
|
|
6638
|
+
...labels.map(() => null),
|
|
6639
|
+
...columns.flatMap((column) => [label3(column), ...measures.slice(1).map(() => null)]),
|
|
6640
|
+
...measures.map((measure) => `Total ${measure.caption}`)
|
|
6641
|
+
],
|
|
6642
|
+
[
|
|
6643
|
+
...labels,
|
|
6644
|
+
...columns.flatMap(() => measures.map((measure) => measure.caption)),
|
|
6645
|
+
...measures.map(() => null)
|
|
6646
|
+
]
|
|
6647
|
+
];
|
|
6648
|
+
}
|
|
6649
|
+
|
|
6650
|
+
// xlsx/pivot/hierarchy-first.ts
|
|
6651
|
+
function appendFirstPivotValues(pivot, context) {
|
|
6652
|
+
const {
|
|
6653
|
+
rowItems,
|
|
6654
|
+
secondRowItems,
|
|
6655
|
+
columnItems,
|
|
6656
|
+
children: children2,
|
|
6657
|
+
innerIndices,
|
|
6658
|
+
groups,
|
|
6659
|
+
details,
|
|
6660
|
+
buckets,
|
|
6661
|
+
width,
|
|
6662
|
+
rowLabels,
|
|
6663
|
+
top,
|
|
6664
|
+
bottom,
|
|
6665
|
+
append
|
|
6666
|
+
} = context;
|
|
6667
|
+
const compact = pivot.layout === "compact";
|
|
6668
|
+
const tabular = !pivot.layout || pivot.layout === "tabular";
|
|
6669
|
+
const blank = () => Array(width - rowLabels).fill(null);
|
|
6670
|
+
pivotMeasures(pivot).forEach((measure, m) => {
|
|
6671
|
+
const numbers3 = (keys, records) => [
|
|
6672
|
+
...columnItems.map(
|
|
6673
|
+
(column) => pivotMeasureNumber(
|
|
6674
|
+
pivot,
|
|
6675
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
6676
|
+
measure
|
|
6677
|
+
)
|
|
6678
|
+
),
|
|
6679
|
+
pivotMeasureNumber(pivot, records, measure)
|
|
6680
|
+
];
|
|
6681
|
+
if (!tabular)
|
|
6682
|
+
append([measure.caption, ...Array(rowLabels - 1).fill(null)], blank(), {
|
|
6683
|
+
indices: [m],
|
|
6684
|
+
measure: m
|
|
6685
|
+
});
|
|
6686
|
+
let first2 = true;
|
|
6687
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
6688
|
+
const key = pivotValueKey(outer);
|
|
6689
|
+
const group = groups.get(key) ?? [];
|
|
6690
|
+
if (!tabular)
|
|
6691
|
+
append(
|
|
6692
|
+
compact ? [pivotItemLabel(outer)] : [null, pivotItemLabel(outer), null],
|
|
6693
|
+
top ? numbers3([key], group) : blank(),
|
|
6694
|
+
{ indices: [m, outerIndex], measure: m },
|
|
6695
|
+
compact ? 1 : 0
|
|
6696
|
+
);
|
|
6697
|
+
const innerKeys = [...children2.get(key)].sort(
|
|
6698
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
6699
|
+
);
|
|
6700
|
+
innerKeys.forEach((innerKey, child4) => {
|
|
6701
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
6702
|
+
append(
|
|
6703
|
+
compact ? [pivotItemLabel(secondRowItems[innerIndex])] : [
|
|
6704
|
+
tabular && first2 ? measure.caption : null,
|
|
6705
|
+
pivot.repeatLabels || tabular && child4 === 0 ? pivotItemLabel(outer) : null,
|
|
6706
|
+
pivotItemLabel(secondRowItems[innerIndex])
|
|
6707
|
+
],
|
|
6708
|
+
numbers3([key, innerKey], details.get(JSON.stringify([key, innerKey]))),
|
|
6709
|
+
{ indices: [m, outerIndex, innerIndex], measure: m },
|
|
6710
|
+
compact ? 2 : 0
|
|
6711
|
+
);
|
|
6712
|
+
first2 = false;
|
|
6713
|
+
});
|
|
6714
|
+
if (bottom)
|
|
6715
|
+
append(
|
|
6716
|
+
compact ? [`${String(pivotItemLabel(outer))} Total`] : [null, `${String(pivotItemLabel(outer))} Total`, null],
|
|
6717
|
+
numbers3([key], group),
|
|
6718
|
+
{ indices: [m, outerIndex], measure: m, type: "default" },
|
|
6719
|
+
compact ? 1 : 0
|
|
6720
|
+
);
|
|
6721
|
+
});
|
|
6722
|
+
});
|
|
6723
|
+
}
|
|
6724
|
+
|
|
6464
6725
|
// xlsx/pivot/hierarchy.ts
|
|
6465
6726
|
var label = pivotItemLabel;
|
|
6466
|
-
function hierarchicalPivotGrid(pivot
|
|
6727
|
+
function hierarchicalPivotGrid(pivot) {
|
|
6467
6728
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
6468
6729
|
const secondRowItems = pivotItems(pivot, pivot.secondRowField);
|
|
6469
6730
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
6470
6731
|
const outerField = pivot.fields.indexOf(pivot.rowField);
|
|
6471
6732
|
const innerField = pivot.fields.indexOf(pivot.secondRowField);
|
|
6472
6733
|
const columnField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
6473
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
6474
6734
|
const layout3 = pivot.layout ?? "tabular";
|
|
6475
6735
|
const compact = layout3 === "compact";
|
|
6476
|
-
const
|
|
6736
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
6737
|
+
const firstValues = rowsAxis && pivot.valuesPosition === "first";
|
|
6738
|
+
const between = rowsAxis && pivot.valuesPosition === "between";
|
|
6739
|
+
const measures = pivotMeasures(pivot);
|
|
6740
|
+
const top = (!rowsAxis || firstValues) && layout3 !== "tabular" && pivot.subtotals !== false && (pivot.subtotalPosition ?? "top") === "top";
|
|
6477
6741
|
const bottom = pivot.subtotals !== false && !top;
|
|
6478
|
-
const rowLabelColumns = compact ? 1 : 2;
|
|
6742
|
+
const rowLabelColumns = compact ? 1 : rowsAxis ? 3 : 2;
|
|
6479
6743
|
const groups = /* @__PURE__ */ new Map();
|
|
6480
6744
|
const details = /* @__PURE__ */ new Map();
|
|
6481
6745
|
const children2 = /* @__PURE__ */ new Map();
|
|
6482
|
-
const innerIndices = new Map(secondRowItems.map((item,
|
|
6746
|
+
const innerIndices = new Map(secondRowItems.map((item, index3) => [pivotValueKey(item), index3]));
|
|
6483
6747
|
const buckets = /* @__PURE__ */ new Map();
|
|
6484
6748
|
const collect = (map, key, record) => {
|
|
6485
6749
|
const list = map.get(key);
|
|
@@ -6499,20 +6763,12 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
6499
6763
|
collect(buckets, JSON.stringify([...key, column]), record);
|
|
6500
6764
|
}
|
|
6501
6765
|
}
|
|
6502
|
-
const
|
|
6503
|
-
|
|
6504
|
-
|
|
6766
|
+
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, rowLabelColumns);
|
|
6767
|
+
const rows = (details.size + rowItems.length * Number(bottom) + 1) * (rowsAxis ? measures.length : 1) + rowItems.length * Number(layout3 !== "tabular") * (firstValues ? measures.length : 1) + (firstValues ? measures.length : between ? rowItems.length * measures.length : details.size) * Number(rowsAxis && layout3 !== "tabular") + dimensions.rows;
|
|
6768
|
+
if (rows * dimensions.width > 1e6) throw new Error("The PivotTable result is too large.");
|
|
6505
6769
|
const labels = compact ? ["Row Labels"] : [pivot.rowField, pivot.secondRowField];
|
|
6506
|
-
const values2 = pivot
|
|
6507
|
-
|
|
6508
|
-
pivot.valueCaption,
|
|
6509
|
-
...compact ? [] : [null],
|
|
6510
|
-
compact ? "Column Labels" : pivot.columnField,
|
|
6511
|
-
...columnItems.slice(1).map(() => null),
|
|
6512
|
-
null
|
|
6513
|
-
],
|
|
6514
|
-
[...labels, ...columnItems.map(label), "Grand Total"]
|
|
6515
|
-
] : [[...labels, pivot.valueCaption]];
|
|
6770
|
+
const values2 = pivotHeaders(pivot, columnItems, labels, label);
|
|
6771
|
+
const firstDataRow = values2.length;
|
|
6516
6772
|
const indents = values2.map(() => 0);
|
|
6517
6773
|
const rowEntries = [];
|
|
6518
6774
|
const append = (labels2, numbers4, entry3, indent = 0) => {
|
|
@@ -6520,91 +6776,187 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
6520
6776
|
rowEntries.push(entry3);
|
|
6521
6777
|
indents.push(indent);
|
|
6522
6778
|
};
|
|
6523
|
-
const
|
|
6779
|
+
const bands = (keys, records) => [
|
|
6524
6780
|
...columnItems.map(
|
|
6525
|
-
(column) =>
|
|
6526
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
6527
|
-
valueField,
|
|
6528
|
-
pivot.aggregate
|
|
6529
|
-
)
|
|
6781
|
+
(column) => pivotNumbers(pivot, buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [])
|
|
6530
6782
|
),
|
|
6531
|
-
|
|
6783
|
+
pivotNumbers(pivot, records)
|
|
6532
6784
|
];
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
const records = details.get(JSON.stringify(keys));
|
|
6547
|
-
if (!records) return;
|
|
6548
|
-
append(
|
|
6549
|
-
compact ? [label(inner)] : [
|
|
6550
|
-
pivot.repeatLabels || layout3 === "tabular" && first2 ? label(outer) : null,
|
|
6551
|
-
label(inner)
|
|
6785
|
+
const numbers3 = (keys, records) => bands(keys, records).flat();
|
|
6786
|
+
const appendMeasures = (labels2, keys, records, indices, type) => {
|
|
6787
|
+
const values3 = bands(keys, records);
|
|
6788
|
+
measures.forEach(
|
|
6789
|
+
(measure, m) => append(
|
|
6790
|
+
type ? [
|
|
6791
|
+
`${type === "grand" ? "Total" : String(labels2[0])} ${measure.caption}`,
|
|
6792
|
+
...Array(rowLabelColumns - 1).fill(null)
|
|
6793
|
+
] : compact ? [measure.caption] : [
|
|
6794
|
+
...labels2.map(
|
|
6795
|
+
(label3) => layout3 === "tabular" && m === 0 || pivot.repeatLabels ? label3 : null
|
|
6796
|
+
),
|
|
6797
|
+
measure.caption
|
|
6552
6798
|
],
|
|
6553
|
-
|
|
6554
|
-
{ indices: [
|
|
6555
|
-
compact ?
|
|
6556
|
-
)
|
|
6557
|
-
|
|
6799
|
+
values3.map((band) => band[m] ?? null),
|
|
6800
|
+
{ indices: type ? indices : [...indices, m], measure: m, ...type ? { type } : {} },
|
|
6801
|
+
compact && !type ? 2 : 0
|
|
6802
|
+
)
|
|
6803
|
+
);
|
|
6804
|
+
};
|
|
6805
|
+
if (firstValues)
|
|
6806
|
+
appendFirstPivotValues(pivot, {
|
|
6807
|
+
rowItems,
|
|
6808
|
+
secondRowItems,
|
|
6809
|
+
columnItems,
|
|
6810
|
+
children: children2,
|
|
6811
|
+
innerIndices,
|
|
6812
|
+
groups,
|
|
6813
|
+
details,
|
|
6814
|
+
buckets,
|
|
6815
|
+
width: dimensions.width,
|
|
6816
|
+
rowLabels: rowLabelColumns,
|
|
6817
|
+
top,
|
|
6818
|
+
bottom,
|
|
6819
|
+
append
|
|
6558
6820
|
});
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6821
|
+
else
|
|
6822
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
6823
|
+
const key = pivotValueKey(outer);
|
|
6824
|
+
if (layout3 !== "tabular")
|
|
6825
|
+
append(
|
|
6826
|
+
[label(outer), ...Array(rowLabelColumns - 1).fill(null)],
|
|
6827
|
+
top ? numbers3([key], groups.get(key) ?? []) : Array(dimensions.width - rowLabelColumns).fill(null),
|
|
6828
|
+
{ indices: [outerIndex] }
|
|
6829
|
+
);
|
|
6830
|
+
let first2 = true;
|
|
6831
|
+
const innerKeys = [...children2.get(key)].sort(
|
|
6832
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
6565
6833
|
);
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6834
|
+
if (between)
|
|
6835
|
+
measures.forEach((measure, m) => {
|
|
6836
|
+
if (layout3 !== "tabular")
|
|
6837
|
+
append(
|
|
6838
|
+
compact ? [measure.caption] : [pivot.repeatLabels ? label(outer) : null, measure.caption, null],
|
|
6839
|
+
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
6840
|
+
{ indices: [outerIndex, m], measure: m },
|
|
6841
|
+
compact ? 1 : 0
|
|
6842
|
+
);
|
|
6843
|
+
innerKeys.forEach((innerKey, child4) => {
|
|
6844
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
6845
|
+
const keys = [key, innerKey];
|
|
6846
|
+
const records = details.get(JSON.stringify(keys));
|
|
6847
|
+
append(
|
|
6848
|
+
compact ? [label(secondRowItems[innerIndex])] : [
|
|
6849
|
+
pivot.repeatLabels || layout3 === "tabular" && m === 0 && child4 === 0 ? label(outer) : null,
|
|
6850
|
+
layout3 === "tabular" && child4 === 0 ? measure.caption : null,
|
|
6851
|
+
label(secondRowItems[innerIndex])
|
|
6852
|
+
],
|
|
6853
|
+
[
|
|
6854
|
+
...columnItems.map(
|
|
6855
|
+
(column) => pivotMeasureNumber(
|
|
6856
|
+
pivot,
|
|
6857
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
6858
|
+
measure
|
|
6859
|
+
)
|
|
6860
|
+
),
|
|
6861
|
+
pivotMeasureNumber(pivot, records, measure)
|
|
6862
|
+
],
|
|
6863
|
+
{ indices: [outerIndex, m, innerIndex], measure: m },
|
|
6864
|
+
compact ? 2 : 0
|
|
6865
|
+
);
|
|
6866
|
+
});
|
|
6867
|
+
});
|
|
6868
|
+
else
|
|
6869
|
+
innerKeys.forEach((innerKey) => {
|
|
6870
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
6871
|
+
const inner = secondRowItems[innerIndex];
|
|
6872
|
+
const keys = [key, innerKey];
|
|
6873
|
+
const records = details.get(JSON.stringify(keys));
|
|
6874
|
+
if (!records) return;
|
|
6875
|
+
if (rowsAxis) {
|
|
6876
|
+
if (layout3 !== "tabular")
|
|
6877
|
+
append(
|
|
6878
|
+
compact ? [label(inner)] : [pivot.repeatLabels ? label(outer) : null, label(inner), null],
|
|
6879
|
+
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
6880
|
+
{ indices: [outerIndex, innerIndex] },
|
|
6881
|
+
compact ? 1 : 0
|
|
6882
|
+
);
|
|
6883
|
+
appendMeasures(
|
|
6884
|
+
[pivot.repeatLabels || first2 ? label(outer) : null, label(inner)],
|
|
6885
|
+
keys,
|
|
6886
|
+
records,
|
|
6887
|
+
[outerIndex, innerIndex]
|
|
6888
|
+
);
|
|
6889
|
+
first2 = false;
|
|
6890
|
+
return;
|
|
6891
|
+
}
|
|
6892
|
+
append(
|
|
6893
|
+
compact ? [label(inner)] : [
|
|
6894
|
+
pivot.repeatLabels || layout3 === "tabular" && first2 ? label(outer) : null,
|
|
6895
|
+
label(inner)
|
|
6896
|
+
],
|
|
6897
|
+
numbers3(keys, records),
|
|
6898
|
+
{ indices: [outerIndex, innerIndex] },
|
|
6899
|
+
compact ? 1 : 0
|
|
6900
|
+
);
|
|
6901
|
+
first2 = false;
|
|
6902
|
+
});
|
|
6903
|
+
if (bottom) {
|
|
6904
|
+
if (rowsAxis) {
|
|
6905
|
+
appendMeasures([label(outer)], [key], groups.get(key) ?? [], [outerIndex], "default");
|
|
6906
|
+
return;
|
|
6907
|
+
}
|
|
6908
|
+
const caption = String(label(outer));
|
|
6909
|
+
append(
|
|
6910
|
+
[`${caption} Total`, ...compact ? [] : [null]],
|
|
6911
|
+
numbers3([key], groups.get(key) ?? []),
|
|
6912
|
+
{ indices: [outerIndex], type: "default" }
|
|
6913
|
+
);
|
|
6914
|
+
}
|
|
6915
|
+
});
|
|
6916
|
+
if (rowsAxis) appendMeasures([], [], pivot.records, [0], "grand");
|
|
6917
|
+
else
|
|
6918
|
+
append(["Grand Total", ...compact ? [] : [null]], numbers3([], pivot.records), {
|
|
6919
|
+
indices: [0],
|
|
6920
|
+
type: "grand"
|
|
6921
|
+
});
|
|
6572
6922
|
return {
|
|
6573
6923
|
values: values2,
|
|
6574
6924
|
rowItems,
|
|
6575
6925
|
secondRowItems,
|
|
6576
6926
|
columnItems,
|
|
6577
6927
|
rowEntries,
|
|
6578
|
-
firstDataRow
|
|
6928
|
+
firstDataRow,
|
|
6579
6929
|
rowLabelColumns,
|
|
6580
|
-
indents
|
|
6930
|
+
indents,
|
|
6931
|
+
...rowsAxis ? { firstHeaderRow: 1 } : {}
|
|
6581
6932
|
};
|
|
6582
6933
|
}
|
|
6583
6934
|
|
|
6584
6935
|
// xlsx/pivot/aggregate.ts
|
|
6585
|
-
function aggregate(records, field, type) {
|
|
6586
|
-
if (!records.length) return null;
|
|
6587
|
-
const values2 = records.map((record) => record[field] ?? null);
|
|
6588
|
-
if (type === "count") return values2.filter((value2) => value2 !== null && value2 !== "").length;
|
|
6589
|
-
const error = values2.find(isCellError);
|
|
6590
|
-
if (error) return error;
|
|
6591
|
-
const numbers3 = values2.filter((value2) => typeof value2 === "number");
|
|
6592
|
-
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
6593
|
-
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
6594
|
-
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
6595
|
-
const sum2 = numbers3.reduce((total2, value2) => total2 + value2, 0);
|
|
6596
|
-
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
6597
|
-
}
|
|
6598
6936
|
function pivotGrid(pivot) {
|
|
6599
6937
|
validatePivotFields(pivot);
|
|
6600
|
-
|
|
6938
|
+
return prependPivotPage(pivotDataGrid(pivotPageProjection(pivot)), pivot);
|
|
6939
|
+
}
|
|
6940
|
+
function pivotDataGrid(pivot) {
|
|
6941
|
+
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
6601
6942
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
6602
6943
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
6603
|
-
|
|
6944
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
6945
|
+
const compact = pivot.layout === "compact";
|
|
6946
|
+
const headings = rowsAxis && pivot.layout !== void 0 && pivot.layout !== "tabular";
|
|
6947
|
+
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, rowsAxis && !compact ? 2 : 1);
|
|
6948
|
+
const dataRows = (rowItems.length + 1) * (rowsAxis ? 1 + (pivot.additionalValues?.length ?? 0) : 1) + (headings ? rowItems.length : 0);
|
|
6949
|
+
if ((dataRows + dimensions.rows) * dimensions.width > 1e6)
|
|
6604
6950
|
throw new Error("The PivotTable result is too large.");
|
|
6951
|
+
const label3 = pivotItemLabel;
|
|
6952
|
+
const values2 = pivotHeaders(
|
|
6953
|
+
pivot,
|
|
6954
|
+
columnItems,
|
|
6955
|
+
[pivot.layout === "compact" ? "Row Labels" : pivot.rowField],
|
|
6956
|
+
label3
|
|
6957
|
+
);
|
|
6605
6958
|
const rowField = pivot.fields.indexOf(pivot.rowField);
|
|
6606
6959
|
const colField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
6607
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
6608
6960
|
const groups = /* @__PURE__ */ new Map();
|
|
6609
6961
|
const cells = /* @__PURE__ */ new Map();
|
|
6610
6962
|
const columns = /* @__PURE__ */ new Map();
|
|
@@ -6622,50 +6974,95 @@ function pivotGrid(pivot) {
|
|
|
6622
6974
|
collect(cells, JSON.stringify([key, col]), record);
|
|
6623
6975
|
}
|
|
6624
6976
|
}
|
|
6625
|
-
const
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6977
|
+
const firstDataRow = values2.length;
|
|
6978
|
+
if (rowsAxis) {
|
|
6979
|
+
const measures = pivotMeasures(pivot);
|
|
6980
|
+
const rowEntries = [];
|
|
6981
|
+
const indents = values2.map(() => 0);
|
|
6982
|
+
const append = (caption, bands, index3, grand = false) => {
|
|
6983
|
+
measures.forEach((measure, m) => {
|
|
6984
|
+
values2.push([
|
|
6985
|
+
...compact ? [grand ? `Total ${measure.caption}` : measure.caption] : [
|
|
6986
|
+
grand ? `Total ${measure.caption}` : pivot.repeatLabels || !headings && m === 0 ? caption : null,
|
|
6987
|
+
grand ? null : measure.caption
|
|
6988
|
+
],
|
|
6989
|
+
...bands.map((band) => band[m] ?? null)
|
|
6990
|
+
]);
|
|
6991
|
+
indents.push(compact && !grand ? 1 : 0);
|
|
6992
|
+
rowEntries.push({
|
|
6993
|
+
indices: grand ? [0] : [index3, m],
|
|
6994
|
+
measure: m,
|
|
6995
|
+
...grand ? { type: "grand" } : {}
|
|
6996
|
+
});
|
|
6997
|
+
});
|
|
6998
|
+
};
|
|
6999
|
+
rowItems.forEach((item, index3) => {
|
|
7000
|
+
const key = pivotValueKey(item);
|
|
7001
|
+
if (headings) {
|
|
7002
|
+
values2.push([label3(item), ...Array(dimensions.width - 1).fill(null)]);
|
|
7003
|
+
rowEntries.push({ indices: [index3] });
|
|
7004
|
+
indents.push(0);
|
|
7005
|
+
}
|
|
7006
|
+
append(
|
|
7007
|
+
label3(item),
|
|
7008
|
+
[
|
|
7009
|
+
...columnItems.map(
|
|
7010
|
+
(col) => pivotNumbers(pivot, cells.get(JSON.stringify([key, pivotValueKey(col)])) ?? [])
|
|
7011
|
+
),
|
|
7012
|
+
pivotNumbers(pivot, groups.get(key) ?? [])
|
|
7013
|
+
],
|
|
7014
|
+
index3
|
|
7015
|
+
);
|
|
7016
|
+
});
|
|
7017
|
+
append(
|
|
7018
|
+
"Grand Total",
|
|
7019
|
+
[
|
|
7020
|
+
...columnItems.map((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
7021
|
+
pivotNumbers(pivot, pivot.records)
|
|
7022
|
+
],
|
|
7023
|
+
0,
|
|
7024
|
+
true
|
|
7025
|
+
);
|
|
7026
|
+
return {
|
|
7027
|
+
values: values2,
|
|
7028
|
+
rowItems,
|
|
7029
|
+
columnItems,
|
|
7030
|
+
firstDataRow,
|
|
7031
|
+
rowLabelColumns: compact ? 1 : 2,
|
|
7032
|
+
indents,
|
|
7033
|
+
firstHeaderRow: 1,
|
|
7034
|
+
rowEntries
|
|
7035
|
+
};
|
|
7036
|
+
}
|
|
6639
7037
|
for (const row2 of rowItems) {
|
|
6640
7038
|
const records = groups.get(pivotValueKey(row2)) ?? [];
|
|
6641
7039
|
values2.push([
|
|
6642
7040
|
label3(row2),
|
|
6643
|
-
...columnItems.
|
|
6644
|
-
(col) =>
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
pivot.aggregate
|
|
7041
|
+
...columnItems.flatMap(
|
|
7042
|
+
(col) => pivotNumbers(
|
|
7043
|
+
pivot,
|
|
7044
|
+
cells.get(JSON.stringify([pivotValueKey(row2), pivotValueKey(col)])) ?? []
|
|
6648
7045
|
)
|
|
6649
7046
|
),
|
|
6650
|
-
|
|
7047
|
+
...pivotNumbers(pivot, records)
|
|
6651
7048
|
]);
|
|
6652
7049
|
}
|
|
6653
7050
|
values2.push([
|
|
6654
7051
|
"Grand Total",
|
|
6655
|
-
...columnItems.
|
|
6656
|
-
|
|
6657
|
-
),
|
|
6658
|
-
aggregate(pivot.records, valueField, pivot.aggregate)
|
|
7052
|
+
...columnItems.flatMap((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
7053
|
+
...pivotNumbers(pivot, pivot.records)
|
|
6659
7054
|
]);
|
|
6660
|
-
return { values: values2, rowItems, columnItems, firstDataRow
|
|
7055
|
+
return { values: values2, rowItems, columnItems, firstDataRow };
|
|
6661
7056
|
}
|
|
6662
7057
|
|
|
6663
7058
|
// xlsx/pivot/admission.ts
|
|
6664
7059
|
var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
6665
7060
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
6666
7061
|
var TABLE = {
|
|
6667
|
-
pivotTableDefinition: "name cacheId dataCaption updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
|
|
6668
|
-
location: "ref firstHeaderRow firstDataRow firstDataCol",
|
|
7062
|
+
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",
|
|
7063
|
+
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
7064
|
+
pageFields: "count",
|
|
7065
|
+
pageField: "fld item hier",
|
|
6669
7066
|
pivotFields: "count",
|
|
6670
7067
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal",
|
|
6671
7068
|
items: "count",
|
|
@@ -6675,7 +7072,7 @@ var TABLE = {
|
|
|
6675
7072
|
field: "x",
|
|
6676
7073
|
rowItems: "count",
|
|
6677
7074
|
colItems: "count",
|
|
6678
|
-
i: "t r",
|
|
7075
|
+
i: "t r i",
|
|
6679
7076
|
x: "v",
|
|
6680
7077
|
dataFields: "count",
|
|
6681
7078
|
dataField: "name fld subtotal baseField baseItem showDataAs",
|
|
@@ -6706,7 +7103,7 @@ function inspect(node, profile, cache2) {
|
|
|
6706
7103
|
for (let i2 = 0; i2 < node.attributes.length; i2++) {
|
|
6707
7104
|
const attr2 = node.attributes.item(i2);
|
|
6708
7105
|
if (attr2.name.startsWith("xmlns")) continue;
|
|
6709
|
-
if (!cache2 && node.namespaceURI === X14 && node.localName === "pivotTableDefinition" && attr2.name === "hideValuesRow" &&
|
|
7106
|
+
if (!cache2 && node.namespaceURI === X14 && node.localName === "pivotTableDefinition" && attr2.name === "hideValuesRow" && ["0", "1"].includes(attr2.value))
|
|
6710
7107
|
continue;
|
|
6711
7108
|
if (!cache2 && node.namespaceURI === X14 && (node.localName === "pivotField" && attr2.name === "fillDownLabels" || node.localName === "pivotTableDefinition" && attr2.name === "fillDownLabelsDefault") && ["0", "1"].includes(attr2.value))
|
|
6712
7109
|
continue;
|
|
@@ -6735,7 +7132,9 @@ function inspect(node, profile, cache2) {
|
|
|
6735
7132
|
throw new Error("Unsupported PivotTable option");
|
|
6736
7133
|
if (attr2.localName === "numFmtId" && attr2.value !== "0")
|
|
6737
7134
|
throw new Error("Unsupported PivotTable field number format");
|
|
6738
|
-
if (node.localName === "pivotTableDefinition" && ["compact", "compactData", "outline", "outlineData"
|
|
7135
|
+
if (node.localName === "pivotTableDefinition" && ["compact", "compactData", "outline", "outlineData", "dataOnRows"].includes(
|
|
7136
|
+
attr2.localName
|
|
7137
|
+
) && !["0", "1"].includes(attr2.value))
|
|
6739
7138
|
throw new Error("Unsupported PivotTable global layout");
|
|
6740
7139
|
if (node.localName === "item" && attr2.localName === "t" && !["default", "data"].includes(attr2.value))
|
|
6741
7140
|
throw new Error("Unsupported PivotTable subtotal");
|
|
@@ -6758,6 +7157,258 @@ function assertPivotRecords(records) {
|
|
|
6758
7157
|
);
|
|
6759
7158
|
}
|
|
6760
7159
|
|
|
7160
|
+
// xlsx/write/xml-out.ts
|
|
7161
|
+
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
7162
|
+
var CONTROL = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
7163
|
+
var NEEDS_ESCAPE = new RegExp(`[${CONTROL}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
7164
|
+
var ESCAPABLE = new RegExp(`[${CONTROL}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
7165
|
+
function encodeEscapes(text) {
|
|
7166
|
+
if (!NEEDS_ESCAPE.test(text)) return text;
|
|
7167
|
+
return text.replace(
|
|
7168
|
+
ESCAPABLE,
|
|
7169
|
+
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
7170
|
+
);
|
|
7171
|
+
}
|
|
7172
|
+
var INVALID_XML = new RegExp(`[${CONTROL}]`, "g");
|
|
7173
|
+
var escapeText2 = (text) => text.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
7174
|
+
var escapeAttr3 = (text) => text.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
7175
|
+
function attrs(values2) {
|
|
7176
|
+
let out = "";
|
|
7177
|
+
for (const [name, value2] of Object.entries(values2)) {
|
|
7178
|
+
if (value2 === void 0) continue;
|
|
7179
|
+
const text = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num(value2) : value2;
|
|
7180
|
+
out += ` ${name}="${escapeAttr3(text)}"`;
|
|
7181
|
+
}
|
|
7182
|
+
return out;
|
|
7183
|
+
}
|
|
7184
|
+
var el = (name, values2 = {}, content2 = "") => content2 ? `<${name}${attrs(values2)}>${content2}</${name}>` : `<${name}${attrs(values2)}/>`;
|
|
7185
|
+
var num = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
7186
|
+
function tElement(text, name = "t") {
|
|
7187
|
+
const encoded = escapeText2(encodeEscapes(text));
|
|
7188
|
+
const preserve = /^\s|\s$|\n|\t/.test(text) ? ' xml:space="preserve"' : "";
|
|
7189
|
+
return `<${name}${preserve}>${encoded}</${name}>`;
|
|
7190
|
+
}
|
|
7191
|
+
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
7192
|
+
function inlineFragment(xml) {
|
|
7193
|
+
const end = xml.indexOf(">");
|
|
7194
|
+
if (end < 0) return xml;
|
|
7195
|
+
const head = xml.slice(0, end);
|
|
7196
|
+
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
7197
|
+
}
|
|
7198
|
+
|
|
7199
|
+
// xlsx/pivot/values-axis.ts
|
|
7200
|
+
function remapPivotRowEntries(entries, axes2) {
|
|
7201
|
+
return entries.map(
|
|
7202
|
+
(entry3) => entry3.type === "grand" ? entry3 : {
|
|
7203
|
+
...entry3,
|
|
7204
|
+
indices: entry3.indices.map((item, axis) => {
|
|
7205
|
+
const index3 = axes2[axis]?.[item];
|
|
7206
|
+
if (index3 === void 0) throw new Error("Invalid report row axis item");
|
|
7207
|
+
return index3;
|
|
7208
|
+
})
|
|
7209
|
+
}
|
|
7210
|
+
);
|
|
7211
|
+
}
|
|
7212
|
+
function pivotFieldIndex(field) {
|
|
7213
|
+
const raw2 = field?.getAttribute("x");
|
|
7214
|
+
if (raw2 === null || raw2 === void 0 || !/^-?\d+$/.test(raw2.trim())) return NaN;
|
|
7215
|
+
const value2 = Number(raw2);
|
|
7216
|
+
return Number.isSafeInteger(value2) ? value2 : NaN;
|
|
7217
|
+
}
|
|
7218
|
+
function pivotValueIndex(root, axis) {
|
|
7219
|
+
const index3 = axis.findIndex((field) => pivotFieldIndex(field) === -2);
|
|
7220
|
+
const position = root.getAttribute("dataPosition");
|
|
7221
|
+
if (position !== null && (!/^\d+$/.test(position.trim()) || Number(position) !== index3))
|
|
7222
|
+
throw new Error("Inconsistent Values axis position");
|
|
7223
|
+
if (axis.length === 3 && index3 < 2 && position === null)
|
|
7224
|
+
throw new Error("Missing leading or between-field Values position");
|
|
7225
|
+
return index3;
|
|
7226
|
+
}
|
|
7227
|
+
function pivotValueAxisItems(measures, columns, columnIndices) {
|
|
7228
|
+
const entries = [];
|
|
7229
|
+
if (columns === void 0) {
|
|
7230
|
+
for (let measure = 0; measure < measures; measure++)
|
|
7231
|
+
entries.push(
|
|
7232
|
+
`<i${attrs({ i: measure || void 0 })}><x${attrs({ v: measure || void 0 })}/></i>`
|
|
7233
|
+
);
|
|
7234
|
+
} else {
|
|
7235
|
+
for (let column = 0; column < columns; column++)
|
|
7236
|
+
for (let measure = 0; measure < measures; measure++) {
|
|
7237
|
+
entries.push(
|
|
7238
|
+
`<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>`
|
|
7239
|
+
);
|
|
7240
|
+
}
|
|
7241
|
+
for (let measure = 0; measure < measures; measure++)
|
|
7242
|
+
entries.push(`<i${attrs({ t: "grand", i: measure || void 0 })}><x/></i>`);
|
|
7243
|
+
}
|
|
7244
|
+
return `<colItems count="${entries.length}">${entries.join("")}</colItems>`;
|
|
7245
|
+
}
|
|
7246
|
+
function supportedPivotAxes(rows, columns, measures, valuesOnRows) {
|
|
7247
|
+
const index3 = pivotFieldIndex;
|
|
7248
|
+
if (valuesOnRows)
|
|
7249
|
+
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);
|
|
7250
|
+
if (rows.some((field) => !Number.isInteger(index3(field)) || index3(field) < 0)) return false;
|
|
7251
|
+
return measures === 1 ? columns.length <= 1 : columns.length >= 1 && columns.length <= 2 && index3(columns.at(-1)) === -2 && (columns.length !== 2 || index3(columns[0]) >= 0);
|
|
7252
|
+
}
|
|
7253
|
+
|
|
7254
|
+
// drawingml/dom.ts
|
|
7255
|
+
function attributeReader(element2) {
|
|
7256
|
+
return (name) => {
|
|
7257
|
+
if (!element2) return void 0;
|
|
7258
|
+
const direct = element2.getAttribute(name);
|
|
7259
|
+
if (direct !== null) return direct;
|
|
7260
|
+
const attributes = element2.attributes;
|
|
7261
|
+
for (let index3 = 0; index3 < attributes.length; index3++) {
|
|
7262
|
+
const candidate = attributes.item(index3);
|
|
7263
|
+
if (candidate && candidate.localName === name) return candidate.value;
|
|
7264
|
+
}
|
|
7265
|
+
return void 0;
|
|
7266
|
+
};
|
|
7267
|
+
}
|
|
7268
|
+
function stringAttribute(element2, name) {
|
|
7269
|
+
const value2 = attributeReader(element2)(name)?.trim();
|
|
7270
|
+
return value2 ? value2 : void 0;
|
|
7271
|
+
}
|
|
7272
|
+
function integerAttribute(element2, name) {
|
|
7273
|
+
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
7274
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
7275
|
+
}
|
|
7276
|
+
function booleanAttribute(element2, name) {
|
|
7277
|
+
const value2 = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
7278
|
+
if (value2 === "1" || value2 === "true") return true;
|
|
7279
|
+
if (value2 === "0" || value2 === "false") return false;
|
|
7280
|
+
return void 0;
|
|
7281
|
+
}
|
|
7282
|
+
function descendants2(root, local) {
|
|
7283
|
+
const result2 = [];
|
|
7284
|
+
const visit = (node) => {
|
|
7285
|
+
for (const child4 of Array.from(node.childNodes)) {
|
|
7286
|
+
if (!isElement(child4)) continue;
|
|
7287
|
+
if (child4.localName === local) result2.push(child4);
|
|
7288
|
+
visit(child4);
|
|
7289
|
+
}
|
|
7290
|
+
};
|
|
7291
|
+
visit(root);
|
|
7292
|
+
return result2;
|
|
7293
|
+
}
|
|
7294
|
+
|
|
7295
|
+
// xlsx/pivot/page-filter-admission.ts
|
|
7296
|
+
var integer = (value2, fallback) => value2 === null ? fallback ?? NaN : /^\d+$/.test(value2.trim()) && Number.isSafeInteger(Number(value2)) ? Number(value2) : NaN;
|
|
7297
|
+
function assertPageAxisItems(root, pivot, shared, cache2, recordRoot) {
|
|
7298
|
+
if (!pivot.pageFilter) return;
|
|
7299
|
+
const literals = (node) => {
|
|
7300
|
+
const raw2 = node.getAttribute("v");
|
|
7301
|
+
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())))
|
|
7302
|
+
throw new Error("Unmodeled report cache literal");
|
|
7303
|
+
for (const child4 of elements(node)) literals(child4);
|
|
7304
|
+
};
|
|
7305
|
+
literals(cache2);
|
|
7306
|
+
literals(recordRoot);
|
|
7307
|
+
const cacheFields = children(first(cache2, "cacheFields", NS.x), "cacheField", NS.x);
|
|
7308
|
+
if (pivot.columnField) {
|
|
7309
|
+
const column = children(first(root, "pivotFields", NS.x), "pivotField", NS.x)[pivot.fields.indexOf(pivot.columnField)];
|
|
7310
|
+
const list = first(column, "extLst", NS.x);
|
|
7311
|
+
const extensions = list ? children(list, "ext", NS.x) : [];
|
|
7312
|
+
if (extensions.some(
|
|
7313
|
+
(extension) => children(
|
|
7314
|
+
extension,
|
|
7315
|
+
"pivotField",
|
|
7316
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
7317
|
+
).some((field) => {
|
|
7318
|
+
const raw2 = field.getAttribute("fillDownLabels");
|
|
7319
|
+
if (raw2 !== null && !["0", "1", "false", "true"].includes(raw2.trim()))
|
|
7320
|
+
throw new Error("Invalid report column label repetition");
|
|
7321
|
+
return booleanAttribute(field, "fillDownLabels") === true;
|
|
7322
|
+
})
|
|
7323
|
+
))
|
|
7324
|
+
throw new Error("Repeated report column labels are preserved");
|
|
7325
|
+
}
|
|
7326
|
+
if (integer(first(cache2, "cacheFields", NS.x)?.getAttribute("count") ?? null) !== pivot.fields.length || integer(cache2.getAttribute("recordCount")) !== pivot.records.length || integer(recordRoot.getAttribute("count")) !== pivot.records.length)
|
|
7327
|
+
throw new Error("Inconsistent report cache counts");
|
|
7328
|
+
for (const name of [
|
|
7329
|
+
pivot.rowField,
|
|
7330
|
+
pivot.secondRowField,
|
|
7331
|
+
pivot.columnField,
|
|
7332
|
+
pivot.pageFilter.field
|
|
7333
|
+
].filter(Boolean)) {
|
|
7334
|
+
const field = pivot.fields.indexOf(name);
|
|
7335
|
+
if (integer(first(cacheFields[field], "sharedItems", NS.x)?.getAttribute("count") ?? null) !== shared[field].length)
|
|
7336
|
+
throw new Error("Inconsistent report shared-item counts");
|
|
7337
|
+
}
|
|
7338
|
+
for (const name of ["rowFields", "colFields"]) {
|
|
7339
|
+
const list = first(root, name, NS.x);
|
|
7340
|
+
if (list && integer(list.getAttribute("count")) !== children(list, "field", NS.x).length)
|
|
7341
|
+
throw new Error("Inconsistent report axis counts");
|
|
7342
|
+
}
|
|
7343
|
+
const projected = pivotPageProjection(pivot), fields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
7344
|
+
const axisValues = (name, axis) => {
|
|
7345
|
+
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;
|
|
7346
|
+
if (node.getAttribute("axis") !== axis) throw new Error("Inconsistent report axis field");
|
|
7347
|
+
const defaults = node.getAttribute("defaultSubtotal") !== "0";
|
|
7348
|
+
if (!list || integer(list.getAttribute("count")) !== items.length || items.length !== count2 + Number(defaults))
|
|
7349
|
+
throw new Error("Incomplete page-axis field items");
|
|
7350
|
+
const data = items.slice(0, count2).map((item) => {
|
|
7351
|
+
const i2 = integer(item.getAttribute("x"));
|
|
7352
|
+
if (item.hasAttribute("t") || !Number.isInteger(i2) || i2 >= count2)
|
|
7353
|
+
throw new Error("Invalid page-axis cache item");
|
|
7354
|
+
return shared[f6][i2];
|
|
7355
|
+
});
|
|
7356
|
+
if (new Set(data.map(pivotValueKey)).size !== count2 || defaults && (items.at(-1)?.getAttribute("t") !== "default" || items.at(-1)?.hasAttribute("x")))
|
|
7357
|
+
throw new Error("Invalid page-axis default item");
|
|
7358
|
+
const indices = new Map(data.map((v, i2) => [pivotValueKey(v), i2]));
|
|
7359
|
+
return pivotItems(projected, name).map((v) => indices.get(pivotValueKey(v)));
|
|
7360
|
+
};
|
|
7361
|
+
const read = (name) => {
|
|
7362
|
+
const list = first(root, name, NS.x), items = children(list, "i", NS.x);
|
|
7363
|
+
if (!list || integer(list.getAttribute("count")) !== items.length)
|
|
7364
|
+
throw new Error("Invalid page-axis item count");
|
|
7365
|
+
return items;
|
|
7366
|
+
};
|
|
7367
|
+
const rows = axisValues(pivot.rowField, "axisRow"), rowItems = read("rowItems");
|
|
7368
|
+
const grid = pivotGrid(pivot);
|
|
7369
|
+
const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, [
|
|
7370
|
+
rows,
|
|
7371
|
+
pivot.secondRowField ? axisValues(pivot.secondRowField, "axisRow") : []
|
|
7372
|
+
]) : [
|
|
7373
|
+
...rows.map((index3) => ({ indices: [index3], type: void 0 })),
|
|
7374
|
+
{ indices: [0], type: "grand" }
|
|
7375
|
+
];
|
|
7376
|
+
if (rowItems.length !== entries.length) throw new Error("Invalid page row items");
|
|
7377
|
+
let previousRow = [];
|
|
7378
|
+
rowItems.forEach((item, i2) => {
|
|
7379
|
+
const expected2 = entries[i2];
|
|
7380
|
+
const xs = children(item, "x", NS.x).map((x) => integer(x.getAttribute("v"), 0)), prefix = integer(item.getAttribute("r"), 0);
|
|
7381
|
+
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))
|
|
7382
|
+
throw new Error("Unmodeled page row item");
|
|
7383
|
+
previousRow = expected2.type ? [] : expected2.indices;
|
|
7384
|
+
});
|
|
7385
|
+
const measures = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
7386
|
+
if (columns)
|
|
7387
|
+
for (const col of columns)
|
|
7388
|
+
for (let m = 0; m < measures; m++) expected.push(measures > 1 ? [col, m] : [col]);
|
|
7389
|
+
else for (let m = 0; m < measures; m++) expected.push([m]);
|
|
7390
|
+
const colItems = read("colItems");
|
|
7391
|
+
if (colItems.length !== expected.length + (columns ? measures : 0))
|
|
7392
|
+
throw new Error("Invalid page column items");
|
|
7393
|
+
let previous = [];
|
|
7394
|
+
colItems.forEach((item, i2) => {
|
|
7395
|
+
const grand = i2 >= expected.length, measure = grand ? i2 - expected.length : i2 % measures;
|
|
7396
|
+
const xs = children(item, "x", NS.x).map((x) => integer(x.getAttribute("v"), 0)), prefix = integer(item.getAttribute("r"), 0);
|
|
7397
|
+
if (integer(item.getAttribute("i"), 0) !== measure || !Number.isInteger(prefix) || prefix < 0 || prefix > Math.max(0, previous.length - 1))
|
|
7398
|
+
throw new Error("Invalid page column prefix");
|
|
7399
|
+
if (grand) {
|
|
7400
|
+
if (item.getAttribute("t") !== "grand" || prefix !== 0 || xs.length !== 1 || xs[0] !== 0)
|
|
7401
|
+
throw new Error("Unmodeled page grand item");
|
|
7402
|
+
previous = [];
|
|
7403
|
+
return;
|
|
7404
|
+
}
|
|
7405
|
+
const values2 = !columns && measures === 1 && xs.length === 0 && prefix === 0 ? [0] : [...previous.slice(0, prefix), ...xs];
|
|
7406
|
+
if (item.hasAttribute("t") || JSON.stringify(values2) !== JSON.stringify(expected[i2]))
|
|
7407
|
+
throw new Error("Unmodeled page column item");
|
|
7408
|
+
previous = values2;
|
|
7409
|
+
});
|
|
7410
|
+
}
|
|
7411
|
+
|
|
6761
7412
|
// xlsx/pivot/read.ts
|
|
6762
7413
|
function value(node) {
|
|
6763
7414
|
const v = att(node, "v") ?? "";
|
|
@@ -6792,22 +7443,24 @@ function readOne(workbook, source2, part) {
|
|
|
6792
7443
|
const dataSheet = sourceNode && att(sourceNode, "sheet");
|
|
6793
7444
|
const dataRange = sourceNode && parseRange(att(sourceNode, "ref") ?? "");
|
|
6794
7445
|
const recordPart = source2.targetOfType(cachePart, `${NS.r}/pivotCacheRecords`);
|
|
7446
|
+
const rowsAxis = att(root, "dataOnRows") === "1";
|
|
6795
7447
|
if (!dataSheet || !dataRange || !recordPart || !workbook.sheets.some((sheet) => sheet.name === dataSheet))
|
|
6796
7448
|
throw new Error("Unsupported pivot source");
|
|
6797
|
-
|
|
7449
|
+
const recordRoot = parseXml(source2.text(recordPart)).documentElement;
|
|
7450
|
+
assertPivotRecords(recordRoot);
|
|
6798
7451
|
const fields = children(first(cache2, "cacheFields", NS.x), "cacheField", NS.x);
|
|
6799
7452
|
if (fields.some((field) => first(field, "fieldGroup", NS.x) || field.hasAttribute("formula")))
|
|
6800
7453
|
throw new Error("Grouped or calculated cache field");
|
|
6801
7454
|
const shared = fields.map(
|
|
6802
7455
|
(field) => elements(first(field, "sharedItems", NS.x) ?? parseXml("<root/>").documentElement).map(value)
|
|
6803
7456
|
);
|
|
6804
|
-
const records = children(
|
|
7457
|
+
const records = children(recordRoot, "r", NS.x).map(
|
|
6805
7458
|
(record) => elements(record).map((node, field) => {
|
|
6806
7459
|
if (node.localName !== "x") return value(node);
|
|
6807
|
-
const
|
|
6808
|
-
if (!Number.isInteger(
|
|
7460
|
+
const index3 = Number(att(node, "v"));
|
|
7461
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= (shared[field]?.length ?? 0))
|
|
6809
7462
|
throw new Error("Invalid pivot cache index");
|
|
6810
|
-
return shared[field][
|
|
7463
|
+
return shared[field][index3];
|
|
6811
7464
|
})
|
|
6812
7465
|
);
|
|
6813
7466
|
if (records.some((record) => record.length !== fields.length) || records.length * fields.length > 1e6)
|
|
@@ -6827,17 +7480,43 @@ function readOne(workbook, source2, part) {
|
|
|
6827
7480
|
"dataField",
|
|
6828
7481
|
NS.x
|
|
6829
7482
|
);
|
|
6830
|
-
if (rowFields.length < 1 || rowFields.length > 2 ||
|
|
7483
|
+
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")
|
|
6831
7484
|
throw new Error("Unsupported pivot layout");
|
|
7485
|
+
const valueIndex = pivotValueIndex(root, rowsAxis ? rowFields : colFields);
|
|
6832
7486
|
const measure = dataFields[0];
|
|
7487
|
+
const definition = elements(first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement).map(
|
|
7488
|
+
(extension) => first(
|
|
7489
|
+
extension,
|
|
7490
|
+
"pivotTableDefinition",
|
|
7491
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
7492
|
+
)
|
|
7493
|
+
).find(Boolean);
|
|
7494
|
+
if (dataFields.length > 1 && att(definition, "hideValuesRow") !== "1")
|
|
7495
|
+
throw new Error("Visible Values header rows are preserved");
|
|
7496
|
+
for (const [axis, count2] of [
|
|
7497
|
+
["rowItems", rowsAxis ? dataFields.length : 1],
|
|
7498
|
+
["colItems", rowsAxis ? 1 : dataFields.length]
|
|
7499
|
+
]) {
|
|
7500
|
+
for (const item of children(
|
|
7501
|
+
first(root, axis, NS.x) ?? parseXml("<root/>").documentElement,
|
|
7502
|
+
"i",
|
|
7503
|
+
NS.x
|
|
7504
|
+
)) {
|
|
7505
|
+
const index3 = Number(att(item, "i") ?? "0");
|
|
7506
|
+
if (!Number.isInteger(index3) || index3 < 0 || index3 >= count2)
|
|
7507
|
+
throw new Error("Unsupported Values axis item");
|
|
7508
|
+
}
|
|
7509
|
+
}
|
|
6833
7510
|
const aggregate3 = att(measure, "subtotal") ?? "sum";
|
|
6834
7511
|
if (!PIVOT_AGGREGATES.includes(aggregate3) || att(measure, "showDataAs") && att(measure, "showDataAs") !== "normal")
|
|
6835
7512
|
throw new Error("Unsupported pivot aggregate");
|
|
6836
7513
|
const names = fields.map((field) => decodeEscapes(att(field, "name") ?? ""));
|
|
6837
|
-
const
|
|
6838
|
-
const
|
|
7514
|
+
const realRows = rowsAxis ? rowFields.filter((field) => pivotFieldIndex(field) !== -2) : rowFields;
|
|
7515
|
+
const row2 = names[pivotFieldIndex(realRows[0])];
|
|
7516
|
+
const second = realRows[1] ? names[Number(att(realRows[1], "x"))] : void 0;
|
|
7517
|
+
const pageFilter = readPivotPageFilter(root, names, shared);
|
|
6839
7518
|
const tableFields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
6840
|
-
const outer = tableFields[
|
|
7519
|
+
const outer = tableFields[pivotFieldIndex(realRows[0])];
|
|
6841
7520
|
const compact = att(outer, "compact") !== "0";
|
|
6842
7521
|
const outline = att(outer, "outline") !== "0";
|
|
6843
7522
|
const layout3 = compact ? "compact" : outline ? "outline" : "tabular";
|
|
@@ -6846,7 +7525,7 @@ function readOne(workbook, source2, part) {
|
|
|
6846
7525
|
) || att(root, "compact") !== "0" !== compact || att(root, "compactData") !== "0" !== compact || att(root, "outline") === "1" !== outline || att(root, "outlineData") === "1" !== outline || layout3 === "compact" && att(root, "indent") !== "0")
|
|
6847
7526
|
throw new Error("Mixed field layouts or custom compact indentation are preserved");
|
|
6848
7527
|
const subtotal = att(outer, "defaultSubtotal") !== "0";
|
|
6849
|
-
const repeat =
|
|
7528
|
+
const repeat = realRows.map((field) => {
|
|
6850
7529
|
const node = tableFields[Number(att(field, "x"))];
|
|
6851
7530
|
const extension = first(first(node, "extLst", NS.x), "ext", NS.x);
|
|
6852
7531
|
return att(
|
|
@@ -6859,16 +7538,24 @@ function readOne(workbook, source2, part) {
|
|
|
6859
7538
|
) === "1";
|
|
6860
7539
|
});
|
|
6861
7540
|
if (repeat.some((entry4) => entry4 !== repeat[0])) throw new Error("Mixed field label repetition");
|
|
6862
|
-
const
|
|
7541
|
+
const hasColumn = colFields.length > (dataFields.length > 1 && !rowsAxis ? 1 : 0);
|
|
7542
|
+
const col = hasColumn ? names[Number(att(colFields[0], "x"))] : void 0;
|
|
6863
7543
|
const data = names[Number(att(measure, "fld"))];
|
|
6864
7544
|
const location = parseRange(att(first(root, "location", NS.x), "ref") ?? "");
|
|
6865
|
-
if (!row2 || !data || !location ||
|
|
7545
|
+
if (!row2 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
|
|
6866
7546
|
throw new Error("Invalid pivot fields");
|
|
7547
|
+
if (pageFilter) {
|
|
7548
|
+
if (location.start.row < 2) throw new Error("Invalid report filter location");
|
|
7549
|
+
location.start.row -= 2;
|
|
7550
|
+
}
|
|
6867
7551
|
const pivot = {
|
|
7552
|
+
...pageFilter ? { pageFilter } : {},
|
|
6868
7553
|
name: att(root, "name") ?? "PivotTable",
|
|
6869
7554
|
source: `${quoteSheetName(dataSheet)}!${formatRange(dataRange)}`,
|
|
6870
7555
|
rowField: row2,
|
|
6871
7556
|
layout: layout3,
|
|
7557
|
+
...rowsAxis ? { valuesAxis: "rows" } : {},
|
|
7558
|
+
...rowsAxis && realRows.length === 2 && valueIndex < 2 ? { valuesPosition: valueIndex === 0 ? "first" : "between" } : {},
|
|
6872
7559
|
subtotalPosition: att(outer, "subtotalTop") === "0" ? "bottom" : "top",
|
|
6873
7560
|
...second ? { secondRowField: second, subtotals: subtotal, repeatLabels: repeat[0] ?? false } : {
|
|
6874
7561
|
...subtotal ? {} : { subtotals: false },
|
|
@@ -6877,6 +7564,15 @@ function readOne(workbook, source2, part) {
|
|
|
6877
7564
|
valueField: data,
|
|
6878
7565
|
aggregate: aggregate3,
|
|
6879
7566
|
valueCaption: decodeEscapes(att(measure, "name") ?? data),
|
|
7567
|
+
...dataFields.length > 1 ? {
|
|
7568
|
+
additionalValues: dataFields.slice(1).map((measure2) => {
|
|
7569
|
+
const field = names[Number(att(measure2, "fld"))];
|
|
7570
|
+
const aggregate4 = att(measure2, "subtotal") ?? "sum";
|
|
7571
|
+
if (!field || !PIVOT_AGGREGATES.includes(aggregate4) || att(measure2, "showDataAs") && att(measure2, "showDataAs") !== "normal")
|
|
7572
|
+
throw new Error("Unsupported pivot measure");
|
|
7573
|
+
return { field, aggregate: aggregate4, caption: decodeEscapes(att(measure2, "name") ?? field) };
|
|
7574
|
+
})
|
|
7575
|
+
} : {},
|
|
6880
7576
|
fields: names,
|
|
6881
7577
|
records,
|
|
6882
7578
|
location,
|
|
@@ -6885,6 +7581,7 @@ function readOne(workbook, source2, part) {
|
|
|
6885
7581
|
sourceXml: xml,
|
|
6886
7582
|
...col ? { columnField: col } : {}
|
|
6887
7583
|
};
|
|
7584
|
+
assertPageAxisItems(root, pivot, shared, cache2, recordRoot);
|
|
6888
7585
|
return pivot;
|
|
6889
7586
|
}
|
|
6890
7587
|
function readPivotTables(workbook, source2, warn) {
|
|
@@ -7210,10 +7907,10 @@ function parseDynamicArrayMetadata(xml) {
|
|
|
7210
7907
|
const flag2 = props?.getAttribute("fDynamic");
|
|
7211
7908
|
return flag2 === "1" || flag2 === "true";
|
|
7212
7909
|
});
|
|
7213
|
-
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk,
|
|
7910
|
+
childrenNamed(top.get("cellMetadata")?.[0], "bk").forEach((bk, index3) => {
|
|
7214
7911
|
for (const rc of childrenNamed(bk, "rc")) {
|
|
7215
7912
|
const type = types[Number(att(rc, "t")) - 1];
|
|
7216
|
-
if (type === DYNAMIC_ARRAY_TYPE && dynamic[Number(att(rc, "v"))]) out.add(
|
|
7913
|
+
if (type === DYNAMIC_ARRAY_TYPE && dynamic[Number(att(rc, "v"))]) out.add(index3 + 1);
|
|
7217
7914
|
}
|
|
7218
7915
|
});
|
|
7219
7916
|
return out;
|
|
@@ -7491,13 +8188,13 @@ function parseStyles(xml, warnings) {
|
|
|
7491
8188
|
const named2 = namesByXf.get(xfId);
|
|
7492
8189
|
if (named2 && xfId !== 0 && named2 !== "Normal") style2.cellStyleName = named2;
|
|
7493
8190
|
const key = styleKey(style2);
|
|
7494
|
-
let
|
|
7495
|
-
if (
|
|
7496
|
-
|
|
8191
|
+
let index3 = keys.get(key);
|
|
8192
|
+
if (index3 === void 0) {
|
|
8193
|
+
index3 = styles.length;
|
|
7497
8194
|
styles.push(style2);
|
|
7498
|
-
keys.set(key,
|
|
8195
|
+
keys.set(key, index3);
|
|
7499
8196
|
}
|
|
7500
|
-
xfMap.push(
|
|
8197
|
+
xfMap.push(index3);
|
|
7501
8198
|
}
|
|
7502
8199
|
if (!styles.length) {
|
|
7503
8200
|
styles.push(fallback);
|
|
@@ -7511,47 +8208,6 @@ function parseStyles(xml, warnings) {
|
|
|
7511
8208
|
return result2;
|
|
7512
8209
|
}
|
|
7513
8210
|
|
|
7514
|
-
// drawingml/dom.ts
|
|
7515
|
-
function attributeReader(element2) {
|
|
7516
|
-
return (name) => {
|
|
7517
|
-
if (!element2) return void 0;
|
|
7518
|
-
const direct = element2.getAttribute(name);
|
|
7519
|
-
if (direct !== null) return direct;
|
|
7520
|
-
const attributes = element2.attributes;
|
|
7521
|
-
for (let index2 = 0; index2 < attributes.length; index2++) {
|
|
7522
|
-
const candidate = attributes.item(index2);
|
|
7523
|
-
if (candidate && candidate.localName === name) return candidate.value;
|
|
7524
|
-
}
|
|
7525
|
-
return void 0;
|
|
7526
|
-
};
|
|
7527
|
-
}
|
|
7528
|
-
function stringAttribute(element2, name) {
|
|
7529
|
-
const value2 = attributeReader(element2)(name)?.trim();
|
|
7530
|
-
return value2 ? value2 : void 0;
|
|
7531
|
-
}
|
|
7532
|
-
function integerAttribute(element2, name) {
|
|
7533
|
-
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
7534
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
7535
|
-
}
|
|
7536
|
-
function booleanAttribute(element2, name) {
|
|
7537
|
-
const value2 = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
7538
|
-
if (value2 === "1" || value2 === "true") return true;
|
|
7539
|
-
if (value2 === "0" || value2 === "false") return false;
|
|
7540
|
-
return void 0;
|
|
7541
|
-
}
|
|
7542
|
-
function descendants2(root, local) {
|
|
7543
|
-
const result2 = [];
|
|
7544
|
-
const visit = (node) => {
|
|
7545
|
-
for (const child4 of Array.from(node.childNodes)) {
|
|
7546
|
-
if (!isElement(child4)) continue;
|
|
7547
|
-
if (child4.localName === local) result2.push(child4);
|
|
7548
|
-
visit(child4);
|
|
7549
|
-
}
|
|
7550
|
-
};
|
|
7551
|
-
visit(root);
|
|
7552
|
-
return result2;
|
|
7553
|
-
}
|
|
7554
|
-
|
|
7555
8211
|
// drawingml/drawing-color.ts
|
|
7556
8212
|
var COLOR_ELEMENTS = {
|
|
7557
8213
|
srgbClr: "srgb",
|
|
@@ -7697,7 +8353,7 @@ function parseTheme2(xml) {
|
|
|
7697
8353
|
if (!xml) return palette;
|
|
7698
8354
|
const theme = parseTheme(parseXml(xml, { label: "XLSX theme" }));
|
|
7699
8355
|
palette.colors = PALETTE_SLOTS.map(
|
|
7700
|
-
(slot2,
|
|
8356
|
+
(slot2, index3) => paletteHex(theme.colorScheme.colors[slot2]) ?? DEFAULT_THEME.colors[index3] ?? "000000"
|
|
7701
8357
|
);
|
|
7702
8358
|
palette.majorFont = theme.fontScheme.major.latin ?? palette.majorFont;
|
|
7703
8359
|
palette.minorFont = theme.fontScheme.minor.latin ?? palette.minorFont;
|
|
@@ -8085,11 +8741,11 @@ function readModernHash(node, prefix = "") {
|
|
|
8085
8741
|
function parseWorkbookPart(xml) {
|
|
8086
8742
|
const root = parseXml(xml, { label: "XLSX workbook" }).documentElement;
|
|
8087
8743
|
const sheets = [];
|
|
8088
|
-
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node,
|
|
8744
|
+
xChildren(xFirst(root, "sheets") ?? root, "sheet").forEach((node, index3) => {
|
|
8089
8745
|
const state = att(node, "state");
|
|
8090
8746
|
sheets.push({
|
|
8091
|
-
name: att(node, "name") ?? `Sheet${
|
|
8092
|
-
sheetId: numAttr(node, "sheetId") ??
|
|
8747
|
+
name: att(node, "name") ?? `Sheet${index3 + 1}`,
|
|
8748
|
+
sheetId: numAttr(node, "sheetId") ?? index3 + 1,
|
|
8093
8749
|
state: state === "hidden" || state === "veryHidden" ? state : "visible",
|
|
8094
8750
|
relId: relAttr(node, "id") ?? ""
|
|
8095
8751
|
});
|
|
@@ -8439,8 +9095,8 @@ function styleRef(element2) {
|
|
|
8439
9095
|
if (element2.localName === "fontRef") {
|
|
8440
9096
|
if (raw2) ref.fontIndex = raw2;
|
|
8441
9097
|
} else {
|
|
8442
|
-
const
|
|
8443
|
-
if (Number.isFinite(
|
|
9098
|
+
const index3 = Number.parseInt(raw2 ?? "", 10);
|
|
9099
|
+
if (Number.isFinite(index3)) ref.index = index3;
|
|
8444
9100
|
}
|
|
8445
9101
|
const color = parseDrawingColorIn(element2);
|
|
8446
9102
|
if (color) ref.color = color;
|
|
@@ -8819,11 +9475,11 @@ function groupTransform(group, parent) {
|
|
|
8819
9475
|
scaleY: parent.scaleY * local.scaleY
|
|
8820
9476
|
};
|
|
8821
9477
|
}
|
|
8822
|
-
function parseShape(sp,
|
|
9478
|
+
function parseShape(sp, index3, group, issues) {
|
|
8823
9479
|
const spPr = first(sp, "spPr", NS.dsp);
|
|
8824
9480
|
const transform6 = parseTransform(first(spPr, "xfrm", NS.a));
|
|
8825
9481
|
if (!transform6) return void 0;
|
|
8826
|
-
const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${
|
|
9482
|
+
const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${index3}`;
|
|
8827
9483
|
const { geometry, adjustments, paths, issue } = parseDrawingGeometry(spPr);
|
|
8828
9484
|
if (issue) issues.push({ code: issue, message: `Shape ${modelId}: ${issue}.` });
|
|
8829
9485
|
const frame = applyGroup(transform6.frame, group);
|
|
@@ -9041,8 +9697,8 @@ function drawingFillXml(fill) {
|
|
|
9041
9697
|
const stops = children(list, "gs", NS.a).filter(
|
|
9042
9698
|
(node) => parseDrawingColorIn(node) && Number.isFinite(Number.parseInt(node.getAttribute("pos") ?? "", 10))
|
|
9043
9699
|
);
|
|
9044
|
-
fill.stops.forEach((stop,
|
|
9045
|
-
const node = stops[
|
|
9700
|
+
fill.stops.forEach((stop, index3) => {
|
|
9701
|
+
const node = stops[index3] ?? doc.createElementNS(NS.a, "a:gs");
|
|
9046
9702
|
if (!node.parentNode) list.appendChild(node);
|
|
9047
9703
|
node.setAttribute("pos", String(Math.round(stop.position * 1e3)));
|
|
9048
9704
|
for (const old of elements(node))
|
|
@@ -9551,45 +10207,6 @@ function readDataValidations(node) {
|
|
|
9551
10207
|
return out;
|
|
9552
10208
|
}
|
|
9553
10209
|
|
|
9554
|
-
// xlsx/write/xml-out.ts
|
|
9555
|
-
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
9556
|
-
var CONTROL = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
9557
|
-
var NEEDS_ESCAPE = new RegExp(`[${CONTROL}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
9558
|
-
var ESCAPABLE = new RegExp(`[${CONTROL}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
9559
|
-
function encodeEscapes(text) {
|
|
9560
|
-
if (!NEEDS_ESCAPE.test(text)) return text;
|
|
9561
|
-
return text.replace(
|
|
9562
|
-
ESCAPABLE,
|
|
9563
|
-
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
9564
|
-
);
|
|
9565
|
-
}
|
|
9566
|
-
var INVALID_XML = new RegExp(`[${CONTROL}]`, "g");
|
|
9567
|
-
var escapeText2 = (text) => text.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
9568
|
-
var escapeAttr3 = (text) => text.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
9569
|
-
function attrs(values2) {
|
|
9570
|
-
let out = "";
|
|
9571
|
-
for (const [name, value2] of Object.entries(values2)) {
|
|
9572
|
-
if (value2 === void 0) continue;
|
|
9573
|
-
const text = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num(value2) : value2;
|
|
9574
|
-
out += ` ${name}="${escapeAttr3(text)}"`;
|
|
9575
|
-
}
|
|
9576
|
-
return out;
|
|
9577
|
-
}
|
|
9578
|
-
var el = (name, values2 = {}, content2 = "") => content2 ? `<${name}${attrs(values2)}>${content2}</${name}>` : `<${name}${attrs(values2)}/>`;
|
|
9579
|
-
var num = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
9580
|
-
function tElement(text, name = "t") {
|
|
9581
|
-
const encoded = escapeText2(encodeEscapes(text));
|
|
9582
|
-
const preserve = /^\s|\s$|\n|\t/.test(text) ? ' xml:space="preserve"' : "";
|
|
9583
|
-
return `<${name}${preserve}>${encoded}</${name}>`;
|
|
9584
|
-
}
|
|
9585
|
-
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
9586
|
-
function inlineFragment(xml) {
|
|
9587
|
-
const end = xml.indexOf(">");
|
|
9588
|
-
if (end < 0) return xml;
|
|
9589
|
-
const head = xml.slice(0, end);
|
|
9590
|
-
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
9591
|
-
}
|
|
9592
|
-
|
|
9593
10210
|
// xlsx/conditional-extensions.ts
|
|
9594
10211
|
var XM = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
9595
10212
|
var URI = "{78C0D931-6437-407d-A8EE-F0AAD7539E65}";
|
|
@@ -9599,8 +10216,8 @@ function writeSettings(node, rule) {
|
|
|
9599
10216
|
if (rule.minLength !== void 0) bar.setAttribute("minLength", String(rule.minLength));
|
|
9600
10217
|
if (rule.maxLength !== void 0) bar.setAttribute("maxLength", String(rule.maxLength));
|
|
9601
10218
|
const thresholds = children(bar, "cfvo", NS.x14);
|
|
9602
|
-
for (const [
|
|
9603
|
-
const target = thresholds[
|
|
10219
|
+
for (const [index3, threshold] of [rule.min, rule.max].entries()) {
|
|
10220
|
+
const target = thresholds[index3];
|
|
9604
10221
|
if (!target) continue;
|
|
9605
10222
|
const oldType = target.getAttribute("type");
|
|
9606
10223
|
if (oldType === "autoMin" && threshold.type === "min" || oldType === "autoMax" && threshold.type === "max")
|
|
@@ -9864,7 +10481,7 @@ function chartCacheValues(cache2) {
|
|
|
9864
10481
|
out[point.index ?? out.length] = numeric2 && text.trim() !== "" && Number.isFinite(Number(text)) ? Number(text) : text;
|
|
9865
10482
|
}
|
|
9866
10483
|
const size = Math.max(cache2.pointCount ?? 0, out.length);
|
|
9867
|
-
for (let
|
|
10484
|
+
for (let index3 = 0; index3 < size; index3++) if (out[index3] === void 0) out[index3] = "";
|
|
9868
10485
|
return out;
|
|
9869
10486
|
}
|
|
9870
10487
|
var chartSourceValues = (source2) => chartCacheValues(source2?.cache ?? source2?.levels?.[0]);
|
|
@@ -9999,8 +10616,8 @@ function parseCache(node) {
|
|
|
9999
10616
|
type: node.localName === "numCache" || node.localName === "numLit" ? "number" : "string",
|
|
10000
10617
|
points: children(node, "pt", NS.c).map((pt) => {
|
|
10001
10618
|
const point = { value: cChild(pt, "v")?.textContent ?? "" };
|
|
10002
|
-
const
|
|
10003
|
-
if (Number.isInteger(
|
|
10619
|
+
const index3 = Number(attribute(pt, "idx") ?? Number.NaN);
|
|
10620
|
+
if (Number.isInteger(index3) && index3 >= 0) point.index = index3;
|
|
10004
10621
|
const formatCode2 = attribute(pt, "formatCode");
|
|
10005
10622
|
if (formatCode2 !== void 0) point.formatCode = formatCode2;
|
|
10006
10623
|
return point;
|
|
@@ -10226,11 +10843,11 @@ var POINT = /* @__PURE__ */ new Set([
|
|
|
10226
10843
|
]);
|
|
10227
10844
|
function parseDataPoint(context, element2) {
|
|
10228
10845
|
reportUnmodelled(context, element2, POINT);
|
|
10229
|
-
const
|
|
10846
|
+
const index3 = cNumber(context, element2, "idx");
|
|
10230
10847
|
return assignDefined(
|
|
10231
10848
|
{},
|
|
10232
10849
|
{
|
|
10233
|
-
index:
|
|
10850
|
+
index: index3 !== void 0 && Number.isInteger(index3) && index3 >= 0 ? index3 : void 0,
|
|
10234
10851
|
invertIfNegative: cBool(context, element2, "invertIfNegative"),
|
|
10235
10852
|
bubble3D: cBool(context, element2, "bubble3D"),
|
|
10236
10853
|
explosion: cNumber(context, element2, "explosion"),
|
|
@@ -10767,8 +11384,8 @@ var SCHEME_INDEX = {
|
|
|
10767
11384
|
function legacyColor(color) {
|
|
10768
11385
|
if (color?.kind === "srgb") return color.value ? { rgb: color.value.toUpperCase() } : void 0;
|
|
10769
11386
|
if (color?.kind === "scheme") {
|
|
10770
|
-
const
|
|
10771
|
-
return
|
|
11387
|
+
const index3 = SCHEME_INDEX[color.value];
|
|
11388
|
+
return index3 === void 0 ? void 0 : { theme: index3 };
|
|
10772
11389
|
}
|
|
10773
11390
|
return void 0;
|
|
10774
11391
|
}
|
|
@@ -11619,14 +12236,14 @@ var PersonRegistry = class {
|
|
|
11619
12236
|
return `${XML_HEADER}<personList xmlns="${NS.tc}" xmlns:x="${NS.x}">${people}</personList>`;
|
|
11620
12237
|
}
|
|
11621
12238
|
};
|
|
11622
|
-
function vmlShape(comment,
|
|
12239
|
+
function vmlShape(comment, index3, id) {
|
|
11623
12240
|
const { row: row2, col } = comment.address;
|
|
11624
12241
|
const anchor = `${col + 1}, 15, ${Math.max(0, row2 - 1)}, 10, ${col + 3}, 15, ${row2 + 3}, 4`;
|
|
11625
|
-
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:${
|
|
12242
|
+
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>`;
|
|
11626
12243
|
}
|
|
11627
12244
|
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>';
|
|
11628
12245
|
function vmlXml(comments, layout3) {
|
|
11629
|
-
const shapes = comments.map((comment,
|
|
12246
|
+
const shapes = comments.map((comment, index3) => vmlShape(comment, index3, layout3.ids[index3] ?? 0)).join("");
|
|
11630
12247
|
const data = layout3.blocks.join(",");
|
|
11631
12248
|
const base = layout3.base;
|
|
11632
12249
|
if (base && /<\/xml>\s*$/.test(base)) {
|
|
@@ -11657,8 +12274,8 @@ function commentParts(comments, sheetNumber, persons, sheetName, layout3) {
|
|
|
11657
12274
|
const id = guidFrom(`${sheetName}!${ref}:${comment.text}`);
|
|
11658
12275
|
const personId = persons.id(comment.author);
|
|
11659
12276
|
threaded += `<threadedComment ref="${ref}" personId="${personId}" id="${id}"><text>${escapeText2(comment.text)}</text></threadedComment>`;
|
|
11660
|
-
comment.replies.forEach((reply,
|
|
11661
|
-
const replyId = guidFrom(`${id}:reply:${
|
|
12277
|
+
comment.replies.forEach((reply, index3) => {
|
|
12278
|
+
const replyId = guidFrom(`${id}:reply:${index3}:${reply.text}`);
|
|
11662
12279
|
const dT = reply.date ? ` dT="${escapeAttr3(reply.date)}"` : "";
|
|
11663
12280
|
threaded += `<threadedComment ref="${ref}"${dT} personId="${persons.id(reply.author)}" id="${replyId}" parentId="${id}"><text>${escapeText2(reply.text)}</text></threadedComment>`;
|
|
11664
12281
|
});
|
|
@@ -11675,7 +12292,7 @@ Reply:
|
|
|
11675
12292
|
sorted2,
|
|
11676
12293
|
layout3 ?? {
|
|
11677
12294
|
blocks: [sheetNumber],
|
|
11678
|
-
ids: sorted2.map((_,
|
|
12295
|
+
ids: sorted2.map((_, index3) => 1024 * sheetNumber + index3 + 1)
|
|
11679
12296
|
}
|
|
11680
12297
|
);
|
|
11681
12298
|
const parts = { comments: commentsXml, vml };
|
|
@@ -12378,11 +12995,11 @@ var GRAY_VARIATIONS = [
|
|
|
12378
12995
|
{ tint: 8e4 }
|
|
12379
12996
|
];
|
|
12380
12997
|
var ACCENTS = ["accent1", "accent2", "accent3", "accent4", "accent5", "accent6"];
|
|
12381
|
-
function colorful(id,
|
|
12382
|
-
return { id, group: "colorful", index:
|
|
12998
|
+
function colorful(id, index3, base) {
|
|
12999
|
+
return { id, group: "colorful", index: index3, meth: "cycle", base, variations: COLORFUL_VARIATIONS };
|
|
12383
13000
|
}
|
|
12384
|
-
function mono(id,
|
|
12385
|
-
return { id, group: "monochromatic", index:
|
|
13001
|
+
function mono(id, index3, accent, meth) {
|
|
13002
|
+
return { id, group: "monochromatic", index: index3, meth, base: [accent], variations: [] };
|
|
12386
13003
|
}
|
|
12387
13004
|
var CHART_COLOR_PALETTES = [
|
|
12388
13005
|
colorful(10, 1, ACCENTS),
|
|
@@ -12426,9 +13043,9 @@ function chartPaletteSeriesColorChoice(palette, i2, n) {
|
|
|
12426
13043
|
const round2 = Math.floor(i2 / palette.base.length);
|
|
12427
13044
|
transform6 = (palette.variations.length ? palette.variations[round2 % palette.variations.length] : {}) ?? {};
|
|
12428
13045
|
} else {
|
|
12429
|
-
const
|
|
13046
|
+
const index3 = palette.meth === "withinLinearReversed" ? n - 1 - i2 : i2;
|
|
12430
13047
|
base = palette.base[0];
|
|
12431
|
-
transform6 = withinLinearTransform(
|
|
13048
|
+
transform6 = withinLinearTransform(index3, n);
|
|
12432
13049
|
}
|
|
12433
13050
|
if (!base) throw new RangeError("A chart palette must have a base color");
|
|
12434
13051
|
return {
|
|
@@ -12609,18 +13226,18 @@ var PackageWriter = class {
|
|
|
12609
13226
|
var rank = (name) => name === "_rels/.rels" ? 0 : name.startsWith("docProps/") ? 1 : name === "xl/workbook.xml" ? 2 : 3;
|
|
12610
13227
|
|
|
12611
13228
|
// xlsx/write/chart-colors.ts
|
|
12612
|
-
function chartSeriesFill(chart, series,
|
|
13229
|
+
function chartSeriesFill(chart, series, index3) {
|
|
12613
13230
|
const imported = series.fill && drawingFillXml(series.fill);
|
|
12614
13231
|
if (imported) return imported;
|
|
12615
|
-
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series,
|
|
13232
|
+
return `<a:solidFill>${drawingColorXml(chartSeriesColor(chart, series, index3))}</a:solidFill>`;
|
|
12616
13233
|
}
|
|
12617
|
-
function chartSeriesDrawingFill(chart, series,
|
|
13234
|
+
function chartSeriesDrawingFill(chart, series, index3) {
|
|
12618
13235
|
if (series.fill && drawingFillXml(series.fill)) return series.fill;
|
|
12619
|
-
return { kind: "solid", color: chartSeriesColor(chart, series,
|
|
13236
|
+
return { kind: "solid", color: chartSeriesColor(chart, series, index3) };
|
|
12620
13237
|
}
|
|
12621
|
-
function chartSeriesColor(chart, series,
|
|
13238
|
+
function chartSeriesColor(chart, series, index3) {
|
|
12622
13239
|
const palette = findChartColorPalette(chart.colorPalette ?? 10);
|
|
12623
|
-
return series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(palette ?? findChartColorPalette(10),
|
|
13240
|
+
return series.drawingColor ?? chartDrawingColor(series.color) ?? chartPaletteSeriesColorChoice(palette ?? findChartColorPalette(10), index3, chart.series.length);
|
|
12624
13241
|
}
|
|
12625
13242
|
function recolorMarker(marker3, previous, next) {
|
|
12626
13243
|
for (const paint of [marker3, first(marker3, "ln", NS.a)]) {
|
|
@@ -12638,10 +13255,10 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
12638
13255
|
const palette = findChartColorPalette(model.colorPalette ?? 10);
|
|
12639
13256
|
const lineLike = ["line", "scatter", "radar"].includes(model.chartType);
|
|
12640
13257
|
const markerOnly = model.chartType === "scatter" && first(plot2, "scatterStyle", NS.c)?.getAttribute("val") === "marker";
|
|
12641
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
12642
|
-
const series = model.series[
|
|
13258
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
13259
|
+
const series = model.series[index3];
|
|
12643
13260
|
if (!series) return;
|
|
12644
|
-
const old = before.series[
|
|
13261
|
+
const old = before.series[index3];
|
|
12645
13262
|
if (old?.effectsXml !== series.effectsXml) {
|
|
12646
13263
|
let shape2 = first(ser, "spPr", NS.c);
|
|
12647
13264
|
if (!shape2 && series.effectsXml) {
|
|
@@ -12687,12 +13304,12 @@ function patchChartColors(doc, chartNode, model, before) {
|
|
|
12687
13304
|
paint = doc.createElementNS(NS.a, "a:ln");
|
|
12688
13305
|
spPr.appendChild(paint);
|
|
12689
13306
|
}
|
|
12690
|
-
setDrawingFillXml(paint, chartSeriesFill(model, series,
|
|
13307
|
+
setDrawingFillXml(paint, chartSeriesFill(model, series, index3));
|
|
12691
13308
|
}
|
|
12692
13309
|
if (previousPalette && palette && before.colorPalette !== model.colorPalette) {
|
|
12693
13310
|
const marker3 = first(first(ser, "marker", NS.c), "spPr", NS.c);
|
|
12694
|
-
const previous = chartPaletteSeriesColorChoice(previousPalette,
|
|
12695
|
-
const next = chartPaletteSeriesColorChoice(palette,
|
|
13311
|
+
const previous = chartPaletteSeriesColorChoice(previousPalette, index3, model.series.length);
|
|
13312
|
+
const next = chartPaletteSeriesColorChoice(palette, index3, model.series.length);
|
|
12696
13313
|
recolorMarker(marker3, previous, next);
|
|
12697
13314
|
for (const point of children(ser, "dPt", NS.c))
|
|
12698
13315
|
recolorMarker(first(first(point, "marker", NS.c), "spPr", NS.c), previous, next);
|
|
@@ -12787,7 +13404,7 @@ var FIRST_AXIS = 500000001;
|
|
|
12787
13404
|
var SECOND_AXIS = 500000002;
|
|
12788
13405
|
function source(kind, formula, values2) {
|
|
12789
13406
|
const points = values2.flatMap(
|
|
12790
|
-
(value2,
|
|
13407
|
+
(value2, index3) => value2 === null || value2 === "" ? [] : [{ index: index3, value: String(value2) }]
|
|
12791
13408
|
);
|
|
12792
13409
|
return {
|
|
12793
13410
|
kind: formula ? kind === "str" ? "strRef" : "numRef" : kind === "str" ? "strLit" : "numLit",
|
|
@@ -12820,9 +13437,9 @@ function dataPoints(series) {
|
|
|
12820
13437
|
return /^\d+$/.test(key) && paint ? [{ index: Number(key), spPr: { fill: paint } }] : [];
|
|
12821
13438
|
});
|
|
12822
13439
|
}
|
|
12823
|
-
function seriesModel(chart, series,
|
|
13440
|
+
function seriesModel(chart, series, index3) {
|
|
12824
13441
|
const type = chart.chartType;
|
|
12825
|
-
const out = { index:
|
|
13442
|
+
const out = { index: index3, order: index3, dataPoints: dataPoints(series) };
|
|
12826
13443
|
if (series.nameRef)
|
|
12827
13444
|
out.tx = {
|
|
12828
13445
|
reference: source("str", series.nameRef, series.name === void 0 ? [] : [series.name])
|
|
@@ -12831,7 +13448,7 @@ function seriesModel(chart, series, index2) {
|
|
|
12831
13448
|
const lineLike = type === "line" || type === "scatter" || type === "radar";
|
|
12832
13449
|
const effectsXml = effects(series);
|
|
12833
13450
|
if (type !== "pie" && type !== "doughnut" || series.fill || series.color || series.drawingColor || effectsXml) {
|
|
12834
|
-
const fill = chartSeriesDrawingFill(chart, series,
|
|
13451
|
+
const fill = chartSeriesDrawingFill(chart, series, index3);
|
|
12835
13452
|
const shape2 = lineLike ? { line: { widthEmu: 28575, cap: "rnd", fill } } : { fill };
|
|
12836
13453
|
if (effectsXml) shape2.effectsXml = effectsXml;
|
|
12837
13454
|
out.spPr = shape2;
|
|
@@ -12955,7 +13572,7 @@ function style(chart) {
|
|
|
12955
13572
|
return id > 100 ? { c14Style: id, style: id - 100 } : { style: id };
|
|
12956
13573
|
}
|
|
12957
13574
|
function chartSpaceFromObject(chart) {
|
|
12958
|
-
const series = chart.series.map((entry3,
|
|
13575
|
+
const series = chart.series.map((entry3, index3) => seriesModel(chart, entry3, index3));
|
|
12959
13576
|
const [group, chartAxes] = plot(chart, series);
|
|
12960
13577
|
const space = {
|
|
12961
13578
|
roundedCorners: false,
|
|
@@ -12996,8 +13613,8 @@ function patchChartReferences(xml, chart) {
|
|
|
12996
13613
|
changed = true;
|
|
12997
13614
|
}
|
|
12998
13615
|
};
|
|
12999
|
-
children(plot2, "ser", NS.c).forEach((ser,
|
|
13000
|
-
const model = chart.series[
|
|
13616
|
+
children(plot2, "ser", NS.c).forEach((ser, index3) => {
|
|
13617
|
+
const model = chart.series[index3];
|
|
13001
13618
|
if (!model) return;
|
|
13002
13619
|
setRef(first(ser, "tx", NS.c), model.nameRef);
|
|
13003
13620
|
setRef(first(ser, "cat", NS.c) ?? first(ser, "xVal", NS.c), model.categoriesRef);
|
|
@@ -13365,10 +13982,10 @@ var MONTHS2 = [
|
|
|
13365
13982
|
function monthFromName2(name) {
|
|
13366
13983
|
const lower2 = name.toLowerCase();
|
|
13367
13984
|
if (lower2.length < 3) return void 0;
|
|
13368
|
-
const
|
|
13369
|
-
if (
|
|
13370
|
-
const full = new Date(Date.UTC(2e3,
|
|
13371
|
-
return lower2.length === 3 || full.startsWith(lower2) || lower2 === "sept" ?
|
|
13985
|
+
const index3 = MONTHS2.findIndex((m) => lower2.startsWith(m));
|
|
13986
|
+
if (index3 < 0) return void 0;
|
|
13987
|
+
const full = new Date(Date.UTC(2e3, index3, 1)).toLocaleString("en-US", { month: "long", timeZone: "UTC" }).toLowerCase();
|
|
13988
|
+
return lower2.length === 3 || full.startsWith(lower2) || lower2 === "sept" ? index3 + 1 : void 0;
|
|
13372
13989
|
}
|
|
13373
13990
|
var NUMBER_RE3 = /^(\d+(?:,\d{3,})+|\d*)(\.\d*)?(?:e([+-]?\d+))?$/i;
|
|
13374
13991
|
var TIME_RE2 = /^(\d{1,4})(?::(\d+))?(?::(\d+(?:\.\d*)?))?(?:\s+(am|pm|a|p))?$/i;
|
|
@@ -14136,11 +14753,11 @@ function sort(args, ctx) {
|
|
|
14136
14753
|
if (byCol) m = transpose(m);
|
|
14137
14754
|
const indexes2 = args.length > 1 && args[1] !== null ? ctx.toMatrix(args[1] ?? null).flat().map((v) => Math.trunc(num2(v))) : [1];
|
|
14138
14755
|
const orders = args.length > 2 && args[2] !== null ? ctx.toMatrix(args[2] ?? null).flat().map((v) => num2(v)) : [1];
|
|
14139
|
-
const keys = indexes2.map((
|
|
14140
|
-
if (
|
|
14756
|
+
const keys = indexes2.map((index3, k) => {
|
|
14757
|
+
if (index3 < 1 || index3 > m.cols) fail(ERR.VALUE);
|
|
14141
14758
|
const order = orders[Math.min(k, orders.length - 1)] ?? 1;
|
|
14142
14759
|
if (order !== 1 && order !== -1) fail(ERR.VALUE);
|
|
14143
|
-
return { values: m.data.map((row2) => row2[
|
|
14760
|
+
return { values: m.data.map((row2) => row2[index3 - 1] ?? null), descending: order === -1 };
|
|
14144
14761
|
});
|
|
14145
14762
|
const sorted2 = new Matrix(sortRows(m.data, keys));
|
|
14146
14763
|
return byCol ? transpose(sorted2) : sorted2;
|
|
@@ -14268,14 +14885,14 @@ var ARRAY_FUNCTIONS = [
|
|
|
14268
14885
|
const cols = optInt(ctx, args, 1, 1);
|
|
14269
14886
|
const min = args.length > 2 && args[2] !== null ? num2(ctx.toScalar(args[2] ?? null)) : 0;
|
|
14270
14887
|
const max = args.length > 3 && args[3] !== null ? num2(ctx.toScalar(args[3] ?? null)) : 1;
|
|
14271
|
-
const
|
|
14888
|
+
const integer2 = args.length > 4 && args[4] !== null && toBool(ctx.toScalar(args[4] ?? null));
|
|
14272
14889
|
if (rows < 1 || cols < 1) return ERR.CALC;
|
|
14273
14890
|
if (min > max) fail(ERR.VALUE);
|
|
14274
14891
|
const random = () => ctx.frame.host.random();
|
|
14275
14892
|
return Matrix.build(
|
|
14276
14893
|
rows,
|
|
14277
14894
|
cols,
|
|
14278
|
-
() =>
|
|
14895
|
+
() => integer2 ? Math.ceil(min) + Math.floor(random() * (Math.floor(max) - Math.ceil(min) + 1)) : min + random() * (max - min)
|
|
14279
14896
|
);
|
|
14280
14897
|
},
|
|
14281
14898
|
["any"],
|
|
@@ -14330,8 +14947,8 @@ function modes(values2) {
|
|
|
14330
14947
|
function kth(values2, k, largest) {
|
|
14331
14948
|
const n = values2.length;
|
|
14332
14949
|
if (n === 0 || !(k >= 1) || k > n) fail(ERR.NUM);
|
|
14333
|
-
const
|
|
14334
|
-
return sorted(values2)[
|
|
14950
|
+
const index3 = Math.floor(largest ? n + 1 - k : k) - 1;
|
|
14951
|
+
return sorted(values2)[index3];
|
|
14335
14952
|
}
|
|
14336
14953
|
function extreme(values2, max) {
|
|
14337
14954
|
if (values2.length === 0) return 0;
|
|
@@ -14471,13 +15088,13 @@ function fieldIndex(table2, field) {
|
|
|
14471
15088
|
const value2 = scalar(field);
|
|
14472
15089
|
if (isError(value2)) fail(value2);
|
|
14473
15090
|
if (typeof value2 === "number") {
|
|
14474
|
-
const
|
|
14475
|
-
if (
|
|
14476
|
-
return
|
|
15091
|
+
const index4 = Math.trunc(value2) - 1;
|
|
15092
|
+
if (index4 < 0 || index4 >= table2.headers.length) fail(ERR.VALUE);
|
|
15093
|
+
return index4;
|
|
14477
15094
|
}
|
|
14478
|
-
const
|
|
14479
|
-
if (
|
|
14480
|
-
return
|
|
15095
|
+
const index3 = table2.headers.indexOf(label2(value2).toLowerCase());
|
|
15096
|
+
if (index3 < 0) fail(ERR.VALUE);
|
|
15097
|
+
return index3;
|
|
14481
15098
|
}
|
|
14482
15099
|
function recordFilter(table2, criteria) {
|
|
14483
15100
|
const [head, ...rows] = criteria;
|
|
@@ -15763,8 +16380,8 @@ function cumulative(args, principal) {
|
|
|
15763
16380
|
|
|
15764
16381
|
// xlsx/formula/functions/bonds.ts
|
|
15765
16382
|
var C9 = "Financial";
|
|
15766
|
-
var basisOf = (args,
|
|
15767
|
-
const basis = args.length >
|
|
16383
|
+
var basisOf = (args, index3) => {
|
|
16384
|
+
const basis = args.length > index3 && args[index3] !== null ? int3(args[index3]) : 0;
|
|
15768
16385
|
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
15769
16386
|
return basis;
|
|
15770
16387
|
};
|
|
@@ -15946,9 +16563,9 @@ var AMORLINC = {
|
|
|
15946
16563
|
}
|
|
15947
16564
|
const fraction = purchase === firstPeriod ? 1 : basis === 1 ? (firstPeriod - purchase) / (isLeapYear(serialToYmd(purchase, ctx.date1904).year) ? 366 : 365) : yearFrac(purchase, firstPeriod, basis, ctx);
|
|
15948
16565
|
const first2 = Math.min(cost - salvage, annual * fraction);
|
|
15949
|
-
const
|
|
15950
|
-
if (
|
|
15951
|
-
return Math.max(0, Math.min(annual, cost - salvage - first2 - (
|
|
16566
|
+
const index3 = Math.trunc(period);
|
|
16567
|
+
if (index3 === 0) return first2;
|
|
16568
|
+
return Math.max(0, Math.min(annual, cost - salvage - first2 - (index3 - 1) * annual));
|
|
15952
16569
|
}
|
|
15953
16570
|
),
|
|
15954
16571
|
missingRequiredError: "#N/A"
|
|
@@ -16175,8 +16792,8 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
16175
16792
|
|
|
16176
16793
|
// xlsx/formula/functions/securities.ts
|
|
16177
16794
|
var C11 = "Financial";
|
|
16178
|
-
var basisOf2 = (args,
|
|
16179
|
-
const basis = args.length >
|
|
16795
|
+
var basisOf2 = (args, index3) => {
|
|
16796
|
+
const basis = args.length > index3 && args[index3] !== null ? int3(args[index3]) : 0;
|
|
16180
16797
|
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
16181
16798
|
return basis;
|
|
16182
16799
|
};
|
|
@@ -16599,8 +17216,8 @@ var INFO_FUNCTIONS = [
|
|
|
16599
17216
|
const v = args[0];
|
|
16600
17217
|
if (v === void 0) return ctx.sheet + 1;
|
|
16601
17218
|
if (v instanceof RefValue) return (v.areas[0]?.sheet ?? ctx.sheet) + 1;
|
|
16602
|
-
const
|
|
16603
|
-
return
|
|
17219
|
+
const index3 = sheetIndex(ctx.frame.host, str(v));
|
|
17220
|
+
return index3 < 0 ? ERR.NA : index3 + 1;
|
|
16604
17221
|
},
|
|
16605
17222
|
["any"]
|
|
16606
17223
|
),
|
|
@@ -17069,14 +17686,14 @@ function shape(value2) {
|
|
|
17069
17686
|
if (value2 instanceof Matrix) return { rows: value2.rows, cols: value2.cols };
|
|
17070
17687
|
return { rows: 1, cols: 1 };
|
|
17071
17688
|
}
|
|
17072
|
-
function line(ctx, value2, axis,
|
|
17689
|
+
function line(ctx, value2, axis, index3) {
|
|
17073
17690
|
if (value2 instanceof RefValue) {
|
|
17074
17691
|
const area = value2.areas[0];
|
|
17075
17692
|
if (!area || value2.areas.length !== 1) fail(ERR.VALUE);
|
|
17076
17693
|
const { start, end } = area.range;
|
|
17077
17694
|
const bounds = ctx.frame.host.bounds(area.sheet);
|
|
17078
17695
|
if (axis === "col") {
|
|
17079
|
-
const col = start.col +
|
|
17696
|
+
const col = start.col + index3;
|
|
17080
17697
|
const length2 = Math.max(0, Math.min(end.row, bounds.rows - 1) - start.row + 1);
|
|
17081
17698
|
return {
|
|
17082
17699
|
length: length2,
|
|
@@ -17084,7 +17701,7 @@ function line(ctx, value2, axis, index2) {
|
|
|
17084
17701
|
get: (i2) => ctx.readCell(area.sheet, start.row + i2, col)
|
|
17085
17702
|
};
|
|
17086
17703
|
}
|
|
17087
|
-
const row2 = start.row +
|
|
17704
|
+
const row2 = start.row + index3;
|
|
17088
17705
|
const length = Math.max(0, Math.min(end.col, bounds.cols - 1) - start.col + 1);
|
|
17089
17706
|
return {
|
|
17090
17707
|
length,
|
|
@@ -17093,8 +17710,8 @@ function line(ctx, value2, axis, index2) {
|
|
|
17093
17710
|
};
|
|
17094
17711
|
}
|
|
17095
17712
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
17096
|
-
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2,
|
|
17097
|
-
return { length: m.cols, get: (i2) => m.get(
|
|
17713
|
+
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2, index3) };
|
|
17714
|
+
return { length: m.cols, get: (i2) => m.get(index3, i2) };
|
|
17098
17715
|
}
|
|
17099
17716
|
function vectorOf(ctx, value2) {
|
|
17100
17717
|
const { rows, cols } = shape(value2);
|
|
@@ -17532,24 +18149,24 @@ function cellOf(value2, row2, col) {
|
|
|
17532
18149
|
if (value2 instanceof Matrix) return value2.get(row2, col);
|
|
17533
18150
|
return value2;
|
|
17534
18151
|
}
|
|
17535
|
-
function sliceOf(value2, axis,
|
|
18152
|
+
function sliceOf(value2, axis, index3) {
|
|
17536
18153
|
const { rows } = shape(value2);
|
|
17537
18154
|
if (value2 instanceof RefValue) {
|
|
17538
18155
|
const area = value2.areas[0];
|
|
17539
18156
|
if (!area) fail(ERR.REF);
|
|
17540
18157
|
const { start, end } = area.range;
|
|
17541
18158
|
const range = axis === "row" ? {
|
|
17542
|
-
start: { row: start.row +
|
|
17543
|
-
end: { row: start.row +
|
|
18159
|
+
start: { row: start.row + index3, col: start.col },
|
|
18160
|
+
end: { row: start.row + index3, col: end.col }
|
|
17544
18161
|
} : {
|
|
17545
|
-
start: { row: start.row, col: start.col +
|
|
17546
|
-
end: { row: end.row, col: start.col +
|
|
18162
|
+
start: { row: start.row, col: start.col + index3 },
|
|
18163
|
+
end: { row: end.row, col: start.col + index3 }
|
|
17547
18164
|
};
|
|
17548
18165
|
return new RefValue([{ sheet: area.sheet, range }]);
|
|
17549
18166
|
}
|
|
17550
18167
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
17551
|
-
if (axis === "row") return new Matrix([m.data[
|
|
17552
|
-
return new Matrix(Array.from({ length: rows }, (_, r) => [m.get(r,
|
|
18168
|
+
if (axis === "row") return new Matrix([m.data[index3] ?? []]);
|
|
18169
|
+
return new Matrix(Array.from({ length: rows }, (_, r) => [m.get(r, index3)]));
|
|
17553
18170
|
}
|
|
17554
18171
|
function lookupValue(args) {
|
|
17555
18172
|
const v = scalar(args[0]);
|
|
@@ -17565,15 +18182,15 @@ function lookupArray(value2) {
|
|
|
17565
18182
|
function vhlookup(args, ctx, vertical) {
|
|
17566
18183
|
const lookup2 = blankAsZero(args);
|
|
17567
18184
|
const table2 = lookupArray(args[1] ?? null);
|
|
17568
|
-
const
|
|
18185
|
+
const index3 = int3(args[2]);
|
|
17569
18186
|
const approximate2 = args.length < 4 ? true : bool(args[3]);
|
|
17570
18187
|
const { rows, cols } = shape(table2);
|
|
17571
|
-
if (
|
|
17572
|
-
if (
|
|
18188
|
+
if (index3 < 1) fail(ERR.VALUE);
|
|
18189
|
+
if (index3 > (vertical ? cols : rows)) fail(ERR.REF);
|
|
17573
18190
|
const keys = line(ctx, table2, vertical ? "col" : "row", 0);
|
|
17574
18191
|
const at = approximate2 ? findAscending(keys, lookup2) : findExact(keys, lookup2, true);
|
|
17575
18192
|
if (at < 0) fail(ERR.NA);
|
|
17576
|
-
return vertical ? cellOf(table2, at,
|
|
18193
|
+
return vertical ? cellOf(table2, at, index3 - 1) : cellOf(table2, index3 - 1, at);
|
|
17577
18194
|
}
|
|
17578
18195
|
function match(args, ctx) {
|
|
17579
18196
|
const lookup2 = blankAsZero(args);
|
|
@@ -17600,13 +18217,13 @@ function lookup(args, ctx) {
|
|
|
17600
18217
|
if (at < 0) fail(ERR.NA);
|
|
17601
18218
|
return vertical ? cellOf(source2, at, cols - 1) : cellOf(source2, rows - 1, at);
|
|
17602
18219
|
}
|
|
17603
|
-
function
|
|
18220
|
+
function index2(args) {
|
|
17604
18221
|
const source2 = args[0] ?? null;
|
|
17605
18222
|
if (source2 instanceof RefValue && source2.areas.length > 1) {
|
|
17606
18223
|
const area = Math.trunc(optNum(args, 3, 1));
|
|
17607
18224
|
const chosen = source2.areas[area - 1];
|
|
17608
18225
|
if (!chosen) fail(ERR.REF);
|
|
17609
|
-
return
|
|
18226
|
+
return index2([new RefValue([chosen]), ...args.slice(1, 3)]);
|
|
17610
18227
|
}
|
|
17611
18228
|
const { rows, cols } = shape(source2);
|
|
17612
18229
|
let r = args.length > 1 && args[1] !== null ? int3(args[1]) : 0;
|
|
@@ -17728,7 +18345,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17728
18345
|
"The value or reference at a position.",
|
|
17729
18346
|
1,
|
|
17730
18347
|
4,
|
|
17731
|
-
(args) =>
|
|
18348
|
+
(args) => index2(args),
|
|
17732
18349
|
["any", "value", "value", "value"]
|
|
17733
18350
|
),
|
|
17734
18351
|
spec(
|
|
@@ -17772,27 +18389,27 @@ function valueKeys(value2, out) {
|
|
|
17772
18389
|
}
|
|
17773
18390
|
}
|
|
17774
18391
|
function positionsOf(block, key) {
|
|
17775
|
-
let
|
|
17776
|
-
if (!
|
|
18392
|
+
let index3 = indexes.get(block);
|
|
18393
|
+
if (!index3) {
|
|
17777
18394
|
const count2 = (uses.get(block) ?? 0) + 1;
|
|
17778
18395
|
uses.set(block, count2);
|
|
17779
18396
|
if (count2 < 2 || block.isPadded) return void 0;
|
|
17780
|
-
|
|
18397
|
+
index3 = /* @__PURE__ */ new Map();
|
|
17781
18398
|
const keys = [];
|
|
17782
18399
|
const cols = block.cols;
|
|
17783
18400
|
for (let r = 0; r < block.rows; r++) {
|
|
17784
18401
|
for (let c2 = 0; c2 < cols; c2++) {
|
|
17785
18402
|
valueKeys(block.get(r, c2), keys);
|
|
17786
18403
|
for (const k of keys) {
|
|
17787
|
-
const list =
|
|
18404
|
+
const list = index3.get(k);
|
|
17788
18405
|
if (list) list.push(r * cols + c2);
|
|
17789
|
-
else
|
|
18406
|
+
else index3.set(k, [r * cols + c2]);
|
|
17790
18407
|
}
|
|
17791
18408
|
}
|
|
17792
18409
|
}
|
|
17793
|
-
indexes.set(block,
|
|
18410
|
+
indexes.set(block, index3);
|
|
17794
18411
|
}
|
|
17795
|
-
return
|
|
18412
|
+
return index3.get(key) ?? [];
|
|
17796
18413
|
}
|
|
17797
18414
|
|
|
17798
18415
|
// xlsx/formula/functions/criteria.ts
|
|
@@ -18952,7 +19569,7 @@ function layout(ctx, args) {
|
|
|
18952
19569
|
}
|
|
18953
19570
|
return { y, x, column };
|
|
18954
19571
|
}
|
|
18955
|
-
var withConst = (args,
|
|
19572
|
+
var withConst = (args, index3) => omitted(args, index3) ? true : bool(args[index3]);
|
|
18956
19573
|
var row = (values2, width) => [
|
|
18957
19574
|
...values2,
|
|
18958
19575
|
...new Array(Math.max(0, width - values2.length)).fill(ERR.NA)
|
|
@@ -21266,7 +21883,7 @@ function compile(pattern, caseMode2, global) {
|
|
|
21266
21883
|
return fail(ERR.VALUE);
|
|
21267
21884
|
}
|
|
21268
21885
|
}
|
|
21269
|
-
var caseMode = (args,
|
|
21886
|
+
var caseMode = (args, index3) => optNum(args, index3, 0);
|
|
21270
21887
|
function encodeUrl(text) {
|
|
21271
21888
|
return encodeURIComponent(text).replace(
|
|
21272
21889
|
/[!'()*]/g,
|
|
@@ -21385,9 +22002,9 @@ function textAround(args, ctx, before) {
|
|
|
21385
22002
|
if (instance > 0) found.push({ at: text.length, length: 0 });
|
|
21386
22003
|
else found.unshift({ at: 0, length: 0 });
|
|
21387
22004
|
}
|
|
21388
|
-
const
|
|
21389
|
-
const hit = found[
|
|
21390
|
-
if (!hit ||
|
|
22005
|
+
const index3 = instance > 0 ? instance - 1 : found.length + instance;
|
|
22006
|
+
const hit = found[index3];
|
|
22007
|
+
if (!hit || index3 < 0) return notFound;
|
|
21391
22008
|
return before ? text.slice(0, hit.at) : text.slice(hit.at + hit.length);
|
|
21392
22009
|
}
|
|
21393
22010
|
function splitText(text, delimiters, insensitive, ignoreEmpty) {
|
|
@@ -21503,10 +22120,10 @@ Object.freeze(
|
|
|
21503
22120
|
);
|
|
21504
22121
|
|
|
21505
22122
|
// xlsx/formula/functions/types.ts
|
|
21506
|
-
var paramKind = (spec2,
|
|
22123
|
+
var paramKind = (spec2, index3) => {
|
|
21507
22124
|
const params = spec2.params;
|
|
21508
22125
|
if (!params || params.length === 0) return "value";
|
|
21509
|
-
return params[Math.min(
|
|
22126
|
+
return params[Math.min(index3, params.length - 1)] ?? "value";
|
|
21510
22127
|
};
|
|
21511
22128
|
|
|
21512
22129
|
// xlsx/formula/spill.ts
|
|
@@ -22086,9 +22703,9 @@ function readSourceStyles(xml) {
|
|
|
22086
22703
|
(node) => inlineFragment(outerXml(node))
|
|
22087
22704
|
);
|
|
22088
22705
|
const dxfKeys = /* @__PURE__ */ new Map();
|
|
22089
|
-
parseStyles(xml, []).dxfs.forEach((dxf,
|
|
22706
|
+
parseStyles(xml, []).dxfs.forEach((dxf, index3) => {
|
|
22090
22707
|
const key = styleKey(dxf);
|
|
22091
|
-
if (!dxfKeys.has(key)) dxfKeys.set(key,
|
|
22708
|
+
if (!dxfKeys.has(key)) dxfKeys.set(key, index3);
|
|
22092
22709
|
});
|
|
22093
22710
|
const result2 = { numFmts, dxfXml, dxfKeys };
|
|
22094
22711
|
const tableStyles = xFirst(root, "tableStyles");
|
|
@@ -22196,7 +22813,7 @@ var StyleWriter = class {
|
|
|
22196
22813
|
});
|
|
22197
22814
|
const seen = /* @__PURE__ */ new Set();
|
|
22198
22815
|
const unique2 = named2.filter((entry3) => !seen.has(entry3.name) && seen.add(entry3.name));
|
|
22199
|
-
const xfIdOf = new Map(unique2.map((entry3,
|
|
22816
|
+
const xfIdOf = new Map(unique2.map((entry3, index3) => [entry3.name, index3]));
|
|
22200
22817
|
const base = this.workbook.styles[0] ?? defaultCellStyle();
|
|
22201
22818
|
this.fonts.id(fontXml(base.font));
|
|
22202
22819
|
this.borders.id(borderXml({}));
|
|
@@ -22205,7 +22822,7 @@ var StyleWriter = class {
|
|
|
22205
22822
|
(style2) => this.xf(style2, xfIdOf.get(style2.cellStyleName ?? "Normal") ?? 0)
|
|
22206
22823
|
);
|
|
22207
22824
|
const cellStyles = unique2.map(
|
|
22208
|
-
(entry3,
|
|
22825
|
+
(entry3, index3) => el("cellStyle", { name: entry3.name, xfId: index3, builtinId: entry3.builtinId })
|
|
22209
22826
|
);
|
|
22210
22827
|
const custom = [...this.numFmts].filter(([code]) => builtinFormatIdOf(code) === void 0).sort((a2, b) => a2[1] - b[1]);
|
|
22211
22828
|
let out = `${XML_HEADER}<styleSheet xmlns="${NS.x}" xmlns:mc="${NS.mc}" mc:Ignorable="x14ac" xmlns:x14ac="${NS.x14ac}">`;
|
|
@@ -22370,13 +22987,13 @@ function definedNamesOf(workbook) {
|
|
|
22370
22987
|
const names = workbook.definedNames.filter(
|
|
22371
22988
|
(name) => name.name && (name.localSheet === void 0 || name.localSheet >= 0 && name.localSheet < workbook.sheets.length)
|
|
22372
22989
|
);
|
|
22373
|
-
workbook.sheets.forEach((sheet,
|
|
22990
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
22374
22991
|
const area = sheet.pageSetup?.printArea;
|
|
22375
|
-
if (!area || names.some((n) => n.name === "_xlnm.Print_Area" && n.localSheet ===
|
|
22992
|
+
if (!area || names.some((n) => n.name === "_xlnm.Print_Area" && n.localSheet === index3)) return;
|
|
22376
22993
|
names.push({
|
|
22377
22994
|
name: "_xlnm.Print_Area",
|
|
22378
22995
|
formula: `${quoteSheetName(sheet.name)}!${absoluteRange(area)}`,
|
|
22379
|
-
localSheet:
|
|
22996
|
+
localSheet: index3
|
|
22380
22997
|
});
|
|
22381
22998
|
});
|
|
22382
22999
|
return names;
|
|
@@ -22995,9 +23612,9 @@ function sourceColumnsForPatch(root, table2, names) {
|
|
|
22995
23612
|
const byName = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
22996
23613
|
const tracked = table2.partName !== void 0 || table2.columns.some((c2) => c2.sourceId !== void 0);
|
|
22997
23614
|
const used = /* @__PURE__ */ new Set();
|
|
22998
|
-
return names.map((name,
|
|
22999
|
-
const id = table2.columns[
|
|
23000
|
-
const match2 = id !== void 0 ? byId.get(id) : tracked ? void 0 : source2.length === names.length ? source2[
|
|
23615
|
+
return names.map((name, index3) => {
|
|
23616
|
+
const id = table2.columns[index3]?.sourceId;
|
|
23617
|
+
const match2 = id !== void 0 ? byId.get(id) : tracked ? void 0 : source2.length === names.length ? source2[index3] : byName.get(name.toLowerCase());
|
|
23001
23618
|
if (!match2 || used.has(match2)) return void 0;
|
|
23002
23619
|
used.add(match2);
|
|
23003
23620
|
return match2;
|
|
@@ -23014,12 +23631,12 @@ function patchAutoFilter(doc, root, table2, before, names) {
|
|
|
23014
23631
|
filter2.setAttribute("ref", formatRange(range));
|
|
23015
23632
|
const list = xKid(root, "tableColumns");
|
|
23016
23633
|
const original = list ? xKids(list, "tableColumn") : [];
|
|
23017
|
-
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2,
|
|
23634
|
+
const current = new Map(sourceColumnsForPatch(root, table2, names).map((c2, index3) => [c2, index3]));
|
|
23018
23635
|
for (const column of xKids(filter2, "filterColumn")) {
|
|
23019
23636
|
const old = original[Number(column.getAttribute("colId") ?? "0")];
|
|
23020
|
-
const
|
|
23021
|
-
if (
|
|
23022
|
-
else column.setAttribute("colId", num(
|
|
23637
|
+
const index3 = old ? current.get(old) : void 0;
|
|
23638
|
+
if (index3 === void 0) filter2.removeChild(column);
|
|
23639
|
+
else column.setAttribute("colId", num(index3));
|
|
23023
23640
|
}
|
|
23024
23641
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
23025
23642
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
@@ -23064,11 +23681,11 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
23064
23681
|
for (const column of sourceColumns) list.removeChild(column);
|
|
23065
23682
|
let nextId = Math.max(0, ...ids) + 1;
|
|
23066
23683
|
const totalsRow = table2.range.end.row;
|
|
23067
|
-
names.forEach((name,
|
|
23068
|
-
const column = picked[
|
|
23684
|
+
names.forEach((name, index3) => {
|
|
23685
|
+
const column = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
23069
23686
|
if (!column.getAttribute("id")) column.setAttribute("id", num(nextId++));
|
|
23070
23687
|
column.setAttribute("name", name);
|
|
23071
|
-
const model = table2.columns[
|
|
23688
|
+
const model = table2.columns[index3];
|
|
23072
23689
|
const fn = table2.totalsRow ? model?.totalsRowFunction : void 0;
|
|
23073
23690
|
setOrRemove(column, "totalsRowFunction", fn);
|
|
23074
23691
|
setOrRemove(column, "totalsRowLabel", table2.totalsRow ? model?.totalsRowLabel : void 0);
|
|
@@ -23082,7 +23699,7 @@ function patchColumns(doc, root, sheet, table2, names) {
|
|
|
23082
23699
|
);
|
|
23083
23700
|
if (fn !== "custom") setChildText(doc, column, "totalsRowFormula", void 0, []);
|
|
23084
23701
|
else {
|
|
23085
|
-
const cellFormula = sheet.rows.get(totalsRow)?.get(table2.range.start.col +
|
|
23702
|
+
const cellFormula = sheet.rows.get(totalsRow)?.get(table2.range.start.col + index3)?.formula;
|
|
23086
23703
|
if (cellFormula)
|
|
23087
23704
|
setChildText(
|
|
23088
23705
|
doc,
|
|
@@ -23163,11 +23780,11 @@ function tableXml(table2, id, names) {
|
|
|
23163
23780
|
const range = formatRange(table2.range);
|
|
23164
23781
|
const filterEnd = { ...table2.range.end, row: table2.range.end.row - (table2.totalsRow ? 1 : 0) };
|
|
23165
23782
|
const filter2 = table2.headerRow && !table2.totalsRow ? `<autoFilter ref="${range}"/>` : table2.headerRow ? `<autoFilter ref="${formatRange({ start: table2.range.start, end: filterEnd })}"/>` : "";
|
|
23166
|
-
const columns = names.map((name,
|
|
23167
|
-
const column = table2.columns[
|
|
23783
|
+
const columns = names.map((name, index3) => {
|
|
23784
|
+
const column = table2.columns[index3];
|
|
23168
23785
|
const calculated = column?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText2(addFuturePrefixes(column.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
23169
23786
|
const values2 = attrs({
|
|
23170
|
-
id:
|
|
23787
|
+
id: index3 + 1,
|
|
23171
23788
|
name,
|
|
23172
23789
|
totalsRowFunction: table2.totalsRow ? column?.totalsRowFunction : void 0,
|
|
23173
23790
|
totalsRowLabel: table2.totalsRow ? column?.totalsRowLabel : void 0
|
|
@@ -23206,27 +23823,27 @@ function totalsRowFormulas(sheet, table2, names) {
|
|
|
23206
23823
|
const out = /* @__PURE__ */ new Map();
|
|
23207
23824
|
if (!table2.totalsRow) return out;
|
|
23208
23825
|
const row2 = table2.range.end.row;
|
|
23209
|
-
names.forEach((name,
|
|
23210
|
-
const code = SUBTOTAL_CODES[table2.columns[
|
|
23826
|
+
names.forEach((name, index3) => {
|
|
23827
|
+
const code = SUBTOTAL_CODES[table2.columns[index3]?.totalsRowFunction ?? ""];
|
|
23211
23828
|
if (code === void 0) return;
|
|
23212
|
-
const col = table2.range.start.col +
|
|
23829
|
+
const col = table2.range.start.col + index3;
|
|
23213
23830
|
const escaped = name.replace(/['#[\]]/g, "'$&");
|
|
23214
23831
|
const formula = `SUBTOTAL(${code},${table2.displayName || table2.name}[${escaped}])`;
|
|
23215
23832
|
if (sheet.rows.get(row2)?.get(col)?.formula !== formula) out.set(`${row2}:${col}`, formula);
|
|
23216
23833
|
});
|
|
23217
23834
|
return out;
|
|
23218
23835
|
}
|
|
23219
|
-
function resolveTableNames(table2, before,
|
|
23836
|
+
function resolveTableNames(table2, before, index3) {
|
|
23220
23837
|
const display = table2.displayName || table2.name;
|
|
23221
|
-
const displayName = before && before.displayName === display ? display : safeTableName(display,
|
|
23222
|
-
const name = before && before.name === table2.name ? table2.name : table2.name === display ? displayName : safeTableName(table2.name,
|
|
23838
|
+
const displayName = before && before.displayName === display ? display : safeTableName(display, index3);
|
|
23839
|
+
const name = before && before.name === table2.name ? table2.name : table2.name === display ? displayName : safeTableName(table2.name, index3);
|
|
23223
23840
|
return { name, displayName };
|
|
23224
23841
|
}
|
|
23225
|
-
function safeTableName(name,
|
|
23842
|
+
function safeTableName(name, index3) {
|
|
23226
23843
|
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;
|
|
23227
23844
|
if (valid) return name;
|
|
23228
23845
|
const cleaned = name.replace(/[^A-Za-z0-9_.]/g, "_");
|
|
23229
|
-
return `Table_${cleaned ||
|
|
23846
|
+
return `Table_${cleaned || index3}`;
|
|
23230
23847
|
}
|
|
23231
23848
|
|
|
23232
23849
|
// xlsx/write/sheet-parts.ts
|
|
@@ -23239,7 +23856,7 @@ function sourceRelIds(source2, partName) {
|
|
|
23239
23856
|
if (legacy) out.legacy = legacy;
|
|
23240
23857
|
return out;
|
|
23241
23858
|
}
|
|
23242
|
-
function writeComments(ctx, sheet,
|
|
23859
|
+
function writeComments(ctx, sheet, index3, partName, rels) {
|
|
23243
23860
|
const { writer, source: source2 } = ctx;
|
|
23244
23861
|
const name = (pattern) => writer.uniqueName(pattern, ctx.reserved);
|
|
23245
23862
|
const fromSource = source2 && sheet.partName && source2.has(sheet.partName);
|
|
@@ -23284,8 +23901,8 @@ function writeComments(ctx, sheet, index2, partName, rels) {
|
|
|
23284
23901
|
}
|
|
23285
23902
|
}
|
|
23286
23903
|
const own = base ? vmlIdmapBlocks(base) : [];
|
|
23287
|
-
const layout3 = vmlAllocatorFor(ctx, source2).allocate(sheet.comments.length,
|
|
23288
|
-
const parts = commentParts(sheet.comments,
|
|
23904
|
+
const layout3 = vmlAllocatorFor(ctx, source2).allocate(sheet.comments.length, index3 + 1, own);
|
|
23905
|
+
const parts = commentParts(sheet.comments, index3 + 1, ctx.persons, sheet.name, {
|
|
23289
23906
|
...layout3,
|
|
23290
23907
|
...base ? { base } : {}
|
|
23291
23908
|
});
|
|
@@ -23307,11 +23924,11 @@ function sourceVmlPart(source2, sheetPart) {
|
|
|
23307
23924
|
}
|
|
23308
23925
|
function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
23309
23926
|
const ids = [];
|
|
23310
|
-
for (const [
|
|
23927
|
+
for (const [index3, original] of sheet.tables.entries()) {
|
|
23311
23928
|
const { writer, source: source2 } = ctx;
|
|
23312
23929
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
23313
23930
|
const before = sourceXml && original.partName ? parseTable(sourceXml, original.partName) : void 0;
|
|
23314
|
-
const { name, displayName } = resolveTableNames(original, before,
|
|
23931
|
+
const { name, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
23315
23932
|
const table2 = name === original.name && displayName === original.displayName ? original : { ...original, name, displayName };
|
|
23316
23933
|
const { names, headerText: forced } = resolveTableColumns(sheet, table2);
|
|
23317
23934
|
for (const [key, text] of forced) headerText.set(key, text);
|
|
@@ -23593,7 +24210,7 @@ var REGENERATED = /* @__PURE__ */ new Set([
|
|
|
23593
24210
|
]);
|
|
23594
24211
|
var NS_XR2 = "http://schemas.microsoft.com/office/spreadsheetml/2015/revision2";
|
|
23595
24212
|
var NS_XR3 = "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3";
|
|
23596
|
-
function writeWorksheet(ctx, sheet,
|
|
24213
|
+
function writeWorksheet(ctx, sheet, index3, partName) {
|
|
23597
24214
|
const { writer, source: source2 } = ctx;
|
|
23598
24215
|
const rels = new RelationshipSet();
|
|
23599
24216
|
let sourceDrawing;
|
|
@@ -23616,7 +24233,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
23616
24233
|
const tableParts = writeTables(ctx, sheet, partName, rels, headerText, formulas);
|
|
23617
24234
|
blocks.set("sheetPr", sheetPrXml(sheet));
|
|
23618
24235
|
blocks.set("dimension", dimensionXml(sheet));
|
|
23619
|
-
blocks.set("sheetViews", sheetViewsXml(sheet,
|
|
24236
|
+
blocks.set("sheetViews", sheetViewsXml(sheet, index3 === ctx.workbook.activeSheet));
|
|
23620
24237
|
blocks.set("sheetFormatPr", sheetFormatXml(sheet));
|
|
23621
24238
|
blocks.set("cols", colsXml(sheet, ctx.workbook.styles.length));
|
|
23622
24239
|
blocks.set(
|
|
@@ -23655,7 +24272,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
23655
24272
|
);
|
|
23656
24273
|
blocks.set("headerFooter", page.headerFooter);
|
|
23657
24274
|
blocks.set("drawing", writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing));
|
|
23658
|
-
blocks.set("legacyDrawing", writeComments(ctx, sheet,
|
|
24275
|
+
blocks.set("legacyDrawing", writeComments(ctx, sheet, index3, partName, rels));
|
|
23659
24276
|
blocks.set("tableParts", tableParts);
|
|
23660
24277
|
ctx.pivots?.writeSheet(writer, sheet, partName, rels);
|
|
23661
24278
|
blocks.set("extLst", conditionalExtensionsXml(sheet));
|
|
@@ -23680,12 +24297,12 @@ function pivotCacheData(pivot) {
|
|
|
23680
24297
|
const items = pivot.fields.map(() => []);
|
|
23681
24298
|
const indices = pivot.fields.map(() => /* @__PURE__ */ new Map());
|
|
23682
24299
|
for (const record of pivot.records)
|
|
23683
|
-
pivot.fields.forEach((_field,
|
|
23684
|
-
const value2 = record[
|
|
24300
|
+
pivot.fields.forEach((_field, index3) => {
|
|
24301
|
+
const value2 = record[index3] ?? null;
|
|
23685
24302
|
const key = pivotValueKey(value2);
|
|
23686
|
-
if (!indices[
|
|
23687
|
-
indices[
|
|
23688
|
-
items[
|
|
24303
|
+
if (!indices[index3].has(key)) {
|
|
24304
|
+
indices[index3].set(key, items[index3].length);
|
|
24305
|
+
items[index3].push(value2);
|
|
23689
24306
|
}
|
|
23690
24307
|
});
|
|
23691
24308
|
return { items, indices };
|
|
@@ -23700,8 +24317,8 @@ function valueXml(value2) {
|
|
|
23700
24317
|
}
|
|
23701
24318
|
function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
23702
24319
|
const source2 = sparklineDataRange(workbook, 0, pivot.source);
|
|
23703
|
-
const fields = pivot.fields.map((name,
|
|
23704
|
-
const items = data.items[
|
|
24320
|
+
const fields = pivot.fields.map((name, index3) => {
|
|
24321
|
+
const items = data.items[index3];
|
|
23705
24322
|
const types = new Set(
|
|
23706
24323
|
items.map((value2) => value2 === null || value2 === "" ? "blank" : typeof value2)
|
|
23707
24324
|
);
|
|
@@ -23713,7 +24330,7 @@ function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
|
23713
24330
|
}
|
|
23714
24331
|
function pivotCacheRecordsXml(pivot, data) {
|
|
23715
24332
|
const records = pivot.records.map(
|
|
23716
|
-
(record) => `<r>${pivot.fields.map((_field,
|
|
24333
|
+
(record) => `<r>${pivot.fields.map((_field, index3) => `<x v="${data.indices[index3].get(pivotValueKey(record[index3] ?? null))}"/>`).join("")}</r>`
|
|
23717
24334
|
).join("");
|
|
23718
24335
|
return `${XML_HEADER}<pivotCacheRecords xmlns="${NS.x}" count="${pivot.records.length}">${records}</pivotCacheRecords>`;
|
|
23719
24336
|
}
|
|
@@ -23723,45 +24340,87 @@ function pivotTableXml(pivot, cacheId, cache2) {
|
|
|
23723
24340
|
const grid = pivotGrid(pivot);
|
|
23724
24341
|
const row2 = pivot.fields.indexOf(pivot.rowField);
|
|
23725
24342
|
const second = pivot.secondRowField ? pivot.fields.indexOf(pivot.secondRowField) : -1;
|
|
24343
|
+
const page = pivot.pageFilter ? pivot.fields.indexOf(pivot.pageFilter.field) : -1;
|
|
24344
|
+
const pageItems = page >= 0 ? pivotItems(pivot, pivot.pageFilter.field) : [];
|
|
24345
|
+
const axisItems = (field, visible) => page >= 0 ? pivotItems(pivot, field) : visible;
|
|
24346
|
+
const rowItemsFull = axisItems(pivot.rowField, grid.rowItems);
|
|
24347
|
+
const secondRowItemsFull = pivot.secondRowField ? axisItems(pivot.secondRowField, grid.secondRowItems) : [];
|
|
24348
|
+
const columnItemsFull = pivot.columnField ? axisItems(pivot.columnField, grid.columnItems) : [];
|
|
24349
|
+
const itemIndices = (visible, full) => {
|
|
24350
|
+
const indices = new Map(full.map((item, index3) => [pivotValueKey(item), index3]));
|
|
24351
|
+
return visible.map((v) => indices.get(pivotValueKey(v)));
|
|
24352
|
+
};
|
|
24353
|
+
const rowIndicesFull = itemIndices(grid.rowItems, rowItemsFull), secondRowIndicesFull = itemIndices(grid.secondRowItems ?? [], secondRowItemsFull), columnIndicesFull = itemIndices(grid.columnItems, columnItemsFull);
|
|
24354
|
+
const rowEntries = page >= 0 && grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, [rowIndicesFull, secondRowIndicesFull]) : grid.rowEntries;
|
|
24355
|
+
const pageOffset = page >= 0 ? 2 : 0;
|
|
23726
24356
|
const col = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
23727
|
-
const
|
|
24357
|
+
const measures = pivotMeasures(pivot);
|
|
24358
|
+
const multiple = measures.length > 1;
|
|
24359
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
23728
24360
|
const compact = pivot.layout === "compact";
|
|
23729
24361
|
const outline = pivot.layout === "compact" || pivot.layout === "outline";
|
|
23730
24362
|
const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
|
|
23731
|
-
const fields = pivot.fields.map((_field,
|
|
23732
|
-
const items2 =
|
|
23733
|
-
const subtotal = !(
|
|
23734
|
-
const repeated = pivot.repeatLabels && (
|
|
23735
|
-
return `<pivotField${attrs({ axis:
|
|
24363
|
+
const fields = pivot.fields.map((_field, index3) => {
|
|
24364
|
+
const items2 = index3 === page ? pageItems : index3 === row2 ? rowItemsFull : index3 === second ? secondRowItemsFull : index3 === col ? columnItemsFull : void 0;
|
|
24365
|
+
const subtotal = !(index3 === row2 && pivot.subtotals === false);
|
|
24366
|
+
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>' : "";
|
|
24367
|
+
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, 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="${cache2.indices[index3].get(pivotValueKey(item))}"/>`).join("")}${subtotal ? '<item t="default"/>' : ""}</items>` : ""}${repeated}</pivotField>`;
|
|
23736
24368
|
}).join("");
|
|
23737
|
-
const items = (count2) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
23738
|
-
const header = grid.firstDataRow - 1;
|
|
23739
|
-
const rowIndices = [row2, ...second >= 0 ? [second] : []];
|
|
24369
|
+
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
24370
|
+
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : multiple && col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
24371
|
+
const rowIndices = rowsAxis && pivot.valuesPosition === "first" ? [-2, row2, second] : rowsAxis && pivot.valuesPosition === "between" ? [row2, -2, second] : [row2, ...second >= 0 ? [second] : [], ...rowsAxis ? [-2] : []];
|
|
23740
24372
|
let previous = [];
|
|
23741
|
-
const rowItems =
|
|
24373
|
+
const rowItems = rowEntries?.map((entry3) => {
|
|
23742
24374
|
let prefix = 0;
|
|
23743
|
-
if (
|
|
24375
|
+
if (entry3.type === "default" && rowsAxis && pivot.valuesPosition === "first") prefix = 1;
|
|
24376
|
+
else if (!entry3.type)
|
|
23744
24377
|
while (prefix < entry3.indices.length - 1 && entry3.indices[prefix] === previous[prefix])
|
|
23745
24378
|
prefix++;
|
|
23746
|
-
previous = entry3.type ? [] : entry3.indices;
|
|
23747
|
-
return `<i${attrs({ t: entry3.type, r: prefix || void 0 })}>${entry3.indices.slice(prefix).map((
|
|
23748
|
-
}).join("") ?? items(grid.rowItems.length);
|
|
23749
|
-
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((
|
|
23750
|
-
if (
|
|
23751
|
-
body += `<colFields count="1"
|
|
23752
|
-
else
|
|
23753
|
-
|
|
24379
|
+
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
24380
|
+
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>`;
|
|
24381
|
+
}).join("") ?? items(grid.rowItems.length, rowIndicesFull);
|
|
24382
|
+
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>`;
|
|
24383
|
+
if (multiple && !rowsAxis)
|
|
24384
|
+
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)}`;
|
|
24385
|
+
else if (col >= 0)
|
|
24386
|
+
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length, columnIndicesFull)}</colItems>`;
|
|
24387
|
+
else
|
|
24388
|
+
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : page >= 0 ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
24389
|
+
if (page >= 0)
|
|
24390
|
+
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>`;
|
|
24391
|
+
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>`;
|
|
23754
24392
|
const doc = parseXml(
|
|
23755
24393
|
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>`
|
|
23756
24394
|
);
|
|
23757
24395
|
const root = doc.documentElement;
|
|
23758
24396
|
root.setAttribute("name", pivot.name);
|
|
23759
24397
|
root.setAttribute("cacheId", String(cacheId));
|
|
24398
|
+
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
24399
|
+
if (rowsAxis && (pivot.valuesPosition === "between" || pivot.valuesPosition === "first"))
|
|
24400
|
+
root.setAttribute("dataPosition", pivot.valuesPosition === "first" ? "0" : "1");
|
|
24401
|
+
else root.removeAttribute("dataPosition");
|
|
23760
24402
|
root.setAttribute("compact", compact ? "1" : "0");
|
|
23761
24403
|
root.setAttribute("compactData", compact ? "1" : "0");
|
|
23762
24404
|
root.setAttribute("outline", outline ? "1" : "0");
|
|
23763
24405
|
root.setAttribute("outlineData", outline ? "1" : "0");
|
|
23764
24406
|
if (compact) root.setAttribute("indent", "0");
|
|
24407
|
+
if (multiple && !elements(first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement).some(
|
|
24408
|
+
(extension) => first(
|
|
24409
|
+
extension,
|
|
24410
|
+
"pivotTableDefinition",
|
|
24411
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
24412
|
+
)
|
|
24413
|
+
)) {
|
|
24414
|
+
let list = first(root, "extLst", NS.x);
|
|
24415
|
+
if (!list) {
|
|
24416
|
+
list = doc.createElementNS(NS.x, "extLst");
|
|
24417
|
+
root.appendChild(list);
|
|
24418
|
+
}
|
|
24419
|
+
const extension = parseXml(
|
|
24420
|
+
`<ext xmlns="${NS.x}" uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}"><x14:pivotTableDefinition xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" hideValuesRow="1"/></ext>`
|
|
24421
|
+
).documentElement;
|
|
24422
|
+
list.appendChild(doc.importNode(extension, true));
|
|
24423
|
+
}
|
|
23765
24424
|
root.setAttribute("rowGrandTotals", "1");
|
|
23766
24425
|
root.setAttribute("colGrandTotals", "1");
|
|
23767
24426
|
for (const extension of elements(
|
|
@@ -23772,6 +24431,7 @@ function pivotTableXml(pivot, cacheId, cache2) {
|
|
|
23772
24431
|
"pivotTableDefinition",
|
|
23773
24432
|
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
23774
24433
|
);
|
|
24434
|
+
if (multiple && definition) definition.setAttribute("hideValuesRow", "1");
|
|
23775
24435
|
if (definition?.hasAttribute("fillDownLabelsDefault"))
|
|
23776
24436
|
definition.setAttribute("fillDownLabelsDefault", pivot.repeatLabels ? "1" : "0");
|
|
23777
24437
|
}
|
|
@@ -23782,7 +24442,8 @@ function pivotTableXml(pivot, cacheId, cache2) {
|
|
|
23782
24442
|
"rowItems",
|
|
23783
24443
|
"colFields",
|
|
23784
24444
|
"colItems",
|
|
23785
|
-
"dataFields"
|
|
24445
|
+
"dataFields",
|
|
24446
|
+
"pageFields"
|
|
23786
24447
|
]);
|
|
23787
24448
|
for (const child4 of elements(root)) if (replaced.has(child4.localName)) root.removeChild(child4);
|
|
23788
24449
|
const replacement = parseXml(`<root xmlns="${NS.x}">${body}</root>`).documentElement;
|
|
@@ -23967,8 +24628,8 @@ async function saveXlsx(workbook) {
|
|
|
23967
24628
|
return void 0;
|
|
23968
24629
|
});
|
|
23969
24630
|
const sheetRefs = [];
|
|
23970
|
-
workbook.sheets.forEach((sheet,
|
|
23971
|
-
let partName = partNames[
|
|
24631
|
+
workbook.sheets.forEach((sheet, index3) => {
|
|
24632
|
+
let partName = partNames[index3];
|
|
23972
24633
|
const sourceType = partName && source2?.has(partName) ? source2.contentType(partName) : void 0;
|
|
23973
24634
|
const special = sourceType ? SHEET_TYPES[sourceType] : void 0;
|
|
23974
24635
|
if (!partName) {
|
|
@@ -23979,11 +24640,11 @@ async function saveXlsx(workbook) {
|
|
|
23979
24640
|
claimed.add(partName);
|
|
23980
24641
|
}
|
|
23981
24642
|
if (special) writer.carry(partName);
|
|
23982
|
-
else writeWorksheet(ctx, sheet,
|
|
24643
|
+
else writeWorksheet(ctx, sheet, index3, partName);
|
|
23983
24644
|
sheetRefs.push({
|
|
23984
24645
|
name: sheet.name,
|
|
23985
24646
|
sheetId: sheet.sheetId,
|
|
23986
|
-
state: states[
|
|
24647
|
+
state: states[index3] ?? "visible",
|
|
23987
24648
|
relId: rels.add(special ?? RELATIONSHIP_TYPES.worksheet, relativeTarget(bookPart, partName))
|
|
23988
24649
|
});
|
|
23989
24650
|
});
|
|
@@ -24605,10 +25266,10 @@ function hasFlatUniqueStreamLayout(entries, workbookCount) {
|
|
|
24605
25266
|
return new Set(names).size === names.length;
|
|
24606
25267
|
}
|
|
24607
25268
|
function equalBytes(left2, right2) {
|
|
24608
|
-
return left2.length === right2.length && left2.every((value2,
|
|
25269
|
+
return left2.length === right2.length && left2.every((value2, index3) => value2 === right2[index3]);
|
|
24609
25270
|
}
|
|
24610
25271
|
function isCfb(bytes) {
|
|
24611
|
-
return OLE_MAGIC.every((value2,
|
|
25272
|
+
return OLE_MAGIC.every((value2, index3) => bytes[index3] === value2);
|
|
24612
25273
|
}
|
|
24613
25274
|
|
|
24614
25275
|
// ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook-functions.js
|
|
@@ -25049,9 +25710,9 @@ function decode2(rgce, extra, context, options) {
|
|
|
25049
25710
|
break;
|
|
25050
25711
|
case 25: {
|
|
25051
25712
|
const ixti = reader.u16();
|
|
25052
|
-
const
|
|
25713
|
+
const index3 = reader.u16();
|
|
25053
25714
|
reader.skip(2);
|
|
25054
|
-
const name = context.externName(ixti,
|
|
25715
|
+
const name = context.externName(ixti, index3);
|
|
25055
25716
|
if (name === void 0)
|
|
25056
25717
|
return void 0;
|
|
25057
25718
|
push(name);
|
|
@@ -25168,9 +25829,9 @@ var XLS_BUILTIN_FORMATS = {
|
|
|
25168
25829
|
48: "##0.0E+0",
|
|
25169
25830
|
49: "@"
|
|
25170
25831
|
};
|
|
25171
|
-
function paletteColor(
|
|
25172
|
-
const rgb =
|
|
25173
|
-
return rgb ? { index:
|
|
25832
|
+
function paletteColor(index3, palette) {
|
|
25833
|
+
const rgb = index3 < 64 ? palette[index3] : void 0;
|
|
25834
|
+
return rgb ? { index: index3, rgb } : { index: index3, auto: true };
|
|
25174
25835
|
}
|
|
25175
25836
|
var UNDERLINE = {
|
|
25176
25837
|
1: "single",
|
|
@@ -25610,18 +26271,18 @@ function parseGlobals(records) {
|
|
|
25610
26271
|
}
|
|
25611
26272
|
return void 0;
|
|
25612
26273
|
},
|
|
25613
|
-
name(
|
|
25614
|
-
const raw2 = rawNames[
|
|
26274
|
+
name(index3) {
|
|
26275
|
+
const raw2 = rawNames[index3 - 1];
|
|
25615
26276
|
return raw2?.name.name;
|
|
25616
26277
|
},
|
|
25617
|
-
externName(ixti,
|
|
26278
|
+
externName(ixti, index3) {
|
|
25618
26279
|
const xti = xtis[ixti];
|
|
25619
26280
|
const book = xti ? supbooks[xti.book] : void 0;
|
|
25620
26281
|
if (!book)
|
|
25621
26282
|
return void 0;
|
|
25622
26283
|
if (book.kind === "self")
|
|
25623
|
-
return this.name(
|
|
25624
|
-
return book.externNames[
|
|
26284
|
+
return this.name(index3);
|
|
26285
|
+
return book.externNames[index3 - 1];
|
|
25625
26286
|
}
|
|
25626
26287
|
};
|
|
25627
26288
|
for (const raw2 of rawNames) {
|
|
@@ -25952,8 +26613,8 @@ function parseSheet(bound, records, start, globals) {
|
|
|
25952
26613
|
sheet.cells.push(result2);
|
|
25953
26614
|
return result2;
|
|
25954
26615
|
};
|
|
25955
|
-
for (let
|
|
25956
|
-
const record = records[
|
|
26616
|
+
for (let index3 = start; index3 < records.length; index3++) {
|
|
26617
|
+
const record = records[index3];
|
|
25957
26618
|
const { opcode, data } = record;
|
|
25958
26619
|
if (opcode === 2057) {
|
|
25959
26620
|
depth++;
|
|
@@ -26161,7 +26822,7 @@ function parseSheet(bound, records, start, globals) {
|
|
|
26161
26822
|
|
|
26162
26823
|
// ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/legacy-excel-workbook.js
|
|
26163
26824
|
function compoundStreamNames(bytes) {
|
|
26164
|
-
if (!OLE_MAGIC.every((value2,
|
|
26825
|
+
if (!OLE_MAGIC.every((value2, index3) => bytes[index3] === value2))
|
|
26165
26826
|
return [];
|
|
26166
26827
|
try {
|
|
26167
26828
|
const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
@@ -26173,10 +26834,10 @@ function compoundStreamNames(bytes) {
|
|
|
26173
26834
|
function topLevelSubstreams(records) {
|
|
26174
26835
|
const starts = [];
|
|
26175
26836
|
let depth = 0;
|
|
26176
|
-
records.forEach((record,
|
|
26837
|
+
records.forEach((record, index3) => {
|
|
26177
26838
|
if (record.opcode === 2057) {
|
|
26178
|
-
if (depth === 0 &&
|
|
26179
|
-
starts.push(
|
|
26839
|
+
if (depth === 0 && index3 > 0)
|
|
26840
|
+
starts.push(index3);
|
|
26180
26841
|
depth++;
|
|
26181
26842
|
} else if (record.opcode === 10)
|
|
26182
26843
|
depth = Math.max(0, depth - 1);
|
|
@@ -26201,7 +26862,7 @@ function readXlsWorkbook(bytes) {
|
|
|
26201
26862
|
unsupported.push("VBA macros");
|
|
26202
26863
|
if (streams2.some((name) => name === "_SX_DB_CUR") && !unsupported.includes("pivot caches"))
|
|
26203
26864
|
unsupported.push("pivot caches");
|
|
26204
|
-
const byOffset = new Map(records.map((record,
|
|
26865
|
+
const byOffset = new Map(records.map((record, index3) => [record.offset, index3]));
|
|
26205
26866
|
const substreams = topLevelSubstreams(records);
|
|
26206
26867
|
const sheets = globals.sheets.map((bound, position) => {
|
|
26207
26868
|
const start = byOffset.get(bound.offset) ?? substreams[position];
|
|
@@ -26325,7 +26986,7 @@ function layout2(bytes) {
|
|
|
26325
26986
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
26326
26987
|
if (view.getUint16(0, true) !== 65534 || view.getUint16(2, true) > 1 || view.getUint32(24, true) !== 1)
|
|
26327
26988
|
return;
|
|
26328
|
-
if (!FMTID.every((value2,
|
|
26989
|
+
if (!FMTID.every((value2, index3) => bytes[28 + index3] === value2))
|
|
26329
26990
|
return;
|
|
26330
26991
|
const start = view.getUint32(44, true);
|
|
26331
26992
|
if (start < 48 || start % 4 || start + 8 > bytes.length)
|
|
@@ -26483,8 +27144,8 @@ function xfToCellStyle(xls, xf) {
|
|
|
26483
27144
|
}
|
|
26484
27145
|
function defaultXfIndex(xls) {
|
|
26485
27146
|
if (xls.xfs[15] && !xls.xfs[15].isStyle) return 15;
|
|
26486
|
-
const
|
|
26487
|
-
return
|
|
27147
|
+
const index3 = xls.xfs.findIndex((xf) => !xf.isStyle);
|
|
27148
|
+
return index3 >= 0 ? index3 : 0;
|
|
26488
27149
|
}
|
|
26489
27150
|
|
|
26490
27151
|
// xlsx/load/legacy-xls-sheet.ts
|
|
@@ -26678,7 +27339,7 @@ async function loadLegacyXls(input) {
|
|
|
26678
27339
|
workbook.sheets = [];
|
|
26679
27340
|
let undecoded = 0;
|
|
26680
27341
|
let external = false;
|
|
26681
|
-
xls.sheets.forEach((source2,
|
|
27342
|
+
xls.sheets.forEach((source2, index3) => {
|
|
26682
27343
|
if (source2.kind !== "worksheet") {
|
|
26683
27344
|
const kind = source2.kind === "chart" ? "chart sheet" : `${source2.kind} sheet`;
|
|
26684
27345
|
warnings.push(
|
|
@@ -26687,7 +27348,7 @@ async function loadLegacyXls(input) {
|
|
|
26687
27348
|
return;
|
|
26688
27349
|
}
|
|
26689
27350
|
const mapped = mapSheet(source2, workbook.sheets.length + 1, resolve2);
|
|
26690
|
-
sheetIndex2.set(
|
|
27351
|
+
sheetIndex2.set(index3, workbook.sheets.length);
|
|
26691
27352
|
workbook.sheets.push(mapped.sheet);
|
|
26692
27353
|
undecoded += mapped.undecodedFormulas;
|
|
26693
27354
|
external ||= mapped.externalReferences;
|
|
@@ -26796,7 +27457,7 @@ function decodeSpreadsheetText(bytes) {
|
|
|
26796
27457
|
var CFB_MAGIC = [208, 207, 17, 224, 161, 177, 26, 225];
|
|
26797
27458
|
var ZIP_MAGIC = [80, 75, 3, 4];
|
|
26798
27459
|
var toBytes3 = (input) => input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
26799
|
-
var startsWith = (bytes, magic) => magic.every((value2,
|
|
27460
|
+
var startsWith = (bytes, magic) => magic.every((value2, index3) => bytes[index3] === value2);
|
|
26800
27461
|
function zipEntryNames(bytes) {
|
|
26801
27462
|
const names = /* @__PURE__ */ new Set();
|
|
26802
27463
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|