ooxml-core 1.8.4 → 1.9.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-AT7FVG5Q.mjs +2 -0
- package/dist/{PptxHandler-BL4B7CZO.mjs → PptxHandler-EX4WBIQQ.mjs} +2 -2
- package/dist/PptxHandler-VFSCECPL.cjs +11 -0
- package/dist/automation/index.cjs +6652 -4002
- package/dist/automation/index.mjs +6652 -4002
- package/dist/chunk-AT66SA5M.cjs +44423 -0
- package/dist/{chunk-TTPZITQN.mjs → chunk-FIELY5PI.mjs} +1 -1
- package/dist/{chunk-ZAP5WLEN.mjs → chunk-IGOA57LE.mjs} +1 -1
- package/dist/chunk-LCS3J3QI.mjs +87604 -0
- package/dist/{chunk-NIHPA63A.mjs → chunk-M76PHYRR.mjs} +54 -37
- package/dist/chunk-OB277ZGE.mjs +44107 -0
- package/dist/{chunk-GAGSCAR3.mjs → chunk-OXHMZS7B.mjs} +552 -178
- package/dist/chunk-SWF7KVL5.cjs +87610 -0
- package/dist/{chunk-Z7IQR4S4.mjs → chunk-WSO4T2LJ.mjs} +246 -21
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/cell-blocks.d.ts +4 -0
- package/dist/docx/cell-blocks.d.ts.map +1 -0
- package/dist/docx/document-paragraphs.d.ts.map +1 -1
- package/dist/docx/document-parts.d.ts +2 -0
- package/dist/docx/document-parts.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +189 -20
- package/dist/docx/embedded.mjs +189 -20
- package/dist/docx/index.cjs +219 -24
- package/dist/docx/index.mjs +219 -24
- package/dist/docx/layout/adapt-table.d.ts.map +1 -1
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/flow-paragraph.d.ts +5 -0
- package/dist/docx/layout/flow-paragraph.d.ts.map +1 -1
- package/dist/docx/layout/flow-table.d.ts +2 -1
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/footnote-columns.d.ts +22 -0
- package/dist/docx/layout/footnote-columns.d.ts.map +1 -0
- package/dist/docx/layout/footnote-flow.d.ts +27 -0
- package/dist/docx/layout/footnote-flow.d.ts.map +1 -0
- package/dist/docx/layout/footnote-split.d.ts +7 -0
- package/dist/docx/layout/footnote-split.d.ts.map +1 -0
- package/dist/docx/layout/index.cjs +1099 -92
- package/dist/docx/layout/index.mjs +1099 -92
- package/dist/docx/layout/input.d.ts +17 -1
- package/dist/docx/layout/input.d.ts.map +1 -1
- package/dist/docx/layout/legacy-footnote-flow.d.ts +18 -0
- package/dist/docx/layout/legacy-footnote-flow.d.ts.map +1 -0
- package/dist/docx/layout/line-metrics.d.ts.map +1 -1
- package/dist/docx/layout/page-cursor.d.ts +13 -8
- package/dist/docx/layout/page-cursor.d.ts.map +1 -1
- package/dist/docx/layout/page-flow.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-tokens.d.ts +2 -0
- package/dist/docx/layout/paragraph-tokens.d.ts.map +1 -1
- package/dist/docx/layout/reference-footnotes.d.ts +7 -0
- package/dist/docx/layout/reference-footnotes.d.ts.map +1 -0
- package/dist/docx/layout/result.d.ts +31 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/section-flow.d.ts +2 -0
- package/dist/docx/layout/section-flow.d.ts.map +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts +11 -0
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -0
- package/dist/docx/layout/table-footnotes.d.ts +27 -0
- package/dist/docx/layout/table-footnotes.d.ts.map +1 -0
- package/dist/docx/layout/table-layout.d.ts +10 -4
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +194 -25
- package/dist/docx/load/index.mjs +194 -25
- package/dist/docx/model-run.d.ts +2 -0
- package/dist/docx/model-run.d.ts.map +1 -1
- package/dist/docx/model.d.ts +7 -0
- package/dist/docx/model.d.ts.map +1 -1
- package/dist/docx/notes.d.ts +5 -0
- package/dist/docx/notes.d.ts.map +1 -1
- package/dist/docx/parse-table.d.ts.map +1 -1
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/save.d.ts.map +1 -1
- package/dist/docx/section-model.d.ts +2 -0
- package/dist/docx/section-model.d.ts.map +1 -1
- package/dist/docx/sections.d.ts.map +1 -1
- package/dist/docx/settings.d.ts +2 -0
- package/dist/docx/settings.d.ts.map +1 -1
- package/dist/docx/table-model.d.ts +3 -1
- package/dist/docx/table-model.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +55 -0
- package/dist/docx/ui/index.d.ts +1 -0
- package/dist/docx/ui/index.d.ts.map +1 -1
- package/dist/docx/ui/index.mjs +55 -1
- package/dist/docx/ui/table-structure-guard.d.ts +4 -0
- package/dist/docx/ui/table-structure-guard.d.ts.map +1 -0
- package/dist/docx/write-footnote-columns.d.ts +3 -0
- package/dist/docx/write-footnote-columns.d.ts.map +1 -0
- package/dist/docx/write-notes.d.ts.map +1 -1
- package/dist/docx/write-run.d.ts.map +1 -1
- package/dist/docx/write-sections.d.ts.map +1 -1
- package/dist/index.cjs +8 -5
- package/dist/index.mjs +8 -5
- package/dist/opc/clone-part-graph.d.ts +4 -0
- package/dist/opc/clone-part-graph.d.ts.map +1 -1
- package/dist/opc/index.cjs +8 -5
- package/dist/opc/index.mjs +8 -5
- package/dist/pptx/automation/index.cjs +621 -207
- package/dist/pptx/automation/index.d.ts +3 -3
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-Cn-GzYGp.d.ts → index-B4cnSPNz.d.ts} +33 -4
- package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-CKIUurnd.d.ts → index-BZh-IMkN.d.ts} +14 -9
- package/dist/pptx/chunks/{index-CKIUurnd.d.ts.map → index-BZh-IMkN.d.ts.map} +1 -1
- package/dist/pptx/chunks/{text-operations-BHfAm5K9.d.ts → text-operations-BLodkuXE.d.ts} +29 -12
- package/dist/pptx/chunks/text-operations-BLodkuXE.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +622 -213
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +53 -36
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +416 -45
- package/dist/pptx/editor/render/find-replace.d.ts +35 -4
- package/dist/pptx/editor/render/find-replace.d.ts.map +1 -1
- package/dist/pptx/editor/render/find-replace.mjs +416 -46
- package/dist/pptx/editor/render/slide-operations.cjs +87 -0
- package/dist/pptx/editor/render/slide-operations.d.ts +17 -1
- package/dist/pptx/editor/render/slide-operations.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-operations.mjs +83 -1
- package/dist/pptx/editor/render/slide-search.cjs +6 -10
- package/dist/pptx/editor/render/slide-search.d.ts +1 -1
- package/dist/pptx/editor/render/slide-search.mjs +6 -10
- package/dist/pptx/editor/render/template-editing.d.ts +1 -1
- package/dist/pptx/editor/render/template-editing.d.ts.map +1 -1
- package/dist/pptx/index.cjs +889 -237
- package/dist/pptx/index.d.ts +4 -4
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +593 -34
- package/dist/teams/index.mjs +593 -34
- package/dist/visio/accessibility.d.ts +10 -0
- package/dist/visio/accessibility.d.ts.map +1 -0
- package/dist/visio/cell-formula.d.ts +2 -0
- package/dist/visio/cell-formula.d.ts.map +1 -1
- package/dist/visio/connector-curve-aligned.d.ts +5 -0
- package/dist/visio/connector-curve-aligned.d.ts.map +1 -0
- package/dist/visio/connector-curve-spans.d.ts +14 -0
- package/dist/visio/connector-curve-spans.d.ts.map +1 -0
- package/dist/visio/connector-jumps.d.ts +5 -0
- package/dist/visio/connector-jumps.d.ts.map +1 -0
- package/dist/visio/connector-route-walk.d.ts +2 -1
- package/dist/visio/connector-route-walk.d.ts.map +1 -1
- package/dist/visio/edit-alt-text-scope.d.ts +5 -0
- package/dist/visio/edit-alt-text-scope.d.ts.map +1 -0
- package/dist/visio/edit-alt-text.d.ts +3 -0
- package/dist/visio/edit-alt-text.d.ts.map +1 -0
- package/dist/visio/edit-commands.d.ts +7 -2
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-commands.d.ts +5 -0
- package/dist/visio/edit-formatting-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-paint.d.ts.map +1 -1
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
- package/dist/visio/edit-line-jump-cache.d.ts +4 -0
- package/dist/visio/edit-line-jump-cache.d.ts.map +1 -0
- package/dist/visio/edit-master-index.d.ts.map +1 -1
- package/dist/visio/edit-metadata-commands.d.ts +10 -2
- package/dist/visio/edit-metadata-commands.d.ts.map +1 -1
- package/dist/visio/edit-metadata.d.ts +3 -1
- package/dist/visio/edit-metadata.d.ts.map +1 -1
- package/dist/visio/edit-page-alt-text.d.ts +4 -0
- package/dist/visio/edit-page-alt-text.d.ts.map +1 -0
- package/dist/visio/edit-page-layout.d.ts.map +1 -1
- package/dist/visio/edit-page-rename.d.ts.map +1 -1
- package/dist/visio/edit-page-setup-commands.d.ts +7 -1
- package/dist/visio/edit-page-setup-commands.d.ts.map +1 -1
- package/dist/visio/edit-page-size.d.ts.map +1 -1
- package/dist/visio/edit-pages.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-scope.d.ts.map +1 -1
- package/dist/visio/edit-shape-create.d.ts.map +1 -1
- package/dist/visio/edit-stencil-connector-write.d.ts.map +1 -1
- package/dist/visio/edit-style-admission.d.ts.map +1 -1
- package/dist/visio/edit-text.d.ts.map +1 -1
- package/dist/visio/edit.d.ts +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +1091 -233
- package/dist/visio/index.d.ts +2 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +1091 -234
- package/dist/visio/line-jumps.d.ts +1 -5
- package/dist/visio/line-jumps.d.ts.map +1 -1
- package/dist/visio/model.d.ts +13 -0
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/page-layout.d.ts +11 -2
- package/dist/visio/page-layout.d.ts.map +1 -1
- package/dist/visio/parser.d.ts.map +1 -1
- package/dist/visio/shape-metadata.d.ts +6 -0
- package/dist/visio/shape-metadata.d.ts.map +1 -1
- package/dist/visio/shapes.d.ts.map +1 -1
- package/dist/visio/text-field-case.d.ts +2 -0
- package/dist/visio/text-field-case.d.ts.map +1 -0
- package/dist/visio/text-field-display.d.ts.map +1 -1
- package/dist/visio/text-field-numeric.d.ts +4 -0
- package/dist/visio/text-field-numeric.d.ts.map +1 -0
- package/dist/visio/ui/connector-preview.d.ts +1 -1
- package/dist/visio/ui/connector-preview.d.ts.map +1 -1
- package/dist/visio/ui/data-graphic-rules.d.ts +2 -0
- package/dist/visio/ui/data-graphic-rules.d.ts.map +1 -1
- package/dist/visio/ui/data-graphics.d.ts +3 -2
- package/dist/visio/ui/data-graphics.d.ts.map +1 -1
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +16898 -15855
- package/dist/visio/ui/index.mjs +16898 -15856
- package/dist/visio/ui/scene-details.d.ts.map +1 -1
- package/dist/visio/ui/scene-validation.d.ts.map +1 -1
- package/dist/visio/ui/snapshot-scene.d.ts +2 -1
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/visio/xml-attribute-whitespace.d.ts +5 -0
- package/dist/visio/xml-attribute-whitespace.d.ts.map +1 -0
- package/dist/xlsx/edit/index.d.ts +1 -0
- package/dist/xlsx/edit/index.d.ts.map +1 -1
- package/dist/xlsx/edit/insert-guard.d.ts.map +1 -1
- package/dist/xlsx/edit/merge.d.ts.map +1 -1
- package/dist/xlsx/edit/page-breaks.d.ts +5 -0
- package/dist/xlsx/edit/page-breaks.d.ts.map +1 -0
- package/dist/xlsx/edit/pivots.d.ts +8 -0
- package/dist/xlsx/edit/pivots.d.ts.map +1 -0
- package/dist/xlsx/edit/print-titles.d.ts +7 -0
- package/dist/xlsx/edit/print-titles.d.ts.map +1 -0
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/sheets.d.ts.map +1 -1
- package/dist/xlsx/edit/shift-formulas.d.ts.map +1 -1
- package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
- package/dist/xlsx/edit/sparkline-ranges.d.ts +11 -0
- package/dist/xlsx/edit/sparkline-ranges.d.ts.map +1 -0
- package/dist/xlsx/edit/sparkline-xml.d.ts +13 -0
- package/dist/xlsx/edit/sparkline-xml.d.ts.map +1 -0
- package/dist/xlsx/edit/sparklines.d.ts +16 -0
- package/dist/xlsx/edit/sparklines.d.ts.map +1 -0
- package/dist/xlsx/edit/table-edits.d.ts.map +1 -1
- package/dist/xlsx/edit/tables.d.ts.map +1 -1
- package/dist/xlsx/edit/types.d.ts +22 -1
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/text-regex.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +3159 -1164
- package/dist/xlsx/index.d.ts +1 -0
- package/dist/xlsx/index.d.ts.map +1 -1
- package/dist/xlsx/index.mjs +3140 -1165
- package/dist/xlsx/layout/cell-view.d.ts +2 -0
- package/dist/xlsx/layout/cell-view.d.ts.map +1 -1
- package/dist/xlsx/layout/header-footer.d.ts +58 -0
- package/dist/xlsx/layout/header-footer.d.ts.map +1 -0
- package/dist/xlsx/layout/index.d.ts +5 -0
- package/dist/xlsx/layout/index.d.ts.map +1 -1
- package/dist/xlsx/layout/print-breaks.d.ts +11 -0
- package/dist/xlsx/layout/print-breaks.d.ts.map +1 -0
- package/dist/xlsx/layout/print-layout.d.ts +34 -0
- package/dist/xlsx/layout/print-layout.d.ts.map +1 -0
- package/dist/xlsx/layout/print-merges.d.ts +18 -0
- package/dist/xlsx/layout/print-merges.d.ts.map +1 -0
- package/dist/xlsx/layout/print-repeat.d.ts +12 -0
- package/dist/xlsx/layout/print-repeat.d.ts.map +1 -0
- package/dist/xlsx/layout/print-titles.d.ts +20 -0
- package/dist/xlsx/layout/print-titles.d.ts.map +1 -0
- package/dist/xlsx/layout/sparkline-data.d.ts.map +1 -1
- package/dist/xlsx/layout/sparkline-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +7784 -6976
- package/dist/xlsx/load/index.mjs +7784 -6976
- package/dist/xlsx/model-pivots.d.ts +46 -0
- package/dist/xlsx/model-pivots.d.ts.map +1 -0
- package/dist/xlsx/model.d.ts +5 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/pivot/admission.d.ts +5 -0
- package/dist/xlsx/pivot/admission.d.ts.map +1 -0
- package/dist/xlsx/pivot/aggregate.d.ts +19 -0
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -0
- package/dist/xlsx/pivot/cache-xml.d.ts +9 -0
- package/dist/xlsx/pivot/cache-xml.d.ts.map +1 -0
- package/dist/xlsx/pivot/data.d.ts +12 -0
- package/dist/xlsx/pivot/data.d.ts.map +1 -0
- package/dist/xlsx/pivot/hierarchy.d.ts +7 -0
- package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -0
- package/dist/xlsx/pivot/index.d.ts +3 -0
- package/dist/xlsx/pivot/index.d.ts.map +1 -0
- package/dist/xlsx/pivot/read.d.ts +5 -0
- package/dist/xlsx/pivot/read.d.ts.map +1 -0
- package/dist/xlsx/pivot/table-xml.d.ts +5 -0
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -0
- package/dist/xlsx/pivot/write.d.ts +11 -0
- package/dist/xlsx/pivot/write.d.ts.map +1 -0
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/print-layout.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/print-layout.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/sparklines.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/sparklines.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/page-breaks.d.ts +3 -0
- package/dist/xlsx/ui/commands/page-breaks.d.ts.map +1 -0
- package/dist/xlsx/ui/index.cjs +2001 -288
- package/dist/xlsx/ui/index.d.ts +1 -0
- package/dist/xlsx/ui/index.d.ts.map +1 -1
- package/dist/xlsx/ui/index.mjs +2001 -289
- package/dist/xlsx/write/page-setup.d.ts.map +1 -1
- package/dist/xlsx/write/save.d.ts.map +1 -1
- package/dist/xlsx/write/sheet-parts.d.ts +1 -0
- package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/write/worksheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/pptx/chunks/index-Cn-GzYGp.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BHfAm5K9.d.ts.map +0 -1
package/dist/teams/index.mjs
CHANGED
|
@@ -261,9 +261,9 @@ var init_namespaces = __esm({
|
|
|
261
261
|
}
|
|
262
262
|
});
|
|
263
263
|
function parseXml(xml, options = {}) {
|
|
264
|
-
const
|
|
264
|
+
const label3 = options.label ?? "OOXML";
|
|
265
265
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
266
|
-
throw new Error(`${
|
|
266
|
+
throw new Error(`${label3} XML with DTD or entity declarations is not supported`);
|
|
267
267
|
let parseError = "";
|
|
268
268
|
let parsed;
|
|
269
269
|
try {
|
|
@@ -274,12 +274,12 @@ function parseXml(xml, options = {}) {
|
|
|
274
274
|
}).parseFromString(xml, "application/xml");
|
|
275
275
|
} catch (error) {
|
|
276
276
|
throw new Error(
|
|
277
|
-
`Invalid ${
|
|
277
|
+
`Invalid ${label3} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
278
278
|
{ cause: error }
|
|
279
279
|
);
|
|
280
280
|
}
|
|
281
281
|
if (parseError || !parsed.documentElement)
|
|
282
|
-
throw new Error(`Invalid ${
|
|
282
|
+
throw new Error(`Invalid ${label3} XML: ${parseError || "missing root element"}`);
|
|
283
283
|
return parsed;
|
|
284
284
|
}
|
|
285
285
|
function named(element2, local, ns, lenient = true) {
|
|
@@ -913,19 +913,19 @@ var init_opc = __esm({
|
|
|
913
913
|
|
|
914
914
|
// xlsx/address.ts
|
|
915
915
|
function columnLabel(col) {
|
|
916
|
-
let
|
|
916
|
+
let label3 = "";
|
|
917
917
|
let n = col + 1;
|
|
918
918
|
while (n > 0) {
|
|
919
919
|
const rem = (n - 1) % 26;
|
|
920
|
-
|
|
920
|
+
label3 = String.fromCharCode(65 + rem) + label3;
|
|
921
921
|
n = Math.floor((n - 1) / 26);
|
|
922
922
|
}
|
|
923
|
-
return
|
|
923
|
+
return label3;
|
|
924
924
|
}
|
|
925
|
-
function columnIndex(
|
|
926
|
-
if (!/^[A-Za-z]{1,3}$/.test(
|
|
925
|
+
function columnIndex(label3) {
|
|
926
|
+
if (!/^[A-Za-z]{1,3}$/.test(label3)) return -1;
|
|
927
927
|
let n = 0;
|
|
928
|
-
for (const ch of
|
|
928
|
+
for (const ch of label3.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
929
929
|
return n - 1;
|
|
930
930
|
}
|
|
931
931
|
function parseAddress(ref) {
|
|
@@ -2591,10 +2591,10 @@ function titleXml(context, title) {
|
|
|
2591
2591
|
function labelOptionsXml(context, options) {
|
|
2592
2592
|
return numberFormatXml(options.numberFormat) + shapePropertiesXml(context, options.spPr) + textBodyXml(context, options.txPr) + valXml("dLblPos", options.position) + valXml("showLegendKey", options.showLegendKey) + valXml("showVal", options.showValue) + valXml("showCatName", options.showCategoryName) + valXml("showSerName", options.showSeriesName) + valXml("showPercent", options.showPercent) + valXml("showBubbleSize", options.showBubbleSize) + (options.separator === void 0 ? "" : textElement("separator", options.separator));
|
|
2593
2593
|
}
|
|
2594
|
-
function labelXml(context,
|
|
2594
|
+
function labelXml(context, label3) {
|
|
2595
2595
|
return elementXml(
|
|
2596
2596
|
"dLbl",
|
|
2597
|
-
valXml("idx",
|
|
2597
|
+
valXml("idx", label3.index) + valXml("delete", label3.deleted) + layoutXml(context, label3.layout) + chartTextXml(context, label3.tx, false) + labelOptionsXml(context, label3) + raw(context, label3.extLst)
|
|
2598
2598
|
);
|
|
2599
2599
|
}
|
|
2600
2600
|
function dataLabelsXml(context, labels) {
|
|
@@ -2602,7 +2602,7 @@ function dataLabelsXml(context, labels) {
|
|
|
2602
2602
|
const leaderLines = labels.leaderLines ? elementXml("leaderLines", shapePropertiesXml(context, labels.leaderLines.spPr)) : "";
|
|
2603
2603
|
return elementXml(
|
|
2604
2604
|
"dLbls",
|
|
2605
|
-
labels.labels.map((
|
|
2605
|
+
labels.labels.map((label3) => labelXml(context, label3)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
|
|
2606
2606
|
);
|
|
2607
2607
|
}
|
|
2608
2608
|
var textElement, dataSourceXml;
|
|
@@ -2633,12 +2633,12 @@ function dataTableXml(context, table2) {
|
|
|
2633
2633
|
}
|
|
2634
2634
|
function displayUnitsXml(context, units) {
|
|
2635
2635
|
if (!units) return "";
|
|
2636
|
-
const
|
|
2636
|
+
const label3 = units.label;
|
|
2637
2637
|
return elementXml(
|
|
2638
2638
|
"dispUnits",
|
|
2639
|
-
valXml("custUnit", units.customUnit) + (units.customUnit === void 0 ? valXml("builtInUnit", units.builtInUnit) : "") + (
|
|
2639
|
+
valXml("custUnit", units.customUnit) + (units.customUnit === void 0 ? valXml("builtInUnit", units.builtInUnit) : "") + (label3 ? elementXml(
|
|
2640
2640
|
"dispUnitsLbl",
|
|
2641
|
-
layoutXml(context,
|
|
2641
|
+
layoutXml(context, label3.layout) + chartTextXml(context, label3.tx, false) + shapePropertiesXml(context, label3.spPr) + textBodyXml(context, label3.txPr)
|
|
2642
2642
|
) : "") + raw(context, units.extLst)
|
|
2643
2643
|
);
|
|
2644
2644
|
}
|
|
@@ -2849,10 +2849,10 @@ function parseDisplayUnits(context, element2) {
|
|
|
2849
2849
|
if (!element2) return void 0;
|
|
2850
2850
|
reportUnmodelled(context, element2, DISPLAY_UNITS);
|
|
2851
2851
|
const labelElement = cChild(element2, "dispUnitsLbl");
|
|
2852
|
-
let
|
|
2852
|
+
let label3;
|
|
2853
2853
|
if (labelElement) {
|
|
2854
2854
|
reportUnmodelled(context, labelElement, DISPLAY_UNITS_LABEL);
|
|
2855
|
-
|
|
2855
|
+
label3 = assignDefined(
|
|
2856
2856
|
{},
|
|
2857
2857
|
{
|
|
2858
2858
|
layout: manualLayout(labelElement),
|
|
@@ -2867,7 +2867,7 @@ function parseDisplayUnits(context, element2) {
|
|
|
2867
2867
|
{
|
|
2868
2868
|
builtInUnit: cVal(element2, "builtInUnit"),
|
|
2869
2869
|
customUnit: cNumber(context, element2, "custUnit"),
|
|
2870
|
-
label:
|
|
2870
|
+
label: label3,
|
|
2871
2871
|
extLst: extensionList(element2)
|
|
2872
2872
|
}
|
|
2873
2873
|
);
|
|
@@ -15814,13 +15814,27 @@ var init_text_regex = __esm({
|
|
|
15814
15814
|
"REGEXEXTRACT",
|
|
15815
15815
|
C36,
|
|
15816
15816
|
"REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])",
|
|
15817
|
-
"
|
|
15817
|
+
"Extracts the first match (0), all matches (1), or the first match\u2019s capture groups (2).",
|
|
15818
15818
|
2,
|
|
15819
15819
|
4,
|
|
15820
15820
|
(args) => {
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15821
|
+
const mode = optNum(args, 2, 0);
|
|
15822
|
+
if (mode !== 0 && mode !== 1 && mode !== 2) fail(ERR.VALUE);
|
|
15823
|
+
const regex = compile(str(args[1]), caseMode(args, 3), mode === 1);
|
|
15824
|
+
const text = str(args[0]);
|
|
15825
|
+
if (mode === 1) {
|
|
15826
|
+
const matches2 = [];
|
|
15827
|
+
for (const match3 of text.matchAll(regex)) {
|
|
15828
|
+
checkArraySize(matches2.length + 1, 1);
|
|
15829
|
+
matches2.push(match3[0]);
|
|
15830
|
+
}
|
|
15831
|
+
return matches2.length ? new Matrix(matches2.map((match3) => [match3])) : fail(ERR.NA);
|
|
15832
|
+
}
|
|
15833
|
+
const match2 = regex.exec(text);
|
|
15834
|
+
if (!match2) fail(ERR.NA);
|
|
15835
|
+
if (mode === 0) return match2[0];
|
|
15836
|
+
if (match2.length === 1) fail(ERR.VALUE);
|
|
15837
|
+
return new Matrix([match2.slice(1).map((group) => group ?? "")]);
|
|
15824
15838
|
}
|
|
15825
15839
|
),
|
|
15826
15840
|
spec(
|
|
@@ -17499,7 +17513,7 @@ function definedNamesOf(workbook) {
|
|
|
17499
17513
|
});
|
|
17500
17514
|
return names2;
|
|
17501
17515
|
}
|
|
17502
|
-
function workbookXml(workbook, sheets, activeTab, sourceXml) {
|
|
17516
|
+
function workbookXml(workbook, sheets, activeTab, sourceXml, pivotCachesXml) {
|
|
17503
17517
|
const kept = /* @__PURE__ */ new Map();
|
|
17504
17518
|
if (sourceXml) {
|
|
17505
17519
|
try {
|
|
@@ -17543,7 +17557,7 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
|
|
|
17543
17557
|
const iterate = workbook.iterate ? ` iterate="1" iterateCount="${workbook.iterate.count}" iterateDelta="${workbook.iterate.delta}"` : "";
|
|
17544
17558
|
const owned = ["fullCalcOnLoad", "calcId", "calcMode", "iterate", "iterateCount", "iterateDelta"];
|
|
17545
17559
|
out += `<calcPr${copyAttrs(calc, owned)} calcId="191029"${mode}${iterate} fullCalcOnLoad="1"/>`;
|
|
17546
|
-
out += raw2(KEPT_TAIL);
|
|
17560
|
+
out += pivotCachesXml === void 0 ? raw2(KEPT_TAIL) : raw2(KEPT_TAIL.slice(0, 2)) + pivotCachesXml + raw2(KEPT_TAIL.slice(3));
|
|
17547
17561
|
return `${out}</workbook>`;
|
|
17548
17562
|
}
|
|
17549
17563
|
var KEPT_BEFORE_SHEETS, KEPT_AFTER_SHEETS, KEPT_TAIL, copyAttrs;
|
|
@@ -17971,6 +17985,11 @@ function readHeaderFooter(node) {
|
|
|
17971
17985
|
function readPageSetup(margins, setup, headerFooter, fitToPage) {
|
|
17972
17986
|
const page = {};
|
|
17973
17987
|
if (setup) {
|
|
17988
|
+
if (/^(1|true)$/.test(att(setup, "useFirstPageNumber") ?? "")) {
|
|
17989
|
+
page.firstPageNumber = numAttr(setup, "firstPageNumber") ?? 1;
|
|
17990
|
+
}
|
|
17991
|
+
const order = att(setup, "pageOrder");
|
|
17992
|
+
if (order === "downThenOver" || order === "overThenDown") page.pageOrder = order;
|
|
17974
17993
|
const orientation = att(setup, "orientation");
|
|
17975
17994
|
if (orientation && ORIENTATIONS.has(orientation))
|
|
17976
17995
|
page.orientation = orientation;
|
|
@@ -18468,9 +18487,9 @@ var init_gradient_preset_data = __esm({
|
|
|
18468
18487
|
var init_gradient_presets = __esm({
|
|
18469
18488
|
"drawingml/gradient-presets.ts"() {
|
|
18470
18489
|
init_gradient_preset_data();
|
|
18471
|
-
OFFICE_GRADIENT_PRESET_DATA.map(([
|
|
18490
|
+
OFFICE_GRADIENT_PRESET_DATA.map(([label3], index2) => ({
|
|
18472
18491
|
id: index2 + 1,
|
|
18473
|
-
label:
|
|
18492
|
+
label: label3
|
|
18474
18493
|
}));
|
|
18475
18494
|
}
|
|
18476
18495
|
});
|
|
@@ -18706,8 +18725,8 @@ function parseTable(xml, partName) {
|
|
|
18706
18725
|
if (id !== void 0 && Number.isInteger(id) && id >= 0) column.sourceId = id;
|
|
18707
18726
|
const fn = att(node, "totalsRowFunction");
|
|
18708
18727
|
if (fn && fn !== "none") column.totalsRowFunction = fn;
|
|
18709
|
-
const
|
|
18710
|
-
if (
|
|
18728
|
+
const label3 = att(node, "totalsRowLabel");
|
|
18729
|
+
if (label3 !== void 0) column.totalsRowLabel = label3;
|
|
18711
18730
|
const calculated = xFirst(node, "calculatedColumnFormula");
|
|
18712
18731
|
if (calculated) column.calculatedColumnFormula = stripFuturePrefixes(xText(calculated));
|
|
18713
18732
|
return column;
|
|
@@ -18789,20 +18808,28 @@ function setupXml(sheet, page) {
|
|
|
18789
18808
|
const source2 = snapshotElement(sheet, "pageSetup");
|
|
18790
18809
|
const fit = page.fitToWidth !== void 0 || page.fitToHeight !== void 0;
|
|
18791
18810
|
const pick2 = (p) => ({
|
|
18811
|
+
firstPageNumber: p.firstPageNumber,
|
|
18812
|
+
pageOrder: p.pageOrder,
|
|
18792
18813
|
orientation: p.orientation,
|
|
18793
18814
|
paperSize: p.paperSize,
|
|
18794
18815
|
scale: p.scale,
|
|
18795
18816
|
fitToWidth: p.fitToWidth,
|
|
18796
18817
|
fitToHeight: p.fitToHeight
|
|
18797
18818
|
});
|
|
18798
|
-
const modelled = fit || page.orientation !== void 0 || page.paperSize !== void 0 || page.scale !== void 0;
|
|
18819
|
+
const modelled = page.firstPageNumber !== void 0 || page.pageOrder !== void 0 || fit || page.orientation !== void 0 || page.paperSize !== void 0 || page.scale !== void 0;
|
|
18799
18820
|
if (!source2 && !modelled) return "";
|
|
18800
18821
|
if (source2) {
|
|
18801
18822
|
const before = readPageSetup(void 0, source2, void 0, fit) ?? {};
|
|
18802
18823
|
if (sameModel(pick2(before), pick2(page))) return snapshotXml(sheet, "pageSetup") ?? "";
|
|
18803
18824
|
}
|
|
18804
18825
|
const fitValues = fit ? { fitToWidth: page.fitToWidth, fitToHeight: page.fitToHeight } : {};
|
|
18826
|
+
const numbering = page.firstPageNumber !== void 0 || !source2 || readPageSetup(void 0, source2, void 0, fit)?.firstPageNumber !== void 0 ? {
|
|
18827
|
+
firstPageNumber: page.firstPageNumber,
|
|
18828
|
+
useFirstPageNumber: page.firstPageNumber !== void 0 ? true : void 0
|
|
18829
|
+
} : {};
|
|
18805
18830
|
return `<pageSetup${mergedAttrs(source2, {
|
|
18831
|
+
...numbering,
|
|
18832
|
+
pageOrder: page.pageOrder,
|
|
18806
18833
|
paperSize: page.paperSize,
|
|
18807
18834
|
scale: page.scale,
|
|
18808
18835
|
...fitValues,
|
|
@@ -19752,6 +19779,8 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
19752
19779
|
const ids = sourceRelIds(source2, sheet.partName);
|
|
19753
19780
|
for (const [id, rel] of source2.rels(sheet.partName)) {
|
|
19754
19781
|
const target = source2.target(sheet.partName, rel);
|
|
19782
|
+
if (rel.type === RELATIONSHIP_TYPES.pivotTable && target && sheet.preserved.get("source:pivotTables")?.includes(target))
|
|
19783
|
+
continue;
|
|
19755
19784
|
if (rel.type === RELATIONSHIP_TYPES.drawing && id === ids.drawing) sourceDrawing = target;
|
|
19756
19785
|
if (REGENERATED.has(rel.type) || rel.type === RELATIONSHIP_TYPES.vmlDrawing && id === ids.legacy)
|
|
19757
19786
|
continue;
|
|
@@ -19806,6 +19835,7 @@ function writeWorksheet(ctx, sheet, index2, partName) {
|
|
|
19806
19835
|
blocks.set("drawing", writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing));
|
|
19807
19836
|
blocks.set("legacyDrawing", writeComments(ctx, sheet, index2, partName, rels));
|
|
19808
19837
|
blocks.set("tableParts", tableParts);
|
|
19838
|
+
ctx.pivots?.writeSheet(writer, sheet, partName, rels);
|
|
19809
19839
|
blocks.set("extLst", conditionalExtensionsXml(sheet));
|
|
19810
19840
|
for (const [key, list] of sheet.preserved) {
|
|
19811
19841
|
if (key.startsWith("source:") || !ORDER2.includes(key) || (blocks.get(key) ?? "") !== "")
|
|
@@ -19891,6 +19921,532 @@ var init_worksheet2 = __esm({
|
|
|
19891
19921
|
}
|
|
19892
19922
|
});
|
|
19893
19923
|
|
|
19924
|
+
// xlsx/edit/sparkline-ranges.ts
|
|
19925
|
+
function checkedSparklineRange(raw2) {
|
|
19926
|
+
const range = normalizeRange(raw2);
|
|
19927
|
+
for (const point of [range.start, range.end])
|
|
19928
|
+
if (!Number.isInteger(point.row) || !Number.isInteger(point.col) || point.row < 0 || point.col < 0 || point.row > MAX_ROW || point.col > MAX_COL)
|
|
19929
|
+
throw new RangeError("The reference is not valid.");
|
|
19930
|
+
return range;
|
|
19931
|
+
}
|
|
19932
|
+
function sparklineDataRange(workbook, sheet, source2) {
|
|
19933
|
+
let ast;
|
|
19934
|
+
try {
|
|
19935
|
+
ast = parseFormula(source2.trim().replace(/^=/, ""));
|
|
19936
|
+
} catch {
|
|
19937
|
+
throw new Error("The reference is not valid.");
|
|
19938
|
+
}
|
|
19939
|
+
if (ast.type !== "ref" || !ast.ref || !["cell", "area"].includes(ast.ref.kind) || ast.prefix?.book || ast.prefix?.sheet2 || ast.spill)
|
|
19940
|
+
throw new Error("The reference is not valid.");
|
|
19941
|
+
const index2 = ast.prefix ? workbook.sheets.findIndex((ws) => ws.name.toLowerCase() === ast.prefix.sheet.toLowerCase()) : sheet;
|
|
19942
|
+
if (!workbook.sheets[index2]) throw new Error("The reference is not valid.");
|
|
19943
|
+
return { sheet: index2, range: checkedSparklineRange({ start: ast.ref.start, end: ast.ref.end }) };
|
|
19944
|
+
}
|
|
19945
|
+
var init_sparkline_ranges = __esm({
|
|
19946
|
+
"xlsx/edit/sparkline-ranges.ts"() {
|
|
19947
|
+
init_address();
|
|
19948
|
+
init_parser();
|
|
19949
|
+
}
|
|
19950
|
+
});
|
|
19951
|
+
|
|
19952
|
+
// xlsx/pivot/data.ts
|
|
19953
|
+
function pivotValueKey(value) {
|
|
19954
|
+
return value === null || value === "" ? "blank" : isCellError(value) ? `error:${value.error}` : `${typeof value}:${String(value).toLowerCase()}`;
|
|
19955
|
+
}
|
|
19956
|
+
function pivotItems(pivot, field) {
|
|
19957
|
+
const index2 = pivot.fields.indexOf(field);
|
|
19958
|
+
const items = /* @__PURE__ */ new Map();
|
|
19959
|
+
for (const record of pivot.records) {
|
|
19960
|
+
const value = record[index2] ?? null;
|
|
19961
|
+
const key = pivotValueKey(value);
|
|
19962
|
+
if (!items.has(key)) items.set(key, value);
|
|
19963
|
+
}
|
|
19964
|
+
const rank3 = (value) => value === null || value === "" ? 4 : isCellError(value) ? 3 : typeof value === "boolean" ? 2 : typeof value === "string" ? 1 : 0;
|
|
19965
|
+
return [...items.values()].sort(
|
|
19966
|
+
(a2, b) => rank3(a2) - rank3(b) || (typeof a2 === "number" && typeof b === "number" ? a2 - b : String(pivotItemLabel(a2)).localeCompare(String(pivotItemLabel(b)), "en", {
|
|
19967
|
+
sensitivity: "base",
|
|
19968
|
+
numeric: true
|
|
19969
|
+
}))
|
|
19970
|
+
);
|
|
19971
|
+
}
|
|
19972
|
+
function pivotItemLabel(value) {
|
|
19973
|
+
if (value === null || value === "") return "(blank)";
|
|
19974
|
+
if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
|
|
19975
|
+
return isCellError(value) ? value.error : value;
|
|
19976
|
+
}
|
|
19977
|
+
function validatePivotFields(pivot) {
|
|
19978
|
+
const used = [
|
|
19979
|
+
pivot.rowField,
|
|
19980
|
+
...pivot.secondRowField ? [pivot.secondRowField] : [],
|
|
19981
|
+
...pivot.columnField ? [pivot.columnField] : [],
|
|
19982
|
+
pivot.valueField
|
|
19983
|
+
];
|
|
19984
|
+
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")
|
|
19985
|
+
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
19986
|
+
}
|
|
19987
|
+
var PIVOT_AGGREGATES;
|
|
19988
|
+
var init_data = __esm({
|
|
19989
|
+
"xlsx/pivot/data.ts"() {
|
|
19990
|
+
init_model();
|
|
19991
|
+
PIVOT_AGGREGATES = ["sum", "count", "average", "min", "max"];
|
|
19992
|
+
}
|
|
19993
|
+
});
|
|
19994
|
+
|
|
19995
|
+
// xlsx/pivot/cache-xml.ts
|
|
19996
|
+
function pivotCacheData(pivot) {
|
|
19997
|
+
const items = pivot.fields.map(() => []);
|
|
19998
|
+
const indices = pivot.fields.map(() => /* @__PURE__ */ new Map());
|
|
19999
|
+
for (const record of pivot.records)
|
|
20000
|
+
pivot.fields.forEach((_field, index2) => {
|
|
20001
|
+
const value = record[index2] ?? null;
|
|
20002
|
+
const key = pivotValueKey(value);
|
|
20003
|
+
if (!indices[index2].has(key)) {
|
|
20004
|
+
indices[index2].set(key, items[index2].length);
|
|
20005
|
+
items[index2].push(value);
|
|
20006
|
+
}
|
|
20007
|
+
});
|
|
20008
|
+
return { items, indices };
|
|
20009
|
+
}
|
|
20010
|
+
function valueXml(value) {
|
|
20011
|
+
if (value === null || value === "") return "<m/>";
|
|
20012
|
+
if (isCellError(value)) return `<e${attrs({ v: value.error })}/>`;
|
|
20013
|
+
if (typeof value === "string") return `<s${attrs({ v: encodeEscapes(value) })}/>`;
|
|
20014
|
+
if (typeof value === "boolean") return `<b v="${value ? 1 : 0}"/>`;
|
|
20015
|
+
if (!Number.isFinite(value)) throw new Error("The PivotTable cache contains an invalid value.");
|
|
20016
|
+
return `<n v="${value}"/>`;
|
|
20017
|
+
}
|
|
20018
|
+
function pivotCacheDefinitionXml(pivot, workbook, data, recordRel) {
|
|
20019
|
+
const source2 = sparklineDataRange(workbook, 0, pivot.source);
|
|
20020
|
+
const fields = pivot.fields.map((name, index2) => {
|
|
20021
|
+
const items = data.items[index2];
|
|
20022
|
+
const types = new Set(
|
|
20023
|
+
items.map((value) => value === null || value === "" ? "blank" : typeof value)
|
|
20024
|
+
);
|
|
20025
|
+
const nums = items.filter((value) => typeof value === "number");
|
|
20026
|
+
const text = items.some((item) => item !== null && item !== "" && typeof item !== "number");
|
|
20027
|
+
return `<cacheField${attrs({ name: encodeEscapes(name), numFmtId: 0 })}><sharedItems${attrs({ count: items.length, containsString: !nums.length || text, containsNumber: !!nums.length, containsInteger: nums.length > 0 && nums.every(Number.isInteger), containsBlank: types.has("blank"), containsMixedTypes: nums.length > 0 && text, containsSemiMixedTypes: !nums.length || types.size > 1 })}>${items.map(valueXml).join("")}</sharedItems></cacheField>`;
|
|
20028
|
+
}).join("");
|
|
20029
|
+
return `${XML_HEADER}<pivotCacheDefinition xmlns="${NS.x}" xmlns:r="${NS.r}" r:id="${recordRel}" createdVersion="6" refreshedVersion="6" minRefreshableVersion="3" recordCount="${pivot.records.length}"><cacheSource type="worksheet"><worksheetSource${attrs({ ref: formatRange(source2.range), sheet: workbook.sheets[source2.sheet].name })}/></cacheSource><cacheFields count="${pivot.fields.length}">${fields}</cacheFields></pivotCacheDefinition>`;
|
|
20030
|
+
}
|
|
20031
|
+
function pivotCacheRecordsXml(pivot, data) {
|
|
20032
|
+
const records = pivot.records.map(
|
|
20033
|
+
(record) => `<r>${pivot.fields.map((_field, index2) => `<x v="${data.indices[index2].get(pivotValueKey(record[index2] ?? null))}"/>`).join("")}</r>`
|
|
20034
|
+
).join("");
|
|
20035
|
+
return `${XML_HEADER}<pivotCacheRecords xmlns="${NS.x}" count="${pivot.records.length}">${records}</pivotCacheRecords>`;
|
|
20036
|
+
}
|
|
20037
|
+
var init_cache_xml = __esm({
|
|
20038
|
+
"xlsx/pivot/cache-xml.ts"() {
|
|
20039
|
+
init_xml2();
|
|
20040
|
+
init_model();
|
|
20041
|
+
init_address();
|
|
20042
|
+
init_sparkline_ranges();
|
|
20043
|
+
init_xml_out();
|
|
20044
|
+
init_data();
|
|
20045
|
+
}
|
|
20046
|
+
});
|
|
20047
|
+
|
|
20048
|
+
// xlsx/pivot/hierarchy.ts
|
|
20049
|
+
function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
20050
|
+
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
20051
|
+
const secondRowItems = pivotItems(pivot, pivot.secondRowField);
|
|
20052
|
+
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
20053
|
+
const outerField = pivot.fields.indexOf(pivot.rowField);
|
|
20054
|
+
const innerField = pivot.fields.indexOf(pivot.secondRowField);
|
|
20055
|
+
const columnField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
20056
|
+
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
20057
|
+
const layout2 = pivot.layout ?? "tabular";
|
|
20058
|
+
const compact = layout2 === "compact";
|
|
20059
|
+
const top = layout2 !== "tabular" && pivot.subtotals !== false && (pivot.subtotalPosition ?? "top") === "top";
|
|
20060
|
+
const bottom = pivot.subtotals !== false && !top;
|
|
20061
|
+
const rowLabelColumns = compact ? 1 : 2;
|
|
20062
|
+
const groups = /* @__PURE__ */ new Map();
|
|
20063
|
+
const details = /* @__PURE__ */ new Map();
|
|
20064
|
+
const children2 = /* @__PURE__ */ new Map();
|
|
20065
|
+
const innerIndices = new Map(secondRowItems.map((item, index2) => [pivotValueKey(item), index2]));
|
|
20066
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
20067
|
+
const collect = (map, key, record) => {
|
|
20068
|
+
const list = map.get(key);
|
|
20069
|
+
if (list) list.push(record);
|
|
20070
|
+
else map.set(key, [record]);
|
|
20071
|
+
};
|
|
20072
|
+
for (const record of pivot.records) {
|
|
20073
|
+
const outer = pivotValueKey(record[outerField] ?? null);
|
|
20074
|
+
const inner = pivotValueKey(record[innerField] ?? null);
|
|
20075
|
+
collect(groups, outer, record);
|
|
20076
|
+
collect(details, JSON.stringify([outer, inner]), record);
|
|
20077
|
+
if (!children2.has(outer)) children2.set(outer, /* @__PURE__ */ new Set());
|
|
20078
|
+
children2.get(outer).add(inner);
|
|
20079
|
+
if (pivot.columnField) {
|
|
20080
|
+
const column = pivotValueKey(record[columnField] ?? null);
|
|
20081
|
+
for (const key of [[], [outer], [outer, inner]])
|
|
20082
|
+
collect(buckets, JSON.stringify([...key, column]), record);
|
|
20083
|
+
}
|
|
20084
|
+
}
|
|
20085
|
+
const rows = details.size + rowItems.length * (Number(layout2 !== "tabular") + Number(bottom)) + 3;
|
|
20086
|
+
if (rows * (columnItems.length + 3) > 1e6)
|
|
20087
|
+
throw new Error("The PivotTable result is too large.");
|
|
20088
|
+
const labels = compact ? ["Row Labels"] : [pivot.rowField, pivot.secondRowField];
|
|
20089
|
+
const values2 = pivot.columnField ? [
|
|
20090
|
+
[
|
|
20091
|
+
pivot.valueCaption,
|
|
20092
|
+
...compact ? [] : [null],
|
|
20093
|
+
compact ? "Column Labels" : pivot.columnField,
|
|
20094
|
+
...columnItems.slice(1).map(() => null),
|
|
20095
|
+
null
|
|
20096
|
+
],
|
|
20097
|
+
[...labels, ...columnItems.map(label2), "Grand Total"]
|
|
20098
|
+
] : [[...labels, pivot.valueCaption]];
|
|
20099
|
+
const indents = values2.map(() => 0);
|
|
20100
|
+
const rowEntries = [];
|
|
20101
|
+
const append = (labels2, numbers4, entry3, indent = 0) => {
|
|
20102
|
+
values2.push([...labels2, ...numbers4]);
|
|
20103
|
+
rowEntries.push(entry3);
|
|
20104
|
+
indents.push(indent);
|
|
20105
|
+
};
|
|
20106
|
+
const numbers3 = (keys, records) => [
|
|
20107
|
+
...columnItems.map(
|
|
20108
|
+
(column) => aggregate3(
|
|
20109
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
20110
|
+
valueField,
|
|
20111
|
+
pivot.aggregate
|
|
20112
|
+
)
|
|
20113
|
+
),
|
|
20114
|
+
aggregate3(records, valueField, pivot.aggregate)
|
|
20115
|
+
];
|
|
20116
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
20117
|
+
const key = pivotValueKey(outer);
|
|
20118
|
+
if (layout2 !== "tabular")
|
|
20119
|
+
append(
|
|
20120
|
+
[label2(outer), ...compact ? [] : [null]],
|
|
20121
|
+
top ? numbers3([key], groups.get(key) ?? []) : Array(columnItems.length + 1).fill(null),
|
|
20122
|
+
{ indices: [outerIndex] }
|
|
20123
|
+
);
|
|
20124
|
+
let first2 = true;
|
|
20125
|
+
[...children2.get(key)].sort((a2, b) => innerIndices.get(a2) - innerIndices.get(b)).forEach((innerKey) => {
|
|
20126
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
20127
|
+
const inner = secondRowItems[innerIndex];
|
|
20128
|
+
const keys = [key, innerKey];
|
|
20129
|
+
const records = details.get(JSON.stringify(keys));
|
|
20130
|
+
if (!records) return;
|
|
20131
|
+
append(
|
|
20132
|
+
compact ? [label2(inner)] : [
|
|
20133
|
+
pivot.repeatLabels || layout2 === "tabular" && first2 ? label2(outer) : null,
|
|
20134
|
+
label2(inner)
|
|
20135
|
+
],
|
|
20136
|
+
numbers3(keys, records),
|
|
20137
|
+
{ indices: [outerIndex, innerIndex] },
|
|
20138
|
+
compact ? 1 : 0
|
|
20139
|
+
);
|
|
20140
|
+
first2 = false;
|
|
20141
|
+
});
|
|
20142
|
+
if (bottom) {
|
|
20143
|
+
const caption = String(label2(outer));
|
|
20144
|
+
append(
|
|
20145
|
+
[`${caption} Total`, ...compact ? [] : [null]],
|
|
20146
|
+
numbers3([key], groups.get(key) ?? []),
|
|
20147
|
+
{ indices: [outerIndex], type: "default" }
|
|
20148
|
+
);
|
|
20149
|
+
}
|
|
20150
|
+
});
|
|
20151
|
+
append(["Grand Total", ...compact ? [] : [null]], numbers3([], pivot.records), {
|
|
20152
|
+
indices: [0],
|
|
20153
|
+
type: "grand"
|
|
20154
|
+
});
|
|
20155
|
+
return {
|
|
20156
|
+
values: values2,
|
|
20157
|
+
rowItems,
|
|
20158
|
+
secondRowItems,
|
|
20159
|
+
columnItems,
|
|
20160
|
+
rowEntries,
|
|
20161
|
+
firstDataRow: pivot.columnField ? 2 : 1,
|
|
20162
|
+
rowLabelColumns,
|
|
20163
|
+
indents
|
|
20164
|
+
};
|
|
20165
|
+
}
|
|
20166
|
+
var label2;
|
|
20167
|
+
var init_hierarchy2 = __esm({
|
|
20168
|
+
"xlsx/pivot/hierarchy.ts"() {
|
|
20169
|
+
init_data();
|
|
20170
|
+
label2 = pivotItemLabel;
|
|
20171
|
+
}
|
|
20172
|
+
});
|
|
20173
|
+
|
|
20174
|
+
// xlsx/pivot/aggregate.ts
|
|
20175
|
+
function aggregate2(records, field, type) {
|
|
20176
|
+
if (!records.length) return null;
|
|
20177
|
+
const values2 = records.map((record) => record[field] ?? null);
|
|
20178
|
+
if (type === "count") return values2.filter((value) => value !== null && value !== "").length;
|
|
20179
|
+
const error = values2.find(isCellError);
|
|
20180
|
+
if (error) return error;
|
|
20181
|
+
const numbers3 = values2.filter((value) => typeof value === "number");
|
|
20182
|
+
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
20183
|
+
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
20184
|
+
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
20185
|
+
const sum2 = numbers3.reduce((total2, value) => total2 + value, 0);
|
|
20186
|
+
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
20187
|
+
}
|
|
20188
|
+
function pivotGrid(pivot) {
|
|
20189
|
+
validatePivotFields(pivot);
|
|
20190
|
+
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot, aggregate2);
|
|
20191
|
+
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
20192
|
+
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
20193
|
+
if ((rowItems.length + 3) * (columnItems.length + 2) > 1e6)
|
|
20194
|
+
throw new Error("The PivotTable result is too large.");
|
|
20195
|
+
const rowField = pivot.fields.indexOf(pivot.rowField);
|
|
20196
|
+
const colField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
20197
|
+
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
20198
|
+
const groups = /* @__PURE__ */ new Map();
|
|
20199
|
+
const cells2 = /* @__PURE__ */ new Map();
|
|
20200
|
+
const columns = /* @__PURE__ */ new Map();
|
|
20201
|
+
const collect = (map, key, record) => {
|
|
20202
|
+
const found = map.get(key);
|
|
20203
|
+
if (found) found.push(record);
|
|
20204
|
+
else map.set(key, [record]);
|
|
20205
|
+
};
|
|
20206
|
+
for (const record of pivot.records) {
|
|
20207
|
+
const key = pivotValueKey(record[rowField] ?? null);
|
|
20208
|
+
collect(groups, key, record);
|
|
20209
|
+
if (pivot.columnField) {
|
|
20210
|
+
const col = pivotValueKey(record[colField] ?? null);
|
|
20211
|
+
collect(columns, col, record);
|
|
20212
|
+
collect(cells2, JSON.stringify([key, col]), record);
|
|
20213
|
+
}
|
|
20214
|
+
}
|
|
20215
|
+
const label3 = pivotItemLabel;
|
|
20216
|
+
const values2 = pivot.columnField ? [
|
|
20217
|
+
[
|
|
20218
|
+
pivot.valueCaption,
|
|
20219
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
20220
|
+
...columnItems.slice(1).map(() => null),
|
|
20221
|
+
null
|
|
20222
|
+
],
|
|
20223
|
+
[
|
|
20224
|
+
pivot.layout === "compact" ? "Row Labels" : pivot.rowField,
|
|
20225
|
+
...columnItems.map(label3),
|
|
20226
|
+
"Grand Total"
|
|
20227
|
+
]
|
|
20228
|
+
] : [[pivot.layout === "compact" ? "Row Labels" : pivot.rowField, pivot.valueCaption]];
|
|
20229
|
+
for (const row2 of rowItems) {
|
|
20230
|
+
const records = groups.get(pivotValueKey(row2)) ?? [];
|
|
20231
|
+
values2.push([
|
|
20232
|
+
label3(row2),
|
|
20233
|
+
...columnItems.map(
|
|
20234
|
+
(col) => aggregate2(
|
|
20235
|
+
cells2.get(JSON.stringify([pivotValueKey(row2), pivotValueKey(col)])) ?? [],
|
|
20236
|
+
valueField,
|
|
20237
|
+
pivot.aggregate
|
|
20238
|
+
)
|
|
20239
|
+
),
|
|
20240
|
+
aggregate2(records, valueField, pivot.aggregate)
|
|
20241
|
+
]);
|
|
20242
|
+
}
|
|
20243
|
+
values2.push([
|
|
20244
|
+
"Grand Total",
|
|
20245
|
+
...columnItems.map(
|
|
20246
|
+
(col) => aggregate2(columns.get(pivotValueKey(col)) ?? [], valueField, pivot.aggregate)
|
|
20247
|
+
),
|
|
20248
|
+
aggregate2(pivot.records, valueField, pivot.aggregate)
|
|
20249
|
+
]);
|
|
20250
|
+
return { values: values2, rowItems, columnItems, firstDataRow: pivot.columnField ? 2 : 1 };
|
|
20251
|
+
}
|
|
20252
|
+
var init_aggregate = __esm({
|
|
20253
|
+
"xlsx/pivot/aggregate.ts"() {
|
|
20254
|
+
init_model();
|
|
20255
|
+
init_data();
|
|
20256
|
+
init_hierarchy2();
|
|
20257
|
+
}
|
|
20258
|
+
});
|
|
20259
|
+
|
|
20260
|
+
// xlsx/pivot/table-xml.ts
|
|
20261
|
+
function pivotTableXml(pivot, cacheId, cache2) {
|
|
20262
|
+
const grid = pivotGrid(pivot);
|
|
20263
|
+
const row2 = pivot.fields.indexOf(pivot.rowField);
|
|
20264
|
+
const second = pivot.secondRowField ? pivot.fields.indexOf(pivot.secondRowField) : -1;
|
|
20265
|
+
const col = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
20266
|
+
const value = pivot.fields.indexOf(pivot.valueField);
|
|
20267
|
+
const compact = pivot.layout === "compact";
|
|
20268
|
+
const outline = pivot.layout === "compact" || pivot.layout === "outline";
|
|
20269
|
+
const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
|
|
20270
|
+
const fields = pivot.fields.map((_field, index2) => {
|
|
20271
|
+
const items2 = index2 === row2 ? grid.rowItems : index2 === second ? grid.secondRowItems : index2 === col ? grid.columnItems : void 0;
|
|
20272
|
+
const subtotal = !(index2 === row2 && pivot.subtotals === false);
|
|
20273
|
+
const repeated = pivot.repeatLabels && (index2 === row2 || index2 === 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>' : "";
|
|
20274
|
+
return `<pivotField${attrs({ axis: index2 === row2 || index2 === second ? "axisRow" : index2 === col ? "axisCol" : void 0, dataField: index2 === value ? true : void 0, compact, outline, showAll: false, subtotalTop: index2 === row2 ? top : void 0, defaultSubtotal: subtotal ? void 0 : false })}>${items2 ? `<items count="${items2.length + Number(subtotal)}">${items2.map((item) => `<item x="${cache2.indices[index2].get(pivotValueKey(item))}"/>`).join("")}${subtotal ? '<item t="default"/>' : ""}</items>` : ""}${repeated}</pivotField>`;
|
|
20275
|
+
}).join("");
|
|
20276
|
+
const items = (count2) => Array.from({ length: count2 }, (_v, i) => `<i><x v="${i}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
20277
|
+
const header = grid.firstDataRow - 1;
|
|
20278
|
+
const rowIndices = [row2, ...second >= 0 ? [second] : []];
|
|
20279
|
+
let previous = [];
|
|
20280
|
+
const rowItems = grid.rowEntries?.map((entry3) => {
|
|
20281
|
+
let prefix = 0;
|
|
20282
|
+
if (!entry3.type)
|
|
20283
|
+
while (prefix < entry3.indices.length - 1 && entry3.indices[prefix] === previous[prefix])
|
|
20284
|
+
prefix++;
|
|
20285
|
+
previous = entry3.type ? [] : entry3.indices;
|
|
20286
|
+
return `<i${attrs({ t: entry3.type, r: prefix || void 0 })}>${entry3.indices.slice(prefix).map((index2) => `<x${attrs({ v: index2 || void 0 })}/>`).join("")}</i>`;
|
|
20287
|
+
}).join("") ?? items(grid.rowItems.length);
|
|
20288
|
+
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((index2) => `<field x="${index2}"/>`).join("")}</rowFields><rowItems count="${grid.rowEntries?.length ?? grid.rowItems.length + 1}">${rowItems}</rowItems>`;
|
|
20289
|
+
if (col >= 0)
|
|
20290
|
+
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length)}</colItems>`;
|
|
20291
|
+
else body += '<colItems count="1"><i><x/></i></colItems>';
|
|
20292
|
+
body += `<dataFields count="1"><dataField${attrs({ name: encodeEscapes(pivot.valueCaption), fld: value, subtotal: pivot.aggregate, baseField: 0, baseItem: 0 })}/></dataFields>`;
|
|
20293
|
+
const doc = parseXml(
|
|
20294
|
+
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>`
|
|
20295
|
+
);
|
|
20296
|
+
const root = doc.documentElement;
|
|
20297
|
+
root.setAttribute("name", pivot.name);
|
|
20298
|
+
root.setAttribute("cacheId", String(cacheId));
|
|
20299
|
+
root.setAttribute("compact", compact ? "1" : "0");
|
|
20300
|
+
root.setAttribute("compactData", compact ? "1" : "0");
|
|
20301
|
+
root.setAttribute("outline", outline ? "1" : "0");
|
|
20302
|
+
root.setAttribute("outlineData", outline ? "1" : "0");
|
|
20303
|
+
if (compact) root.setAttribute("indent", "0");
|
|
20304
|
+
root.setAttribute("rowGrandTotals", "1");
|
|
20305
|
+
root.setAttribute("colGrandTotals", "1");
|
|
20306
|
+
for (const extension of elements(
|
|
20307
|
+
first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement
|
|
20308
|
+
)) {
|
|
20309
|
+
const definition = first(
|
|
20310
|
+
extension,
|
|
20311
|
+
"pivotTableDefinition",
|
|
20312
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
20313
|
+
);
|
|
20314
|
+
if (definition?.hasAttribute("fillDownLabelsDefault"))
|
|
20315
|
+
definition.setAttribute("fillDownLabelsDefault", pivot.repeatLabels ? "1" : "0");
|
|
20316
|
+
}
|
|
20317
|
+
const replaced = /* @__PURE__ */ new Set([
|
|
20318
|
+
"location",
|
|
20319
|
+
"pivotFields",
|
|
20320
|
+
"rowFields",
|
|
20321
|
+
"rowItems",
|
|
20322
|
+
"colFields",
|
|
20323
|
+
"colItems",
|
|
20324
|
+
"dataFields"
|
|
20325
|
+
]);
|
|
20326
|
+
for (const child3 of elements(root)) if (replaced.has(child3.localName)) root.removeChild(child3);
|
|
20327
|
+
const replacement = parseXml(`<root xmlns="${NS.x}">${body}</root>`).documentElement;
|
|
20328
|
+
const before = root.firstChild;
|
|
20329
|
+
for (const child3 of elements(replacement)) root.insertBefore(doc.importNode(child3, true), before);
|
|
20330
|
+
return XML_HEADER + buildXml(root);
|
|
20331
|
+
}
|
|
20332
|
+
var init_table_xml = __esm({
|
|
20333
|
+
"xlsx/pivot/table-xml.ts"() {
|
|
20334
|
+
init_xml2();
|
|
20335
|
+
init_address();
|
|
20336
|
+
init_xml_out();
|
|
20337
|
+
init_aggregate();
|
|
20338
|
+
init_data();
|
|
20339
|
+
}
|
|
20340
|
+
});
|
|
20341
|
+
|
|
20342
|
+
// xlsx/pivot/write.ts
|
|
20343
|
+
var TYPES, PivotWritePlan;
|
|
20344
|
+
var init_write = __esm({
|
|
20345
|
+
"xlsx/pivot/write.ts"() {
|
|
20346
|
+
init_opc();
|
|
20347
|
+
init_xml2();
|
|
20348
|
+
init_xml_util();
|
|
20349
|
+
init_package_writer();
|
|
20350
|
+
init_drawing();
|
|
20351
|
+
init_cache_xml();
|
|
20352
|
+
init_table_xml();
|
|
20353
|
+
TYPES = {
|
|
20354
|
+
table: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",
|
|
20355
|
+
definition: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml",
|
|
20356
|
+
records: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"
|
|
20357
|
+
};
|
|
20358
|
+
PivotWritePlan = class {
|
|
20359
|
+
tableParts = /* @__PURE__ */ new Map();
|
|
20360
|
+
cachesXml;
|
|
20361
|
+
constructor(writer, workbook, source2, bookPart, bookRels, reserved) {
|
|
20362
|
+
const sourceCaches = source2?.text(bookPart) ? children(
|
|
20363
|
+
first(parseXml(source2.text(bookPart)).documentElement, "pivotCaches", NS.x) ?? parseXml("<root/>").documentElement,
|
|
20364
|
+
"pivotCache",
|
|
20365
|
+
NS.x
|
|
20366
|
+
) : [];
|
|
20367
|
+
const retained = /* @__PURE__ */ new Set();
|
|
20368
|
+
const owns = workbook.sheets.some((sheet) => sheet.pivotTables !== void 0);
|
|
20369
|
+
for (const sheet of workbook.sheets)
|
|
20370
|
+
if (source2 && sheet.partName)
|
|
20371
|
+
for (const rel of source2.rels(sheet.partName).values()) {
|
|
20372
|
+
if (rel.type !== RELATIONSHIP_TYPES.pivotTable) continue;
|
|
20373
|
+
const part = source2.target(sheet.partName, rel);
|
|
20374
|
+
if (!part) continue;
|
|
20375
|
+
const pivot = sheet.pivotTables?.find((entry3) => entry3.partName === part);
|
|
20376
|
+
if (pivot?.dirty || !pivot && sheet.preserved.get("source:pivotTables")?.includes(part))
|
|
20377
|
+
continue;
|
|
20378
|
+
const xml = source2.text(part);
|
|
20379
|
+
if (xml) retained.add(Number(parseXml(xml).documentElement.getAttribute("cacheId")));
|
|
20380
|
+
}
|
|
20381
|
+
const entries = [];
|
|
20382
|
+
for (const node of sourceCaches) {
|
|
20383
|
+
const id = Number(node.getAttribute("cacheId"));
|
|
20384
|
+
if (owns && !retained.has(id)) continue;
|
|
20385
|
+
const rid = relAttr(node, "id");
|
|
20386
|
+
const rel = rid && source2?.rels(bookPart).get(rid);
|
|
20387
|
+
const part = rel && source2?.target(bookPart, rel);
|
|
20388
|
+
if (rel && rid && part) {
|
|
20389
|
+
bookRels.keep(rid, rel);
|
|
20390
|
+
writer.carry(part);
|
|
20391
|
+
entries.push(selfContainedXml(node));
|
|
20392
|
+
}
|
|
20393
|
+
}
|
|
20394
|
+
let cacheId = Math.max(
|
|
20395
|
+
-1,
|
|
20396
|
+
...sourceCaches.map((node) => Number(node.getAttribute("cacheId"))).filter((id) => Number.isInteger(id) && id >= 0)
|
|
20397
|
+
) + 1;
|
|
20398
|
+
for (const sheet of workbook.sheets)
|
|
20399
|
+
for (const pivot of sheet.pivotTables ?? []) {
|
|
20400
|
+
if (pivot.partName && !pivot.dirty) {
|
|
20401
|
+
this.tableParts.set(pivot, pivot.partName);
|
|
20402
|
+
continue;
|
|
20403
|
+
}
|
|
20404
|
+
const table2 = pivot.partName ?? writer.uniqueName((n) => `xl/pivotTables/pivotTable${n}.xml`, reserved);
|
|
20405
|
+
const definition = writer.uniqueName(
|
|
20406
|
+
(n) => `xl/pivotCache/pivotCacheDefinition${n}.xml`,
|
|
20407
|
+
reserved
|
|
20408
|
+
);
|
|
20409
|
+
const records = writer.uniqueName(
|
|
20410
|
+
(n) => `xl/pivotCache/pivotCacheRecords${n}.xml`,
|
|
20411
|
+
reserved
|
|
20412
|
+
);
|
|
20413
|
+
const cache2 = pivotCacheData(pivot);
|
|
20414
|
+
const cacheRels = new RelationshipSet();
|
|
20415
|
+
const recordRel = cacheRels.add(
|
|
20416
|
+
`${NS.r}/pivotCacheRecords`,
|
|
20417
|
+
relativeTarget(definition, records)
|
|
20418
|
+
);
|
|
20419
|
+
writer.add(records, pivotCacheRecordsXml(pivot, cache2), TYPES.records);
|
|
20420
|
+
writer.add(
|
|
20421
|
+
definition,
|
|
20422
|
+
pivotCacheDefinitionXml(pivot, workbook, cache2, recordRel),
|
|
20423
|
+
TYPES.definition
|
|
20424
|
+
);
|
|
20425
|
+
writer.rels(definition, cacheRels);
|
|
20426
|
+
writer.add(table2, pivotTableXml(pivot, cacheId, cache2), TYPES.table);
|
|
20427
|
+
const tableRels = new RelationshipSet();
|
|
20428
|
+
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(table2, definition));
|
|
20429
|
+
writer.rels(table2, tableRels);
|
|
20430
|
+
const rid = bookRels.add(
|
|
20431
|
+
RELATIONSHIP_TYPES.pivotCacheDefinition,
|
|
20432
|
+
relativeTarget(bookPart, definition)
|
|
20433
|
+
);
|
|
20434
|
+
entries.push(`<pivotCache cacheId="${cacheId++}" r:id="${rid}"/>`);
|
|
20435
|
+
this.tableParts.set(pivot, table2);
|
|
20436
|
+
}
|
|
20437
|
+
this.cachesXml = owns ? entries.length ? `<pivotCaches>${entries.join("")}</pivotCaches>` : "" : void 0;
|
|
20438
|
+
}
|
|
20439
|
+
writeSheet(writer, sheet, part, rels) {
|
|
20440
|
+
for (const pivot of sheet.pivotTables ?? []) {
|
|
20441
|
+
const table2 = this.tableParts.get(pivot);
|
|
20442
|
+
writer.carry(table2);
|
|
20443
|
+
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part, table2));
|
|
20444
|
+
}
|
|
20445
|
+
}
|
|
20446
|
+
};
|
|
20447
|
+
}
|
|
20448
|
+
});
|
|
20449
|
+
|
|
19894
20450
|
// xlsx/write/save.ts
|
|
19895
20451
|
async function saveXlsx(workbook) {
|
|
19896
20452
|
if (!workbook.sheets.length) throw new Error("A workbook needs at least one sheet");
|
|
@@ -19933,6 +20489,7 @@ async function saveXlsx(workbook) {
|
|
|
19933
20489
|
if (target) writer.carry(target);
|
|
19934
20490
|
}
|
|
19935
20491
|
}
|
|
20492
|
+
ctx.pivots = new PivotWritePlan(writer, workbook, source2, bookPart, rels, reserved);
|
|
19936
20493
|
const states = workbook.sheets.map((sheet) => sheet.state);
|
|
19937
20494
|
if (!states.includes("visible")) states[0] = "visible";
|
|
19938
20495
|
let activeTab = Math.min(Math.max(0, workbook.activeSheet), workbook.sheets.length - 1);
|
|
@@ -19998,7 +20555,7 @@ async function saveXlsx(workbook) {
|
|
|
19998
20555
|
const sourceXml = sourceBook ? source2?.text(sourceBook) : void 0;
|
|
19999
20556
|
writer.add(
|
|
20000
20557
|
bookPart,
|
|
20001
|
-
workbookXml(workbook, sheetRefs, Math.max(0, activeTab), sourceXml),
|
|
20558
|
+
workbookXml(workbook, sheetRefs, Math.max(0, activeTab), sourceXml, ctx.pivots.cachesXml),
|
|
20002
20559
|
keptVba ? CONTENT_TYPES.workbookMacro : CONTENT_TYPES.workbook
|
|
20003
20560
|
);
|
|
20004
20561
|
writer.rels(bookPart, rels);
|
|
@@ -20041,6 +20598,7 @@ var init_save = __esm({
|
|
|
20041
20598
|
init_doc_props();
|
|
20042
20599
|
init_workbook_part2();
|
|
20043
20600
|
init_worksheet2();
|
|
20601
|
+
init_write();
|
|
20044
20602
|
REGENERATED2 = /* @__PURE__ */ new Set([
|
|
20045
20603
|
RELATIONSHIP_TYPES.worksheet,
|
|
20046
20604
|
RELATIONSHIP_TYPES.chartsheet,
|
|
@@ -20051,7 +20609,8 @@ var init_save = __esm({
|
|
|
20051
20609
|
RELATIONSHIP_TYPES.theme,
|
|
20052
20610
|
RELATIONSHIP_TYPES.calcChain,
|
|
20053
20611
|
RELATIONSHIP_TYPES.person,
|
|
20054
|
-
RELATIONSHIP_TYPES.sheetMetadata
|
|
20612
|
+
RELATIONSHIP_TYPES.sheetMetadata,
|
|
20613
|
+
RELATIONSHIP_TYPES.pivotCacheDefinition
|
|
20055
20614
|
]);
|
|
20056
20615
|
SHEET_TYPES = {
|
|
20057
20616
|
[CONTENT_TYPES.chartsheet]: RELATIONSHIP_TYPES.chartsheet,
|
|
@@ -20071,7 +20630,7 @@ var write_exports = {};
|
|
|
20071
20630
|
__export(write_exports, {
|
|
20072
20631
|
saveXlsx: () => saveXlsx
|
|
20073
20632
|
});
|
|
20074
|
-
var
|
|
20633
|
+
var init_write2 = __esm({
|
|
20075
20634
|
"xlsx/write/index.ts"() {
|
|
20076
20635
|
init_save();
|
|
20077
20636
|
}
|
|
@@ -21586,7 +22145,7 @@ function createFileActions(context) {
|
|
|
21586
22145
|
checkFileAbort(options?.signal);
|
|
21587
22146
|
const [{ createWorkbook: createWorkbook2 }, { saveXlsx: saveXlsx2 }] = await Promise.all([
|
|
21588
22147
|
Promise.resolve().then(() => (init_workbook(), workbook_exports)),
|
|
21589
|
-
Promise.resolve().then(() => (
|
|
22148
|
+
Promise.resolve().then(() => (init_write2(), write_exports))
|
|
21590
22149
|
]);
|
|
21591
22150
|
checkFileAbort(options?.signal);
|
|
21592
22151
|
const bytes = await withFileAbort(() => saveXlsx2(createWorkbook2()), options?.signal);
|