ooxml-core 1.14.0 → 1.16.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-3A7VEXVK.cjs +13 -0
- package/dist/PptxHandler-7POULDRL.mjs +4 -0
- package/dist/{PptxHandler-KNBFECUE.mjs → PptxHandler-M35YFCUC.mjs} +2 -2
- package/dist/PresentationBuilder-C7NPM7OQ.mjs +4 -0
- package/dist/{PresentationBuilder-II7C4A3R.cjs → PresentationBuilder-XVRTITYR.cjs} +6 -5
- package/dist/{PresentationBuilder-5DCCFHWJ.mjs → PresentationBuilder-Y6DJK6H2.mjs} +2 -2
- package/dist/automation/index.cjs +1198 -1095
- package/dist/automation/index.mjs +1198 -1095
- package/dist/chunk-5W2QL4SB.cjs +244 -0
- package/dist/{chunk-TQE7FFNT.cjs → chunk-AHRFBMLK.cjs} +4070 -2015
- package/dist/{chunk-2D4IFQ5M.mjs → chunk-B37EVUMG.mjs} +1 -1
- package/dist/{chunk-4WZLFUUA.mjs → chunk-C2Y6SZDN.mjs} +934 -200
- package/dist/chunk-CA7KCNL3.mjs +236 -0
- package/dist/{chunk-BSUIDT6K.cjs → chunk-DWRJ62KP.cjs} +1 -0
- package/dist/{chunk-TNNXOW2O.mjs → chunk-KOX5Y5E5.mjs} +1 -1
- package/dist/{chunk-54ASP65T.mjs → chunk-LM6VBPQJ.mjs} +416 -15
- package/dist/{chunk-PC4MTLG4.cjs → chunk-OA5V3JJC.cjs} +8 -8
- package/dist/{chunk-ORH32TO3.mjs → chunk-OKGQ2X7D.mjs} +3092 -1037
- package/dist/{chunk-X7MGZQ6C.cjs → chunk-UGWY72WC.cjs} +396 -254
- package/dist/{chunk-XGXIS4PN.mjs → chunk-WBCV52YV.mjs} +3077 -1027
- package/dist/{chunk-2EBMHIGJ.mjs → chunk-WEFFRYXN.mjs} +379 -242
- package/dist/{chunk-AXF2FC4D.mjs → chunk-WSRCLCMB.mjs} +1 -0
- package/dist/{chunk-LMMP67YN.mjs → chunk-XCJRUBGJ.mjs} +1 -1
- package/dist/geometry/index.cjs +259 -0
- package/dist/geometry/index.d.ts +1 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +255 -1
- package/dist/geometry/shape-gallery-catalog.d.ts +32 -0
- package/dist/geometry/shape-gallery-catalog.d.ts.map +1 -0
- package/dist/index.cjs +371 -112
- package/dist/index.mjs +371 -112
- package/dist/pptx/automation/index.cjs +4523 -1957
- package/dist/pptx/automation/index.d.ts +4 -4
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{elements-tK7xnWeS.d.ts → elements-iUzpAeqR.d.ts} +232 -2
- package/dist/pptx/chunks/elements-iUzpAeqR.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-DS9Y4Ne3.d.ts → index-BWHNCVNC.d.ts} +1673 -1534
- package/dist/pptx/chunks/index-BWHNCVNC.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-BSpNQuvz.d.ts → index-CiyTR6mm.d.ts} +201 -5
- package/dist/pptx/chunks/index-CiyTR6mm.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-BdD_UQ11.d.ts → text-operations-CfLVZ7DK.d.ts} +81 -3
- package/dist/pptx/chunks/text-operations-CfLVZ7DK.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +4465 -1899
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +52 -1
- 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 +4 -4
- package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-reconcile.cjs +7 -7
- package/dist/pptx/editor/render/collaboration-reconcile.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-sync.cjs +14 -14
- package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-sync.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +15 -14
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +2 -1
- package/dist/pptx/editor/render/slide-operations.cjs +9 -8
- package/dist/pptx/editor/render/slide-operations.mjs +3 -2
- package/dist/pptx/editor/render/slide-size-rescale.cjs +3 -3
- package/dist/pptx/editor/render/slide-size-rescale.d.ts +1 -1
- package/dist/pptx/editor/render/slide-size-rescale.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-size-rescale.mjs +3 -3
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
- package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
- package/dist/pptx/index.cjs +5656 -2290
- package/dist/pptx/index.d.ts +5 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/ics.d.ts.map +1 -1
- package/dist/teams/index.cjs +631 -635
- package/dist/teams/index.d.ts +1 -0
- package/dist/teams/index.d.ts.map +1 -1
- package/dist/teams/index.mjs +616 -636
- package/dist/teams/meetings.d.ts +11 -1
- package/dist/teams/meetings.d.ts.map +1 -1
- package/dist/teams/recurrence-calendar.d.ts +41 -0
- package/dist/teams/recurrence-calendar.d.ts.map +1 -0
- package/dist/teams/recurrence.d.ts +1 -1
- package/dist/teams/recurrence.d.ts.map +1 -1
- package/dist/teams/server-session.d.ts +19 -0
- package/dist/teams/server-session.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1137 -1027
- package/dist/xlsx/index.mjs +1136 -1028
- package/dist/xlsx/load/index.cjs +593 -652
- package/dist/xlsx/load/index.mjs +593 -652
- package/dist/xlsx/model-pivots.d.ts +64 -4
- package/dist/xlsx/model-pivots.d.ts.map +1 -1
- package/dist/xlsx/pivot/aggregate.d.ts +6 -3
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
- package/dist/xlsx/pivot/axes.d.ts +5 -0
- package/dist/xlsx/pivot/axes.d.ts.map +1 -1
- package/dist/xlsx/pivot/captions-locales.d.ts +3 -0
- package/dist/xlsx/pivot/captions-locales.d.ts.map +1 -0
- package/dist/xlsx/pivot/captions-read.d.ts +14 -0
- package/dist/xlsx/pivot/captions-read.d.ts.map +1 -0
- package/dist/xlsx/pivot/captions.d.ts +26 -0
- package/dist/xlsx/pivot/captions.d.ts.map +1 -0
- package/dist/xlsx/pivot/columns.d.ts +9 -3
- package/dist/xlsx/pivot/columns.d.ts.map +1 -1
- package/dist/xlsx/pivot/data.d.ts +3 -2
- package/dist/xlsx/pivot/data.d.ts.map +1 -1
- package/dist/xlsx/pivot/date-axes.d.ts +1 -1
- package/dist/xlsx/pivot/date-axes.d.ts.map +1 -1
- package/dist/xlsx/pivot/date-group-read.d.ts.map +1 -1
- package/dist/xlsx/pivot/date-groups.d.ts +8 -3
- package/dist/xlsx/pivot/date-groups.d.ts.map +1 -1
- package/dist/xlsx/pivot/index.d.ts +2 -1
- package/dist/xlsx/pivot/index.d.ts.map +1 -1
- package/dist/xlsx/pivot/item-labels.d.ts +12 -0
- package/dist/xlsx/pivot/item-labels.d.ts.map +1 -0
- package/dist/xlsx/pivot/item-names-read.d.ts +8 -0
- package/dist/xlsx/pivot/item-names-read.d.ts.map +1 -0
- package/dist/xlsx/pivot/measures.d.ts +2 -8
- package/dist/xlsx/pivot/measures.d.ts.map +1 -1
- package/dist/xlsx/pivot/nested.d.ts +4 -2
- package/dist/xlsx/pivot/nested.d.ts.map +1 -1
- package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -1
- package/dist/xlsx/pivot/page-filter.d.ts +1 -1
- package/dist/xlsx/pivot/page-filter.d.ts.map +1 -1
- package/dist/xlsx/pivot/read.d.ts.map +1 -1
- package/dist/xlsx/pivot/subtotals.d.ts +6 -1
- package/dist/xlsx/pivot/subtotals.d.ts.map +1 -1
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
- package/dist/xlsx/pivot/values-axis.d.ts +7 -4
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +1002 -1136
- package/dist/xlsx/ui/index.mjs +1002 -1136
- package/package.json +1 -1
- package/dist/PptxHandler-5YP75BPO.cjs +0 -12
- package/dist/PptxHandler-GT5Q66TG.mjs +0 -3
- package/dist/PresentationBuilder-CVM6LJ7L.mjs +0 -3
- package/dist/pptx/chunks/elements-tK7xnWeS.d.ts.map +0 -1
- package/dist/pptx/chunks/index-BSpNQuvz.d.ts.map +0 -1
- package/dist/pptx/chunks/index-DS9Y4Ne3.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BdD_UQ11.d.ts.map +0 -1
- package/dist/xlsx/pivot/hierarchy-first.d.ts +0 -21
- package/dist/xlsx/pivot/hierarchy-first.d.ts.map +0 -1
- package/dist/xlsx/pivot/hierarchy.d.ts +0 -8
- package/dist/xlsx/pivot/hierarchy.d.ts.map +0 -1
|
@@ -75,7 +75,7 @@ var DEFAULT_XML_LIMITS = {
|
|
|
75
75
|
maxNodes: 5e6
|
|
76
76
|
};
|
|
77
77
|
var MARKUP_RE = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<\?[\s\S]*?\?>|<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/g;
|
|
78
|
-
function checkXmlLimits(xml,
|
|
78
|
+
function checkXmlLimits(xml, label2, limits = {}) {
|
|
79
79
|
const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
80
80
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
81
81
|
let depth = 0;
|
|
@@ -88,16 +88,16 @@ function checkXmlLimits(xml, label5, limits = {}) {
|
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
nodes++;
|
|
91
|
-
if (nodes > maxNodes) throw new Error(`${
|
|
91
|
+
if (nodes > maxNodes) throw new Error(`${label2} XML exceeds the limit of ${maxNodes} elements`);
|
|
92
92
|
if (!selfClosing && ++depth > maxDepth)
|
|
93
|
-
throw new Error(`${
|
|
93
|
+
throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
function parseXml(xml, options = {}) {
|
|
97
|
-
const
|
|
97
|
+
const label2 = options.label ?? "OOXML";
|
|
98
98
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
99
|
-
throw new Error(`${
|
|
100
|
-
checkXmlLimits(xml,
|
|
99
|
+
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
100
|
+
checkXmlLimits(xml, label2, options.limits);
|
|
101
101
|
let parseError = "";
|
|
102
102
|
let parsed;
|
|
103
103
|
try {
|
|
@@ -108,12 +108,12 @@ function parseXml(xml, options = {}) {
|
|
|
108
108
|
}).parseFromString(xml, "application/xml");
|
|
109
109
|
} catch (error) {
|
|
110
110
|
throw new Error(
|
|
111
|
-
`Invalid ${
|
|
111
|
+
`Invalid ${label2} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
112
112
|
{ cause: error }
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
if (parseError || !parsed.documentElement)
|
|
116
|
-
throw new Error(`Invalid ${
|
|
116
|
+
throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
|
|
117
117
|
return parsed;
|
|
118
118
|
}
|
|
119
119
|
var buildXml = (node3) => new XMLSerializer().serializeToString(node3);
|
|
@@ -400,10 +400,10 @@ function withParseWarnings(warnings, fn) {
|
|
|
400
400
|
function reportParseWarning(message) {
|
|
401
401
|
if (sink && !sink.includes(message)) sink.push(message);
|
|
402
402
|
}
|
|
403
|
-
function enumValue(guard2, raw2,
|
|
403
|
+
function enumValue(guard2, raw2, label2) {
|
|
404
404
|
if (raw2 === null || raw2 === void 0 || raw2 === "") return void 0;
|
|
405
405
|
if (guard2(raw2)) return raw2;
|
|
406
|
-
reportParseWarning(`Ignored invalid ${
|
|
406
|
+
reportParseWarning(`Ignored invalid ${label2} value \u201C${raw2}\u201D; it is not allowed by the schema.`);
|
|
407
407
|
return void 0;
|
|
408
408
|
}
|
|
409
409
|
|
|
@@ -2292,7 +2292,7 @@ function flatChildren(parent, names, level = "block", enclosing, controls3 = /*
|
|
|
2292
2292
|
return found;
|
|
2293
2293
|
}
|
|
2294
2294
|
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
2295
|
-
var flatRows = (
|
|
2295
|
+
var flatRows = (table4) => flatChildren(table4, ["tr"], "row");
|
|
2296
2296
|
var flatCells = (row3) => flatChildren(row3, ["tc"], "cell");
|
|
2297
2297
|
var flatCellParagraphs = (cell) => flatChildren(cell, ["p"]);
|
|
2298
2298
|
|
|
@@ -3005,42 +3005,42 @@ function buildMargins(doc, margins, tag) {
|
|
|
3005
3005
|
}
|
|
3006
3006
|
return element2.childNodes.length ? element2 : void 0;
|
|
3007
3007
|
}
|
|
3008
|
-
function tableJustification(
|
|
3009
|
-
const { alignment, justification } =
|
|
3008
|
+
function tableJustification(table4) {
|
|
3009
|
+
const { alignment, justification } = table4;
|
|
3010
3010
|
const implied = justification === "start" ? "left" : justification === "end" ? "right" : justification;
|
|
3011
3011
|
return justification && implied === alignment ? justification : alignment;
|
|
3012
3012
|
}
|
|
3013
|
-
function tableColumnCount(
|
|
3013
|
+
function tableColumnCount(table4) {
|
|
3014
3014
|
return Math.max(
|
|
3015
3015
|
1,
|
|
3016
|
-
...
|
|
3016
|
+
...table4.rows.map((row3) => row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0))
|
|
3017
3017
|
);
|
|
3018
3018
|
}
|
|
3019
|
-
function buildNewTableProperties(doc,
|
|
3019
|
+
function buildNewTableProperties(doc, table4, contentWidthTwips) {
|
|
3020
3020
|
const tblPr = makeW(doc, "tblPr");
|
|
3021
|
-
if (
|
|
3021
|
+
if (table4.style) {
|
|
3022
3022
|
const style3 = makeW(doc, "tblStyle");
|
|
3023
|
-
setW2(style3, "val",
|
|
3023
|
+
setW2(style3, "val", table4.style);
|
|
3024
3024
|
tblPr.appendChild(style3);
|
|
3025
3025
|
}
|
|
3026
3026
|
const width = makeW(doc, "tblW");
|
|
3027
|
-
setW2(width, "w", String(
|
|
3028
|
-
setW2(width, "type",
|
|
3027
|
+
setW2(width, "w", String(table4.widthTwips ?? 0));
|
|
3028
|
+
setW2(width, "type", table4.widthTwips ? "dxa" : "auto");
|
|
3029
3029
|
tblPr.appendChild(width);
|
|
3030
|
-
const jcValue = tableJustification(
|
|
3030
|
+
const jcValue = tableJustification(table4);
|
|
3031
3031
|
if (jcValue) {
|
|
3032
3032
|
const jc = makeW(doc, "jc");
|
|
3033
3033
|
setW2(jc, "val", jcValue);
|
|
3034
3034
|
tblPr.appendChild(jc);
|
|
3035
3035
|
}
|
|
3036
|
-
if (
|
|
3036
|
+
if (table4.indentTwips !== void 0) {
|
|
3037
3037
|
const indent = makeW(doc, "tblInd");
|
|
3038
|
-
setW2(indent, "w", String(
|
|
3038
|
+
setW2(indent, "w", String(table4.indentTwips));
|
|
3039
3039
|
setW2(indent, "type", "dxa");
|
|
3040
3040
|
tblPr.appendChild(indent);
|
|
3041
3041
|
}
|
|
3042
|
-
if (
|
|
3043
|
-
const margins =
|
|
3042
|
+
if (table4.borders) tblPr.appendChild(buildBorders(doc, table4.borders, "tblBorders"));
|
|
3043
|
+
const margins = table4.cellMargins && buildMargins(doc, table4.cellMargins, "tblCellMar");
|
|
3044
3044
|
if (margins) tblPr.appendChild(margins);
|
|
3045
3045
|
const look = makeW(doc, "tblLook");
|
|
3046
3046
|
const lookAttributes = [
|
|
@@ -3055,8 +3055,8 @@ function buildNewTableProperties(doc, table3, contentWidthTwips) {
|
|
|
3055
3055
|
for (const [name3, value2] of lookAttributes) setW2(look, name3, value2);
|
|
3056
3056
|
tblPr.appendChild(look);
|
|
3057
3057
|
const tblGrid = makeW(doc, "tblGrid");
|
|
3058
|
-
const columns = tableColumnCount(
|
|
3059
|
-
const widths =
|
|
3058
|
+
const columns = tableColumnCount(table4);
|
|
3059
|
+
const widths = table4.grid?.length === columns ? table4.grid : Array.from({ length: columns }, () => Math.max(1, Math.floor(contentWidthTwips / columns)));
|
|
3060
3060
|
for (const value2 of widths) {
|
|
3061
3061
|
const column2 = makeW(doc, "gridCol");
|
|
3062
3062
|
setW2(column2, "w", String(value2));
|
|
@@ -3304,14 +3304,14 @@ function patchRowProperties(doc, tr, next, base2) {
|
|
|
3304
3304
|
}
|
|
3305
3305
|
orderChildren(props, ROW_ORDER);
|
|
3306
3306
|
}
|
|
3307
|
-
function patchTableMargins(doc,
|
|
3307
|
+
function patchTableMargins(doc, table4, node3, base2) {
|
|
3308
3308
|
patchMarginProperties(
|
|
3309
3309
|
doc,
|
|
3310
3310
|
node3,
|
|
3311
3311
|
"tblPr",
|
|
3312
3312
|
"tblCellMar",
|
|
3313
3313
|
TABLE_ORDER,
|
|
3314
|
-
|
|
3314
|
+
table4.cellMargins,
|
|
3315
3315
|
base2?.cellMargins
|
|
3316
3316
|
);
|
|
3317
3317
|
}
|
|
@@ -3406,12 +3406,12 @@ function patchCellShading(doc, tc, next, base2) {
|
|
|
3406
3406
|
}
|
|
3407
3407
|
|
|
3408
3408
|
// docx/write-table.ts
|
|
3409
|
-
function canEditTableStructure(
|
|
3409
|
+
function canEditTableStructure(table4) {
|
|
3410
3410
|
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node3) => allowed.some((name3) => named2(node3, name3)));
|
|
3411
|
-
if (!only(
|
|
3412
|
-
const grid = first2(
|
|
3411
|
+
if (!only(table4, ["tblPr", "tblGrid", "tr"])) return false;
|
|
3412
|
+
const grid = first2(table4, "tblGrid");
|
|
3413
3413
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
3414
|
-
const rows = children2(
|
|
3414
|
+
const rows = children2(table4, "tr");
|
|
3415
3415
|
if (!rows.length) return false;
|
|
3416
3416
|
const [firstRow] = rows;
|
|
3417
3417
|
if (!firstRow) return false;
|
|
@@ -3437,7 +3437,7 @@ function canEditTableStructure(table3) {
|
|
|
3437
3437
|
}
|
|
3438
3438
|
return true;
|
|
3439
3439
|
}
|
|
3440
|
-
var layout = (
|
|
3440
|
+
var layout = (table4) => table4.rows.map((row3) => row3.map((cell) => cell.paragraphs.map((p) => p.id)));
|
|
3441
3441
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
3442
3442
|
"grid",
|
|
3443
3443
|
"widthTwips",
|
|
@@ -3454,9 +3454,9 @@ function pick(source2, keys) {
|
|
|
3454
3454
|
for (const key2 of keys) if (record2[key2] !== void 0) result2[key2] = record2[key2];
|
|
3455
3455
|
return result2;
|
|
3456
3456
|
}
|
|
3457
|
-
function assertNoDescriptorEdits(
|
|
3457
|
+
function assertNoDescriptorEdits(table4, base2) {
|
|
3458
3458
|
if (!base2) return;
|
|
3459
|
-
if (JSON.stringify(pick(
|
|
3459
|
+
if (JSON.stringify(pick(table4, TABLE_DESCRIPTOR_KEYS)) !== JSON.stringify(pick(base2, TABLE_DESCRIPTOR_KEYS)))
|
|
3460
3460
|
throw new Error(
|
|
3461
3461
|
"Cannot edit table grid widths, width, alignment, indent, borders, or style; only cell text and row/column structure changes are supported. The original DOCX package remains unchanged."
|
|
3462
3462
|
);
|
|
@@ -3466,7 +3466,7 @@ function assertNoDescriptorEdits(table3, base2) {
|
|
|
3466
3466
|
const id3 = cell.paragraphs[0]?.id;
|
|
3467
3467
|
if (id3) baseCellById.set(id3, cell);
|
|
3468
3468
|
}
|
|
3469
|
-
for (const row3 of
|
|
3469
|
+
for (const row3 of table4.rows)
|
|
3470
3470
|
for (const cell of row3) {
|
|
3471
3471
|
const id3 = cell.paragraphs[0]?.id;
|
|
3472
3472
|
const source2 = id3 ? baseCellById.get(id3) : void 0;
|
|
@@ -3482,23 +3482,23 @@ function writeNestedTables(doc, tc, cell, base2, writeParagraph, replaceSlots2)
|
|
|
3482
3482
|
const next = tables(cell.sourceBlocks);
|
|
3483
3483
|
const before = tables(base2?.sourceBlocks);
|
|
3484
3484
|
const nodes = children2(tc, "tbl");
|
|
3485
|
-
next.forEach((
|
|
3485
|
+
next.forEach((table4, index3) => {
|
|
3486
3486
|
const node3 = nodes[index3];
|
|
3487
3487
|
if (node3 && before[index3])
|
|
3488
|
-
writeTable(doc,
|
|
3488
|
+
writeTable(doc, table4, node3, before[index3], writeParagraph, replaceSlots2);
|
|
3489
3489
|
});
|
|
3490
3490
|
}
|
|
3491
|
-
function writeTable(doc,
|
|
3492
|
-
if (base2 && JSON.stringify(
|
|
3493
|
-
assertNoDescriptorEdits(
|
|
3494
|
-
patchTableMargins(doc,
|
|
3495
|
-
const structural = base2 && JSON.stringify(layout(
|
|
3491
|
+
function writeTable(doc, table4, node3, base2, writeParagraph, replaceSlots2) {
|
|
3492
|
+
if (base2 && JSON.stringify(table4) === JSON.stringify(base2)) return node3;
|
|
3493
|
+
assertNoDescriptorEdits(table4, base2);
|
|
3494
|
+
patchTableMargins(doc, table4, node3, base2);
|
|
3495
|
+
const structural = base2 && JSON.stringify(layout(table4)) !== JSON.stringify(layout(base2));
|
|
3496
3496
|
if (structural && !canEditTableStructure(node3))
|
|
3497
3497
|
throw new Error(
|
|
3498
3498
|
"Cannot change the structure of a merged, nested, or complex table. The original DOCX package remains unchanged."
|
|
3499
3499
|
);
|
|
3500
|
-
const width =
|
|
3501
|
-
if (!width ||
|
|
3500
|
+
const width = table4.rows[0]?.length ?? 0;
|
|
3501
|
+
if (!width || table4.rows.some((row3) => row3.length !== width || row3.some((cell) => !cell.paragraphs.length)))
|
|
3502
3502
|
throw new Error("Tables must contain rectangular rows and at least one paragraph per cell.");
|
|
3503
3503
|
const oldRows = flatRows(node3).map((entry3) => entry3.element);
|
|
3504
3504
|
const sourceById = /* @__PURE__ */ new Map();
|
|
@@ -3519,7 +3519,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3519
3519
|
const usedCells = /* @__PURE__ */ new Set();
|
|
3520
3520
|
const usedRows = /* @__PURE__ */ new Set();
|
|
3521
3521
|
const columns = /* @__PURE__ */ new Map();
|
|
3522
|
-
const nextRows =
|
|
3522
|
+
const nextRows = table4.rows.map((row3, rowIndex2) => {
|
|
3523
3523
|
const sources = row3.map(
|
|
3524
3524
|
(cell) => cell.paragraphs.map((p) => sourceById.get(p.id)).find(Boolean)
|
|
3525
3525
|
);
|
|
@@ -3534,7 +3534,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3534
3534
|
patchRowProperties(
|
|
3535
3535
|
doc,
|
|
3536
3536
|
tr,
|
|
3537
|
-
|
|
3537
|
+
table4.rowProperties?.[rowIndex2],
|
|
3538
3538
|
sourceRow === void 0 ? void 0 : base2?.rowProperties?.[sourceRow]
|
|
3539
3539
|
);
|
|
3540
3540
|
const nextCells = row3.map((cell, ci) => {
|
|
@@ -11560,8 +11560,8 @@ function gd14(name3, formula) {
|
|
|
11560
11560
|
const parts = formula.trim().split(/\s+/);
|
|
11561
11561
|
return { name: name3, formula, args: parts.slice(1) };
|
|
11562
11562
|
}
|
|
11563
|
-
function parseGdTable(
|
|
11564
|
-
return
|
|
11563
|
+
function parseGdTable(table4) {
|
|
11564
|
+
return table4.trim().split(/[\n;]/).filter((entry3) => entry3.length > 0).map((entry3) => {
|
|
11565
11565
|
const sep = entry3.indexOf("|");
|
|
11566
11566
|
return gd14(entry3.slice(0, sep), entry3.slice(sep + 1));
|
|
11567
11567
|
});
|
|
@@ -13454,8 +13454,8 @@ function parseDiagramDataModel(source2, part) {
|
|
|
13454
13454
|
"CONNECTION_ENDPOINT_MISSING",
|
|
13455
13455
|
`dgm:cxn ${attribute4} references missing point: ${id3}.`
|
|
13456
13456
|
);
|
|
13457
|
-
const
|
|
13458
|
-
connections2.push(
|
|
13457
|
+
const label2 = connectionLabel(connection, transitionText);
|
|
13458
|
+
connections2.push(label2 ? { ...connection, label: label2 } : connection);
|
|
13459
13459
|
if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
|
|
13460
13460
|
parentById.set(connection.destId, connection.sourceId);
|
|
13461
13461
|
}
|
|
@@ -13494,14 +13494,14 @@ function colorList(container) {
|
|
|
13494
13494
|
}
|
|
13495
13495
|
function parseDiagramColors(source2) {
|
|
13496
13496
|
const root = rootOf2(source2);
|
|
13497
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13498
|
-
name: stringAttribute(
|
|
13499
|
-
fill: colorList(first(
|
|
13500
|
-
line: colorList(first(
|
|
13501
|
-
effect: colorList(first(
|
|
13502
|
-
textLine: colorList(first(
|
|
13503
|
-
textFill: colorList(first(
|
|
13504
|
-
textEffect: colorList(first(
|
|
13497
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13498
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13499
|
+
fill: colorList(first(label2, "fillClrLst", NS.dgm)),
|
|
13500
|
+
line: colorList(first(label2, "linClrLst", NS.dgm)),
|
|
13501
|
+
effect: colorList(first(label2, "effectClrLst", NS.dgm)),
|
|
13502
|
+
textLine: colorList(first(label2, "txLinClrLst", NS.dgm)),
|
|
13503
|
+
textFill: colorList(first(label2, "txFillClrLst", NS.dgm)),
|
|
13504
|
+
textEffect: colorList(first(label2, "txEffectClrLst", NS.dgm))
|
|
13505
13505
|
}));
|
|
13506
13506
|
return { ...parseDefinitionHeader(root), labels };
|
|
13507
13507
|
}
|
|
@@ -13534,16 +13534,16 @@ function parseStyleReferences(style3) {
|
|
|
13534
13534
|
var hasContent = (element2) => Boolean(element2 && (element2.attributes.length > 0 || elements(element2).length > 0));
|
|
13535
13535
|
function parseDiagramQuickStyle(source2) {
|
|
13536
13536
|
const root = rootOf2(source2);
|
|
13537
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13538
|
-
name: stringAttribute(
|
|
13539
|
-
...parseStyleReferences(first(
|
|
13540
|
-
hasScene3d: Boolean(first(
|
|
13541
|
-
hasShape3d: hasContent(first(
|
|
13537
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13538
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13539
|
+
...parseStyleReferences(first(label2, "style", NS.dgm)),
|
|
13540
|
+
hasScene3d: Boolean(first(label2, "scene3d", NS.dgm)),
|
|
13541
|
+
hasShape3d: hasContent(first(label2, "sp3d", NS.dgm))
|
|
13542
13542
|
}));
|
|
13543
13543
|
return {
|
|
13544
13544
|
...parseDefinitionHeader(root),
|
|
13545
13545
|
labels,
|
|
13546
|
-
has3d: labels.some((
|
|
13546
|
+
has3d: labels.some((label2) => label2.hasShape3d)
|
|
13547
13547
|
};
|
|
13548
13548
|
}
|
|
13549
13549
|
function parseDiagramLayoutSummary(source2) {
|
|
@@ -14713,10 +14713,10 @@ function parseDisplayUnits(context, element2) {
|
|
|
14713
14713
|
if (!element2) return void 0;
|
|
14714
14714
|
reportUnmodelled(context, element2, DISPLAY_UNITS);
|
|
14715
14715
|
const labelElement = cChild(element2, "dispUnitsLbl");
|
|
14716
|
-
let
|
|
14716
|
+
let label2;
|
|
14717
14717
|
if (labelElement) {
|
|
14718
14718
|
reportUnmodelled(context, labelElement, DISPLAY_UNITS_LABEL);
|
|
14719
|
-
|
|
14719
|
+
label2 = assignDefined(
|
|
14720
14720
|
{},
|
|
14721
14721
|
{
|
|
14722
14722
|
layout: manualLayout(labelElement),
|
|
@@ -14731,7 +14731,7 @@ function parseDisplayUnits(context, element2) {
|
|
|
14731
14731
|
{
|
|
14732
14732
|
builtInUnit: cVal(element2, "builtInUnit"),
|
|
14733
14733
|
customUnit: cNumber(context, element2, "custUnit"),
|
|
14734
|
-
label:
|
|
14734
|
+
label: label2,
|
|
14735
14735
|
extLst: extensionList2(element2)
|
|
14736
14736
|
}
|
|
14737
14737
|
);
|
|
@@ -15585,10 +15585,10 @@ function titleXml(context, title) {
|
|
|
15585
15585
|
function labelOptionsXml(context, options) {
|
|
15586
15586
|
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));
|
|
15587
15587
|
}
|
|
15588
|
-
function labelXml(context,
|
|
15588
|
+
function labelXml(context, label2) {
|
|
15589
15589
|
return elementXml(
|
|
15590
15590
|
"dLbl",
|
|
15591
|
-
valXml("idx",
|
|
15591
|
+
valXml("idx", label2.index) + valXml("delete", label2.deleted) + layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + labelOptionsXml(context, label2) + raw(context, label2.extLst)
|
|
15592
15592
|
);
|
|
15593
15593
|
}
|
|
15594
15594
|
function dataLabelsXml(context, labels) {
|
|
@@ -15596,7 +15596,7 @@ function dataLabelsXml(context, labels) {
|
|
|
15596
15596
|
const leaderLines = labels.leaderLines ? elementXml("leaderLines", shapePropertiesXml(context, labels.leaderLines.spPr)) : "";
|
|
15597
15597
|
return elementXml(
|
|
15598
15598
|
"dLbls",
|
|
15599
|
-
labels.labels.map((
|
|
15599
|
+
labels.labels.map((label2) => labelXml(context, label2)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
|
|
15600
15600
|
);
|
|
15601
15601
|
}
|
|
15602
15602
|
|
|
@@ -15608,21 +15608,21 @@ function surfaceXml(context, local, surface) {
|
|
|
15608
15608
|
valXml("thickness", surface.thickness) + shapePropertiesXml(context, surface.spPr) + raw(context, surface.pictureOptionsXml) + raw(context, surface.extLst)
|
|
15609
15609
|
);
|
|
15610
15610
|
}
|
|
15611
|
-
function dataTableXml(context,
|
|
15612
|
-
if (!
|
|
15611
|
+
function dataTableXml(context, table4) {
|
|
15612
|
+
if (!table4) return "";
|
|
15613
15613
|
return elementXml(
|
|
15614
15614
|
"dTable",
|
|
15615
|
-
valXml("showHorzBorder",
|
|
15615
|
+
valXml("showHorzBorder", table4.showHorizontalBorder) + valXml("showVertBorder", table4.showVerticalBorder) + valXml("showOutline", table4.showOutline) + valXml("showKeys", table4.showKeys) + shapePropertiesXml(context, table4.spPr) + textBodyXml(context, table4.txPr) + raw(context, table4.extLst)
|
|
15616
15616
|
);
|
|
15617
15617
|
}
|
|
15618
15618
|
function displayUnitsXml(context, units2) {
|
|
15619
15619
|
if (!units2) return "";
|
|
15620
|
-
const
|
|
15620
|
+
const label2 = units2.label;
|
|
15621
15621
|
return elementXml(
|
|
15622
15622
|
"dispUnits",
|
|
15623
|
-
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (
|
|
15623
|
+
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (label2 ? elementXml(
|
|
15624
15624
|
"dispUnitsLbl",
|
|
15625
|
-
layoutXml(context,
|
|
15625
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr)
|
|
15626
15626
|
) : "") + raw(context, units2.extLst)
|
|
15627
15627
|
);
|
|
15628
15628
|
}
|
|
@@ -15647,11 +15647,11 @@ function axisXml(context, axis) {
|
|
|
15647
15647
|
}
|
|
15648
15648
|
|
|
15649
15649
|
// chart/write-analysis.ts
|
|
15650
|
-
function trendlineLabelXml(context,
|
|
15651
|
-
if (!
|
|
15650
|
+
function trendlineLabelXml(context, label2) {
|
|
15651
|
+
if (!label2) return "";
|
|
15652
15652
|
return elementXml(
|
|
15653
15653
|
"trendlineLbl",
|
|
15654
|
-
layoutXml(context,
|
|
15654
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + numberFormatXml(label2.numberFormat) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr) + raw(context, label2.extLst)
|
|
15655
15655
|
);
|
|
15656
15656
|
}
|
|
15657
15657
|
function trendlineXml(context, trendline) {
|
|
@@ -17902,16 +17902,16 @@ var RelationshipAllocator = class {
|
|
|
17902
17902
|
|
|
17903
17903
|
// docx/write.ts
|
|
17904
17904
|
var twips2 = (pixels) => String(Math.round(pixels * 15));
|
|
17905
|
-
function createTable(doc,
|
|
17905
|
+
function createTable(doc, table4, allocator, contentWidthTwips, spans2) {
|
|
17906
17906
|
const node3 = makeW(doc, "tbl");
|
|
17907
|
-
const { tblPr, tblGrid } = buildNewTableProperties(doc,
|
|
17907
|
+
const { tblPr, tblGrid } = buildNewTableProperties(doc, table4, contentWidthTwips);
|
|
17908
17908
|
node3.appendChild(tblPr);
|
|
17909
17909
|
node3.appendChild(tblGrid);
|
|
17910
|
-
const columns = tableColumnCount(
|
|
17911
|
-
|
|
17910
|
+
const columns = tableColumnCount(table4);
|
|
17911
|
+
table4.rows.forEach((row3, rowIndex2) => {
|
|
17912
17912
|
const tr = makeW(doc, "tr");
|
|
17913
17913
|
const spanned = row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0);
|
|
17914
|
-
const trPr = buildRowProperties(doc,
|
|
17914
|
+
const trPr = buildRowProperties(doc, table4.rowProperties?.[rowIndex2], columns - spanned);
|
|
17915
17915
|
if (trPr) tr.appendChild(trPr);
|
|
17916
17916
|
for (const cell of row3) {
|
|
17917
17917
|
const tc = makeW(doc, "tc");
|
|
@@ -18314,28 +18314,28 @@ function validateCell(c2, cell) {
|
|
|
18314
18314
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18315
18315
|
c2.at(".margins").signed(side2, cell.margins[side2], "ST_SignedTwipsMeasure");
|
|
18316
18316
|
}
|
|
18317
|
-
function validateTable(c2,
|
|
18318
|
-
c2.unsigned("widthTwips",
|
|
18319
|
-
c2.signed("indentTwips",
|
|
18317
|
+
function validateTable(c2, table4) {
|
|
18318
|
+
c2.unsigned("widthTwips", table4.widthTwips, "ST_TwipsMeasure");
|
|
18319
|
+
c2.signed("indentTwips", table4.indentTwips, "ST_SignedTwipsMeasure");
|
|
18320
18320
|
c2.check(
|
|
18321
18321
|
"alignment",
|
|
18322
|
-
|
|
18322
|
+
table4.alignment,
|
|
18323
18323
|
(v) => v === "left" || v === "center" || v === "right",
|
|
18324
18324
|
'must be "left", "center" or "right"'
|
|
18325
18325
|
);
|
|
18326
|
-
c2.enum("justification",
|
|
18327
|
-
|
|
18326
|
+
c2.enum("justification", table4.justification, isStJcTable, "ST_JcTable");
|
|
18327
|
+
table4.grid?.forEach(
|
|
18328
18328
|
(width, index3) => c2.at(`.grid[${index3}]`).unsigned("width", width, "ST_TwipsMeasure")
|
|
18329
18329
|
);
|
|
18330
|
-
validateBorders(c2.at(".borders"),
|
|
18331
|
-
if (
|
|
18330
|
+
validateBorders(c2.at(".borders"), table4.borders);
|
|
18331
|
+
if (table4.cellMargins)
|
|
18332
18332
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18333
|
-
c2.at(".cellMargins").signed(side2,
|
|
18334
|
-
|
|
18333
|
+
c2.at(".cellMargins").signed(side2, table4.cellMargins[side2], "ST_SignedTwipsMeasure");
|
|
18334
|
+
table4.rowProperties?.forEach((row3, index3) => {
|
|
18335
18335
|
if (row3)
|
|
18336
18336
|
c2.at(`.rowProperties[${index3}]`).unsigned("heightTwips", row3.heightTwips, "ST_TwipsMeasure");
|
|
18337
18337
|
});
|
|
18338
|
-
|
|
18338
|
+
table4.rows.forEach(
|
|
18339
18339
|
(row3, r) => row3.forEach((cell, k) => validateCell(c2.at(`.rows[${r}][${k}]`), cell))
|
|
18340
18340
|
);
|
|
18341
18341
|
}
|
|
@@ -19767,40 +19767,40 @@ function parseTable(node3, id3, parseParagraph3) {
|
|
|
19767
19767
|
(cell, ci) => parseCell(cell.element, parseParagraph3, `${id3}-r${ri}c${ci}`, cell.control)
|
|
19768
19768
|
)
|
|
19769
19769
|
);
|
|
19770
|
-
const
|
|
19770
|
+
const table4 = { type: "table", id: id3, rows, structureEditable: canEditTableStructure(node3) };
|
|
19771
19771
|
const gridElement = first2(node3, "tblGrid");
|
|
19772
19772
|
const grid = gridElement ? children2(gridElement, "gridCol").flatMap((column2) => {
|
|
19773
19773
|
const width2 = dxa(getW(column2, "w"));
|
|
19774
19774
|
return width2 === void 0 ? [] : [width2];
|
|
19775
19775
|
}) : [];
|
|
19776
|
-
if (grid.length)
|
|
19776
|
+
if (grid.length) table4.grid = grid;
|
|
19777
19777
|
const tblPr = first2(node3, "tblPr");
|
|
19778
19778
|
const tableWidth = first2(tblPr, "tblW");
|
|
19779
19779
|
const width = (getW(tableWidth, "type") ?? "dxa") === "dxa" ? dxa(getW(tableWidth, "w")) : void 0;
|
|
19780
|
-
if (width !== void 0)
|
|
19780
|
+
if (width !== void 0) table4.widthTwips = width;
|
|
19781
19781
|
const justification = enumValue(isStJcTable, getW(first2(tblPr, "jc"), "val"), "w:tblPr/w:jc");
|
|
19782
19782
|
if (justification) {
|
|
19783
|
-
|
|
19783
|
+
table4.justification = justification;
|
|
19784
19784
|
const rtl = onOffElement(first2(tblPr, "bidiVisual")) === true;
|
|
19785
|
-
|
|
19785
|
+
table4.alignment = justification === "start" ? rtl ? "right" : "left" : justification === "end" ? rtl ? "left" : "right" : justification;
|
|
19786
19786
|
}
|
|
19787
19787
|
const indent = parseSignedTwips(getW(first2(tblPr, "tblInd"), "w"));
|
|
19788
|
-
if (indent !== void 0)
|
|
19788
|
+
if (indent !== void 0) table4.indentTwips = indent;
|
|
19789
19789
|
const borders = parseTableBorders(first2(tblPr, "tblBorders"));
|
|
19790
|
-
if (borders)
|
|
19790
|
+
if (borders) table4.borders = borders;
|
|
19791
19791
|
const styleId = getW(first2(tblPr, "tblStyle"), "val");
|
|
19792
|
-
if (styleId)
|
|
19792
|
+
if (styleId) table4.style = styleId;
|
|
19793
19793
|
const look = parseLook(first2(tblPr, "tblLook"));
|
|
19794
|
-
if (look)
|
|
19794
|
+
if (look) table4.look = look;
|
|
19795
19795
|
const cellMargins = parseMargins(first2(tblPr, "tblCellMar"));
|
|
19796
|
-
if (cellMargins)
|
|
19796
|
+
if (cellMargins) table4.cellMargins = cellMargins;
|
|
19797
19797
|
const rowProperties = rowEntries.map(({ element: element2, control }) => {
|
|
19798
19798
|
const properties = parseRowProperties(element2);
|
|
19799
19799
|
if (control) properties.contentControl = control;
|
|
19800
19800
|
return properties;
|
|
19801
19801
|
});
|
|
19802
|
-
if (rowProperties.some((row3) => Object.keys(row3).length))
|
|
19803
|
-
return
|
|
19802
|
+
if (rowProperties.some((row3) => Object.keys(row3).length)) table4.rowProperties = rowProperties;
|
|
19803
|
+
return table4;
|
|
19804
19804
|
}
|
|
19805
19805
|
|
|
19806
19806
|
// docx/hyperlink.ts
|
|
@@ -20854,19 +20854,19 @@ var nextSheetId = (workbook) => workbook.sheets.reduce((max, sheet) => Math.max(
|
|
|
20854
20854
|
var MAX_ROW = 1048575;
|
|
20855
20855
|
var MAX_COL = 16383;
|
|
20856
20856
|
function columnLabel(col) {
|
|
20857
|
-
let
|
|
20857
|
+
let label2 = "";
|
|
20858
20858
|
let n = col + 1;
|
|
20859
20859
|
while (n > 0) {
|
|
20860
20860
|
const rem = (n - 1) % 26;
|
|
20861
|
-
|
|
20861
|
+
label2 = String.fromCharCode(65 + rem) + label2;
|
|
20862
20862
|
n = Math.floor((n - 1) / 26);
|
|
20863
20863
|
}
|
|
20864
|
-
return
|
|
20864
|
+
return label2;
|
|
20865
20865
|
}
|
|
20866
|
-
function columnIndex(
|
|
20867
|
-
if (!/^[A-Za-z]{1,3}$/.test(
|
|
20866
|
+
function columnIndex(label2) {
|
|
20867
|
+
if (!/^[A-Za-z]{1,3}$/.test(label2)) return -1;
|
|
20868
20868
|
let n = 0;
|
|
20869
|
-
for (const ch of
|
|
20869
|
+
for (const ch of label2.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
20870
20870
|
return n - 1;
|
|
20871
20871
|
}
|
|
20872
20872
|
var formatAddress = (address2) => `${columnLabel(address2.col)}${address2.row + 1}`;
|
|
@@ -23225,11 +23225,235 @@ var pivotRowFields = (pivot) => [
|
|
|
23225
23225
|
...pivot.secondRowField ? [pivot.secondRowField] : [],
|
|
23226
23226
|
...pivot.secondRowField ? pivot.moreRowFields ?? [] : []
|
|
23227
23227
|
];
|
|
23228
|
+
function pivotValuesIndex(pivot) {
|
|
23229
|
+
if (pivot.valuesAxis !== "rows") return -1;
|
|
23230
|
+
const count2 = pivotRowFields(pivot).length;
|
|
23231
|
+
const at2 = pivot.valuesPosition;
|
|
23232
|
+
if (typeof at2 === "number") return Math.min(Math.max(Math.trunc(at2), 0), count2);
|
|
23233
|
+
return at2 === "first" ? 0 : at2 === "between" ? Math.min(1, count2) : count2;
|
|
23234
|
+
}
|
|
23228
23235
|
var pivotColumnFields = (pivot) => [
|
|
23229
23236
|
...pivot.columnField ? [pivot.columnField] : [],
|
|
23230
23237
|
...pivot.columnField ? pivot.moreColumnFields ?? [] : []
|
|
23231
23238
|
];
|
|
23232
23239
|
|
|
23240
|
+
// i18n/locale.ts
|
|
23241
|
+
var SUPPORTED_OFFICE_LOCALES = ["en", "fr", "de", "es", "zh-CN"];
|
|
23242
|
+
var DEFAULT_REJECTED_SUBTAGS = ["hant", "tw", "hk", "mo"];
|
|
23243
|
+
function normalizeLocale(input, supported2, fallback, options = {}) {
|
|
23244
|
+
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
23245
|
+
const language = parts[0];
|
|
23246
|
+
if (!language) return fallback;
|
|
23247
|
+
const find3 = (tag) => supported2.find((item) => item.toLowerCase() === tag);
|
|
23248
|
+
const exact = find3(parts.join("-"));
|
|
23249
|
+
if (exact) return exact;
|
|
23250
|
+
const base2 = find3(language);
|
|
23251
|
+
if (base2) return base2;
|
|
23252
|
+
const rejected = options.rejectedSubtags ?? DEFAULT_REJECTED_SUBTAGS;
|
|
23253
|
+
if (parts.slice(1).some((part) => rejected.includes(part))) return fallback;
|
|
23254
|
+
return supported2.find((item) => item.toLowerCase().split("-")[0] === language && item.includes("-")) ?? fallback;
|
|
23255
|
+
}
|
|
23256
|
+
function normalizeOfficeLocale(input) {
|
|
23257
|
+
return normalizeLocale(input, SUPPORTED_OFFICE_LOCALES, "en");
|
|
23258
|
+
}
|
|
23259
|
+
|
|
23260
|
+
// xlsx/pivot/captions-locales.ts
|
|
23261
|
+
var table = (words2, prefix3, rest, functions) => ({
|
|
23262
|
+
...rest,
|
|
23263
|
+
functions,
|
|
23264
|
+
aggregates: Object.fromEntries(
|
|
23265
|
+
Object.keys(words2).map((fn) => [fn, prefix3(words2[fn])])
|
|
23266
|
+
)
|
|
23267
|
+
});
|
|
23268
|
+
var GERMAN = {
|
|
23269
|
+
sum: "Summe",
|
|
23270
|
+
count: "Anzahl",
|
|
23271
|
+
average: "Mittelwert",
|
|
23272
|
+
max: "Max",
|
|
23273
|
+
min: "Min",
|
|
23274
|
+
product: "Produkt",
|
|
23275
|
+
countNums: "Anzahl (Zahlen)",
|
|
23276
|
+
stdDev: "Standardabweichung",
|
|
23277
|
+
stdDevp: "Standardabweichung (Grundgesamtheit)",
|
|
23278
|
+
var: "Varianz",
|
|
23279
|
+
varp: "Varianz (Grundgesamtheit)"
|
|
23280
|
+
};
|
|
23281
|
+
var SPANISH = {
|
|
23282
|
+
sum: "Suma",
|
|
23283
|
+
count: "Cuenta",
|
|
23284
|
+
average: "Promedio",
|
|
23285
|
+
max: "M\xE1x",
|
|
23286
|
+
min: "M\xEDn",
|
|
23287
|
+
product: "Producto",
|
|
23288
|
+
countNums: "Cuenta de n\xFAmeros",
|
|
23289
|
+
stdDev: "Desvest",
|
|
23290
|
+
stdDevp: "Desvestp",
|
|
23291
|
+
var: "Var",
|
|
23292
|
+
varp: "Varp"
|
|
23293
|
+
};
|
|
23294
|
+
var FRENCH = {
|
|
23295
|
+
sum: "Somme",
|
|
23296
|
+
count: "Nombre",
|
|
23297
|
+
average: "Moyenne",
|
|
23298
|
+
max: "Max",
|
|
23299
|
+
min: "Min",
|
|
23300
|
+
product: "Produit",
|
|
23301
|
+
countNums: "Nombre (nombres)",
|
|
23302
|
+
stdDev: "\xC9cartype",
|
|
23303
|
+
stdDevp: "\xC9cartypep",
|
|
23304
|
+
var: "Var",
|
|
23305
|
+
varp: "Varp"
|
|
23306
|
+
};
|
|
23307
|
+
var CHINESE = {
|
|
23308
|
+
sum: "\u6C42\u548C",
|
|
23309
|
+
count: "\u8BA1\u6570",
|
|
23310
|
+
average: "\u5E73\u5747\u503C",
|
|
23311
|
+
max: "\u6700\u5927\u503C",
|
|
23312
|
+
min: "\u6700\u5C0F\u503C",
|
|
23313
|
+
product: "\u4E58\u79EF",
|
|
23314
|
+
countNums: "\u6570\u503C\u8BA1\u6570",
|
|
23315
|
+
stdDev: "\u6807\u51C6\u504F\u5DEE",
|
|
23316
|
+
stdDevp: "\u603B\u4F53\u6807\u51C6\u504F\u5DEE",
|
|
23317
|
+
var: "\u65B9\u5DEE",
|
|
23318
|
+
varp: "\u603B\u4F53\u65B9\u5DEE"
|
|
23319
|
+
};
|
|
23320
|
+
var LOCALIZED_PIVOT_CAPTIONS = {
|
|
23321
|
+
de: table(
|
|
23322
|
+
GERMAN,
|
|
23323
|
+
(word) => `${word} von {0}`,
|
|
23324
|
+
{
|
|
23325
|
+
rowLabels: "Zeilenbeschriftungen",
|
|
23326
|
+
columnLabels: "Spaltenbeschriftungen",
|
|
23327
|
+
grandTotal: "Gesamtergebnis",
|
|
23328
|
+
values: "Werte",
|
|
23329
|
+
all: "(Alle)",
|
|
23330
|
+
blank: "(leer)",
|
|
23331
|
+
subtotal: "{0} Ergebnis",
|
|
23332
|
+
measureTotal: "Gesamt {0}"
|
|
23333
|
+
},
|
|
23334
|
+
GERMAN
|
|
23335
|
+
),
|
|
23336
|
+
es: table(
|
|
23337
|
+
SPANISH,
|
|
23338
|
+
(word) => `${word} de {0}`,
|
|
23339
|
+
{
|
|
23340
|
+
rowLabels: "Etiquetas de fila",
|
|
23341
|
+
columnLabels: "Etiquetas de columna",
|
|
23342
|
+
grandTotal: "Total general",
|
|
23343
|
+
values: "Valores",
|
|
23344
|
+
all: "(Todas)",
|
|
23345
|
+
blank: "(en blanco)",
|
|
23346
|
+
subtotal: "{0} Total",
|
|
23347
|
+
measureTotal: "Total {0}"
|
|
23348
|
+
},
|
|
23349
|
+
SPANISH
|
|
23350
|
+
),
|
|
23351
|
+
fr: table(
|
|
23352
|
+
FRENCH,
|
|
23353
|
+
(word) => `${word} de {0}`,
|
|
23354
|
+
{
|
|
23355
|
+
rowLabels: "\xC9tiquettes de lignes",
|
|
23356
|
+
columnLabels: "\xC9tiquettes de colonnes",
|
|
23357
|
+
grandTotal: "Total g\xE9n\xE9ral",
|
|
23358
|
+
values: "Valeurs",
|
|
23359
|
+
all: "(Tous)",
|
|
23360
|
+
blank: "(vide)",
|
|
23361
|
+
subtotal: "{0} Total",
|
|
23362
|
+
measureTotal: "Total {0}"
|
|
23363
|
+
},
|
|
23364
|
+
FRENCH
|
|
23365
|
+
),
|
|
23366
|
+
"zh-CN": table(
|
|
23367
|
+
CHINESE,
|
|
23368
|
+
(word) => `${word}\u9879:{0}`,
|
|
23369
|
+
{
|
|
23370
|
+
rowLabels: "\u884C\u6807\u7B7E",
|
|
23371
|
+
columnLabels: "\u5217\u6807\u7B7E",
|
|
23372
|
+
grandTotal: "\u603B\u8BA1",
|
|
23373
|
+
values: "\u6570\u503C",
|
|
23374
|
+
all: "(\u5168\u90E8)",
|
|
23375
|
+
blank: "(\u7A7A\u767D)",
|
|
23376
|
+
subtotal: "{0} \u6C47\u603B",
|
|
23377
|
+
measureTotal: "\u603B\u8BA1 {0}"
|
|
23378
|
+
},
|
|
23379
|
+
CHINESE
|
|
23380
|
+
)
|
|
23381
|
+
};
|
|
23382
|
+
|
|
23383
|
+
// xlsx/pivot/captions.ts
|
|
23384
|
+
var FUNCTIONS = {
|
|
23385
|
+
sum: "Sum",
|
|
23386
|
+
count: "Count",
|
|
23387
|
+
average: "Average",
|
|
23388
|
+
max: "Max",
|
|
23389
|
+
min: "Min",
|
|
23390
|
+
product: "Product",
|
|
23391
|
+
countNums: "Count",
|
|
23392
|
+
stdDev: "StdDev",
|
|
23393
|
+
stdDevp: "StdDevp",
|
|
23394
|
+
var: "Var",
|
|
23395
|
+
varp: "Varp"
|
|
23396
|
+
};
|
|
23397
|
+
var aggregateNames = () => Object.fromEntries(
|
|
23398
|
+
Object.keys(FUNCTIONS).map((fn) => [
|
|
23399
|
+
fn,
|
|
23400
|
+
`${fn[0].toUpperCase()}${fn.slice(1)} of {0}`
|
|
23401
|
+
])
|
|
23402
|
+
);
|
|
23403
|
+
var ENGLISH_PIVOT_CAPTIONS = {
|
|
23404
|
+
rowLabels: "Row Labels",
|
|
23405
|
+
columnLabels: "Column Labels",
|
|
23406
|
+
grandTotal: "Grand Total",
|
|
23407
|
+
values: "Values",
|
|
23408
|
+
all: "(All)",
|
|
23409
|
+
blank: "(blank)",
|
|
23410
|
+
subtotal: "{0} Total",
|
|
23411
|
+
measureTotal: "Total {0}",
|
|
23412
|
+
functions: FUNCTIONS,
|
|
23413
|
+
aggregates: aggregateNames()
|
|
23414
|
+
};
|
|
23415
|
+
var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
|
|
23416
|
+
function pivotCaptions(pivot) {
|
|
23417
|
+
const own2 = pivot.captions;
|
|
23418
|
+
if (!own2) return ENGLISH_PIVOT_CAPTIONS;
|
|
23419
|
+
return {
|
|
23420
|
+
...ENGLISH_PIVOT_CAPTIONS,
|
|
23421
|
+
...Object.fromEntries(Object.entries(own2).filter(([, value2]) => typeof value2 === "string")),
|
|
23422
|
+
functions: { ...ENGLISH_PIVOT_CAPTIONS.functions, ...own2.functions },
|
|
23423
|
+
aggregates: { ...ENGLISH_PIVOT_CAPTIONS.aggregates, ...own2.aggregates }
|
|
23424
|
+
};
|
|
23425
|
+
}
|
|
23426
|
+
var pivotMeasureName = (aggregate2, field2, pivot = {}) => fillCaption(pivotCaptions(pivot).aggregates[aggregate2], field2);
|
|
23427
|
+
function localizedPivotCaptions(locale) {
|
|
23428
|
+
const caps = LOCALIZED_PIVOT_CAPTIONS[normalizeOfficeLocale(locale)];
|
|
23429
|
+
return caps ? structuredClone(caps) : void 0;
|
|
23430
|
+
}
|
|
23431
|
+
function trimmedCaptions(caps) {
|
|
23432
|
+
const out = {};
|
|
23433
|
+
for (const key2 of [
|
|
23434
|
+
"rowLabels",
|
|
23435
|
+
"columnLabels",
|
|
23436
|
+
"grandTotal",
|
|
23437
|
+
"values",
|
|
23438
|
+
"all",
|
|
23439
|
+
"blank",
|
|
23440
|
+
"subtotal",
|
|
23441
|
+
"measureTotal"
|
|
23442
|
+
])
|
|
23443
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2]) out[key2] = caps[key2];
|
|
23444
|
+
for (const key2 of ["functions", "aggregates"]) {
|
|
23445
|
+
const changed = Object.keys(caps[key2]).filter(
|
|
23446
|
+
(fn) => caps[key2][fn] !== ENGLISH_PIVOT_CAPTIONS[key2][fn]
|
|
23447
|
+
);
|
|
23448
|
+
if (changed.length) out[key2] = Object.fromEntries(changed.map((fn) => [fn, caps[key2][fn]]));
|
|
23449
|
+
}
|
|
23450
|
+
return Object.keys(out).length ? out : void 0;
|
|
23451
|
+
}
|
|
23452
|
+
function authoredCaptions(options) {
|
|
23453
|
+
const own2 = options.captions ?? localizedPivotCaptions(options.locale);
|
|
23454
|
+
return own2 && Object.keys(own2).length ? structuredClone(own2) : void 0;
|
|
23455
|
+
}
|
|
23456
|
+
|
|
23233
23457
|
// xlsx/formula/date-serial.ts
|
|
23234
23458
|
var DAY_MS = 864e5;
|
|
23235
23459
|
var EPOCH_19002 = Date.UTC(1899, 11, 30);
|
|
@@ -23326,7 +23550,7 @@ var LEAP_MONTHS = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
|
23326
23550
|
var MAX_ITEMS = 1e4;
|
|
23327
23551
|
var pad3 = (value2, width = 2) => String(value2).padStart(width, "0");
|
|
23328
23552
|
var dateGroupUnits = (group) => PIVOT_DATE_UNITS.filter((unit3) => group.by.includes(unit3));
|
|
23329
|
-
var dateGroupFieldName = (unit3, field2) => `${UNIT_TITLES[unit3]} (${field2})`;
|
|
23553
|
+
var dateGroupFieldName = (unit3, field2, group) => group?.localized?.[unit3]?.name ?? `${UNIT_TITLES[unit3]} (${field2})`;
|
|
23330
23554
|
var dateGroupDays = (group) => group.by.length === 1 && group.by[0] === "days" ? group.days ?? 1 : 1;
|
|
23331
23555
|
function dateGroupRange(group, serials) {
|
|
23332
23556
|
let min = Infinity;
|
|
@@ -23349,7 +23573,7 @@ var secondsOfDay = (serial) => Math.round((serial - Math.floor(serial)) * 86400)
|
|
|
23349
23573
|
function dayBuckets(range2, days) {
|
|
23350
23574
|
return Math.max(1, Math.ceil((Math.floor(range2.end) - Math.floor(range2.start) + 1) / days));
|
|
23351
23575
|
}
|
|
23352
|
-
function
|
|
23576
|
+
function englishDateUnitLabels(unit3, range2, days, date1904) {
|
|
23353
23577
|
const labels = [`<${isoDay(range2.start, date1904)}`];
|
|
23354
23578
|
if (unit3 === "seconds" || unit3 === "minutes")
|
|
23355
23579
|
for (let i2 = 0; i2 < 60; i2++) labels.push(`:${pad3(i2)}`);
|
|
@@ -23378,6 +23602,11 @@ function dateUnitLabels(unit3, range2, days, date1904) {
|
|
|
23378
23602
|
labels.push(`>${isoDay(range2.end, date1904)}`);
|
|
23379
23603
|
return labels;
|
|
23380
23604
|
}
|
|
23605
|
+
function dateUnitLabels(unit3, range2, days, date1904, group) {
|
|
23606
|
+
const english = englishDateUnitLabels(unit3, range2, days, date1904);
|
|
23607
|
+
const localized = group?.localized?.[unit3]?.labels;
|
|
23608
|
+
return localized?.length === english.length ? localized : english;
|
|
23609
|
+
}
|
|
23381
23610
|
function dateUnitIndex(unit3, range2, days, date1904, serial, count2) {
|
|
23382
23611
|
if (serial < range2.start) return 0;
|
|
23383
23612
|
if (serial > range2.end) return count2 - 1;
|
|
@@ -23401,7 +23630,7 @@ function derivedDateFields(pivot) {
|
|
|
23401
23630
|
for (const group of pivot.dateGroups ?? [])
|
|
23402
23631
|
for (const unit3 of dateGroupUnits(group))
|
|
23403
23632
|
derived.push({
|
|
23404
|
-
name: dateGroupFieldName(unit3, group.field),
|
|
23633
|
+
name: dateGroupFieldName(unit3, group.field, group),
|
|
23405
23634
|
unit: unit3,
|
|
23406
23635
|
group,
|
|
23407
23636
|
index: databaseFields + derived.length
|
|
@@ -23412,7 +23641,7 @@ function countDerived(pivot) {
|
|
|
23412
23641
|
let count2 = 0;
|
|
23413
23642
|
for (const group of pivot.dateGroups ?? [])
|
|
23414
23643
|
for (const unit3 of dateGroupUnits(group))
|
|
23415
|
-
if (pivot.fields.includes(dateGroupFieldName(unit3, group.field))) count2++;
|
|
23644
|
+
if (pivot.fields.includes(dateGroupFieldName(unit3, group.field, group))) count2++;
|
|
23416
23645
|
return count2;
|
|
23417
23646
|
}
|
|
23418
23647
|
var pivotAxisFieldNames = (pivot) => [
|
|
@@ -23432,7 +23661,7 @@ function derivedDateLabels(pivot, name3) {
|
|
|
23432
23661
|
if (!entry3) return void 0;
|
|
23433
23662
|
const [group] = resolveDateGroups({ ...pivot, dateGroups: [entry3.group] });
|
|
23434
23663
|
const range2 = { start: group.start, end: group.end };
|
|
23435
|
-
return dateUnitLabels(entry3.unit, range2, dateGroupDays(group), pivot.date1904 ?? false);
|
|
23664
|
+
return dateUnitLabels(entry3.unit, range2, dateGroupDays(group), pivot.date1904 ?? false, group);
|
|
23436
23665
|
}
|
|
23437
23666
|
function validateDateGroups(pivot) {
|
|
23438
23667
|
const groups = pivot.dateGroups;
|
|
@@ -23448,18 +23677,16 @@ function validateDateGroups(pivot) {
|
|
|
23448
23677
|
seen.add(group.field);
|
|
23449
23678
|
if (!(pivot.dateFields ?? []).includes(group.field))
|
|
23450
23679
|
throw new Error("Only fields that contain dates can be grouped by date.");
|
|
23451
|
-
if (pivot.pageFilter || pivot.dateFilter)
|
|
23452
|
-
throw new Error("Date groups cannot be combined with report filters or timelines.");
|
|
23453
23680
|
const serials = pivot.records.map((record2) => record2[index3]);
|
|
23454
23681
|
if (!serials.length || serials.some((v) => typeof v !== "number" || !Number.isFinite(v)))
|
|
23455
23682
|
throw new Error("Only fields that contain dates can be grouped by date.");
|
|
23456
23683
|
const range2 = dateGroupRange(group, serials);
|
|
23457
23684
|
if (range2.start >= range2.end) throw new Error("The date group must end after it starts.");
|
|
23458
23685
|
for (const unit3 of dateGroupUnits(group)) {
|
|
23459
|
-
const name3 = dateGroupFieldName(unit3, group.field);
|
|
23686
|
+
const name3 = dateGroupFieldName(unit3, group.field, group);
|
|
23460
23687
|
if (pivot.fields.includes(name3))
|
|
23461
23688
|
throw new Error("A source field already has the name of a date group field.");
|
|
23462
|
-
if (dateUnitLabels(unit3, range2, dateGroupDays(group), pivot.date1904 ?? false).length > MAX_ITEMS)
|
|
23689
|
+
if (dateUnitLabels(unit3, range2, dateGroupDays(group), pivot.date1904 ?? false, group).length > MAX_ITEMS)
|
|
23463
23690
|
throw new Error("The date group has too many items.");
|
|
23464
23691
|
}
|
|
23465
23692
|
}
|
|
@@ -23473,7 +23700,7 @@ function expandDateGroups(pivot) {
|
|
|
23473
23700
|
const tables = derived.map((entry3) => {
|
|
23474
23701
|
const range2 = { start: entry3.group.start, end: entry3.group.end };
|
|
23475
23702
|
const days = dateGroupDays(entry3.group);
|
|
23476
|
-
const labels = dateUnitLabels(entry3.unit, range2, days, date1904);
|
|
23703
|
+
const labels = dateUnitLabels(entry3.unit, range2, days, date1904, entry3.group);
|
|
23477
23704
|
return {
|
|
23478
23705
|
base: pivot.fields.indexOf(entry3.group.field),
|
|
23479
23706
|
labels,
|
|
@@ -23485,9 +23712,9 @@ function expandDateGroups(pivot) {
|
|
|
23485
23712
|
fields: [...pivot.fields, ...derived.map((entry3) => entry3.name)],
|
|
23486
23713
|
records: pivot.records.map((record2) => [
|
|
23487
23714
|
...record2,
|
|
23488
|
-
...tables.map((
|
|
23489
|
-
const value2 = record2[
|
|
23490
|
-
return typeof value2 === "number" ?
|
|
23715
|
+
...tables.map((table4) => {
|
|
23716
|
+
const value2 = record2[table4.base];
|
|
23717
|
+
return typeof value2 === "number" ? table4.labels[table4.index(value2)] : null;
|
|
23491
23718
|
})
|
|
23492
23719
|
])
|
|
23493
23720
|
};
|
|
@@ -23606,15 +23833,13 @@ function normalizedFieldSubtotals(entries) {
|
|
|
23606
23833
|
};
|
|
23607
23834
|
});
|
|
23608
23835
|
}
|
|
23609
|
-
function validateFieldSubtotals(pivot,
|
|
23836
|
+
function validateFieldSubtotals(pivot, axisFields) {
|
|
23610
23837
|
const entries = pivot.fieldSubtotals;
|
|
23611
23838
|
if (entries === void 0) return;
|
|
23612
23839
|
if (!Array.isArray(entries)) throw new Error("Choose valid field subtotals.");
|
|
23613
|
-
if (entries.length && pivot.valuesAxis === "rows")
|
|
23614
|
-
throw new Error("Field subtotals require Values on columns.");
|
|
23615
23840
|
const seen = /* @__PURE__ */ new Set();
|
|
23616
23841
|
for (const entry3 of entries) {
|
|
23617
|
-
if (!entry3 || typeof entry3 !== "object" || !
|
|
23842
|
+
if (!entry3 || typeof entry3 !== "object" || !axisFields.includes(entry3.field) || seen.has(entry3.field) || !Array.isArray(entry3.functions) || entry3.functions.some((fn) => !PIVOT_AGGREGATES.includes(fn)) || new Set(entry3.functions).size !== entry3.functions.length)
|
|
23618
23843
|
throw new Error("Choose valid field subtotals.");
|
|
23619
23844
|
seen.add(entry3.field);
|
|
23620
23845
|
}
|
|
@@ -23693,6 +23918,17 @@ function pruneItemFilters(pivot) {
|
|
|
23693
23918
|
return next.length ? next : void 0;
|
|
23694
23919
|
}
|
|
23695
23920
|
|
|
23921
|
+
// xlsx/pivot/item-labels.ts
|
|
23922
|
+
var keyOf = (field2, item) => `${field2}\0${pivotValueKey(item)}`;
|
|
23923
|
+
function pivotItemLabeler(pivot) {
|
|
23924
|
+
const blank = pivotCaptions(pivot).blank;
|
|
23925
|
+
const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
|
|
23926
|
+
return (field2, value2) => names?.get(keyOf(field2, value2)) ?? (value2 === null || value2 === "" ? blank : pivotItemLabel(value2));
|
|
23927
|
+
}
|
|
23928
|
+
var pivotItemName = (pivot, field2, item) => pivot.itemNames?.find(
|
|
23929
|
+
(entry3) => entry3.field === field2 && pivotValueKey(entry3.item) === pivotValueKey(item)
|
|
23930
|
+
)?.name;
|
|
23931
|
+
|
|
23696
23932
|
// xlsx/pivot/page-filter.ts
|
|
23697
23933
|
function validatePivotPageFilter(pivot) {
|
|
23698
23934
|
const filter2 = pivot.pageFilter;
|
|
@@ -23704,23 +23940,24 @@ function validatePivotPageFilter(pivot) {
|
|
|
23704
23940
|
pivot.columnField,
|
|
23705
23941
|
pivot.valueField,
|
|
23706
23942
|
...extras.map((v) => v?.field)
|
|
23707
|
-
].includes(filter2.field)
|
|
23708
|
-
throw new Error("Report filters require
|
|
23943
|
+
].includes(filter2.field))
|
|
23944
|
+
throw new Error("Report filters require a separate source field.");
|
|
23709
23945
|
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))
|
|
23710
23946
|
throw new Error("Choose a cached literal report filter item.");
|
|
23711
23947
|
}
|
|
23712
23948
|
function pivotPageProjection(pivot) {
|
|
23713
|
-
|
|
23949
|
+
const groups = pivot.dateGroups?.length ? { ...pivot, dateGroups: resolveDateGroups(pivot) } : pivot;
|
|
23950
|
+
return applyPivotGroups(applyPivotItemFilters(pagedProjection(groups)));
|
|
23714
23951
|
}
|
|
23715
23952
|
function pagedProjection(pivot) {
|
|
23716
23953
|
const filter2 = pivot.pageFilter;
|
|
23717
23954
|
if (!filter2) return pivot;
|
|
23718
23955
|
const labels = /* @__PURE__ */ new Map();
|
|
23719
23956
|
for (const item of pivotItems(pivot, filter2.field)) {
|
|
23720
|
-
const
|
|
23721
|
-
if (
|
|
23957
|
+
const label2 = String(pivotItemLabel(item)).toLowerCase(), key3 = pivotValueKey(item);
|
|
23958
|
+
if (label2 === "(all)" || labels.has(label2) && labels.get(label2) !== key3)
|
|
23722
23959
|
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
23723
|
-
labels.set(
|
|
23960
|
+
labels.set(label2, key3);
|
|
23724
23961
|
}
|
|
23725
23962
|
if (filter2.item === void 0) return pivot;
|
|
23726
23963
|
const index3 = pivot.fields.indexOf(filter2.field), key2 = pivotValueKey(filter2.item);
|
|
@@ -23738,7 +23975,7 @@ function prependPivotPage(grid, pivot) {
|
|
|
23738
23975
|
values: [
|
|
23739
23976
|
[
|
|
23740
23977
|
pivot.pageFilter.field,
|
|
23741
|
-
pivot.pageFilter.item === void 0 ?
|
|
23978
|
+
pivot.pageFilter.item === void 0 ? pivotCaptions(pivot).all : pivotItemLabeler(pivot)(pivot.pageFilter.field, pivot.pageFilter.item),
|
|
23742
23979
|
...Array(width - 2).fill(null)
|
|
23743
23980
|
],
|
|
23744
23981
|
Array(width).fill(null),
|
|
@@ -23859,13 +24096,9 @@ function validatePivotFields(pivot) {
|
|
|
23859
24096
|
const columns = pivotColumnFields(pivot);
|
|
23860
24097
|
if (pivot.moreColumnFields !== void 0 && (!Array.isArray(pivot.moreColumnFields) || pivot.moreColumnFields.length > 0 && !pivot.columnField || pivot.moreColumnFields.length > 62 || pivot.moreColumnFields.some((name3) => typeof name3 !== "string")))
|
|
23861
24098
|
throw new Error("Choose valid PivotTable column fields.");
|
|
23862
|
-
if (pivot.valuesAxis === "rows" && rows.length > 2)
|
|
23863
|
-
throw new Error("Values on rows support at most two row fields.");
|
|
23864
|
-
if (pivot.valuesAxis === "rows" && columns.length > 1)
|
|
23865
|
-
throw new Error("Values on rows support one column field.");
|
|
23866
24099
|
if (pivot.pageFilter && columns.length > 1)
|
|
23867
24100
|
throw new Error("Report filters support one column field.");
|
|
23868
|
-
validateFieldSubtotals(pivot, rows);
|
|
24101
|
+
validateFieldSubtotals(pivot, [...rows, ...columns]);
|
|
23869
24102
|
const axisNames = pivotAxisFieldNames(pivot);
|
|
23870
24103
|
if ((pivot.dateGroups ?? []).some(
|
|
23871
24104
|
(group) => [...rows, ...columns].some((name3) => name3 === group.field)
|
|
@@ -23874,13 +24107,14 @@ function validatePivotFields(pivot) {
|
|
|
23874
24107
|
const extras = pivot.additionalValues ?? [];
|
|
23875
24108
|
if (pivot.valuesAxis !== void 0 && !["columns", "rows"].includes(pivot.valuesAxis))
|
|
23876
24109
|
throw new Error("Choose a valid Values axis.");
|
|
23877
|
-
|
|
24110
|
+
const position2 = pivot.valuesPosition;
|
|
24111
|
+
if (position2 !== void 0 && !["last", "between", "first"].includes(position2) && !(typeof position2 === "number" && Number.isInteger(position2) && position2 >= 0))
|
|
23878
24112
|
throw new Error("Choose a valid Values position.");
|
|
23879
|
-
if (
|
|
24113
|
+
if (position2 !== void 0 && position2 !== "last" && (pivot.valuesAxis !== "rows" || position2 === "between" && !pivot.secondRowField || typeof position2 === "number" && position2 > rows.length))
|
|
23880
24114
|
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
23881
24115
|
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
23882
24116
|
throw new Error("Values on rows require multiple measures.");
|
|
23883
|
-
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !==
|
|
24117
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
|
|
23884
24118
|
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
23885
24119
|
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
23886
24120
|
(measure2) => !measure2 || !pivot.fields.includes(measure2.field) || !PIVOT_AGGREGATES.includes(measure2.aggregate) || typeof measure2.caption !== "string" || !measure2.caption.trim() || measure2.caption.length > 255 || pivot.fields.some((field2) => field2.toLowerCase() === measure2.caption.toLowerCase())
|
|
@@ -23893,8 +24127,47 @@ function validatePivotFields(pivot) {
|
|
|
23893
24127
|
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) || !pivot.fields.includes(pivot.valueField) || [...rows, ...columns].some((field2) => !axisNames.includes(field2)) || (/* @__PURE__ */ new Set([...rows, ...columns])).size !== rows.length + columns.length || pivot.subtotals !== void 0 && typeof pivot.subtotals !== "boolean" || pivot.repeatLabels !== void 0 && typeof pivot.repeatLabels !== "boolean")
|
|
23894
24128
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
23895
24129
|
}
|
|
23896
|
-
function pivotCaption(aggregate2, field2) {
|
|
23897
|
-
return
|
|
24130
|
+
function pivotCaption(aggregate2, field2, pivot) {
|
|
24131
|
+
return pivotMeasureName(aggregate2, field2, pivot);
|
|
24132
|
+
}
|
|
24133
|
+
|
|
24134
|
+
// xlsx/write/xml-out.ts
|
|
24135
|
+
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
24136
|
+
var CONTROL2 = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
24137
|
+
var NEEDS_ESCAPE = new RegExp(`[${CONTROL2}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
24138
|
+
var ESCAPABLE = new RegExp(`[${CONTROL2}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
24139
|
+
function encodeEscapes(text8) {
|
|
24140
|
+
if (!NEEDS_ESCAPE.test(text8)) return text8;
|
|
24141
|
+
return text8.replace(
|
|
24142
|
+
ESCAPABLE,
|
|
24143
|
+
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
24144
|
+
);
|
|
24145
|
+
}
|
|
24146
|
+
var INVALID_XML2 = new RegExp(`[${CONTROL2}]`, "g");
|
|
24147
|
+
var escapeText3 = (text8) => text8.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
24148
|
+
var escapeAttr3 = (text8) => text8.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
24149
|
+
function attrs2(values2) {
|
|
24150
|
+
let out = "";
|
|
24151
|
+
for (const [name3, value2] of Object.entries(values2)) {
|
|
24152
|
+
if (value2 === void 0) continue;
|
|
24153
|
+
const text8 = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num(value2) : value2;
|
|
24154
|
+
out += ` ${name3}="${escapeAttr3(text8)}"`;
|
|
24155
|
+
}
|
|
24156
|
+
return out;
|
|
24157
|
+
}
|
|
24158
|
+
var el4 = (name3, values2 = {}, content2 = "") => content2 ? `<${name3}${attrs2(values2)}>${content2}</${name3}>` : `<${name3}${attrs2(values2)}/>`;
|
|
24159
|
+
var num = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
24160
|
+
function tElement(text8, name3 = "t") {
|
|
24161
|
+
const encoded = escapeText3(encodeEscapes(text8));
|
|
24162
|
+
const preserve = /^\s|\s$|\n|\t/.test(text8) ? ' xml:space="preserve"' : "";
|
|
24163
|
+
return `<${name3}${preserve}>${encoded}</${name3}>`;
|
|
24164
|
+
}
|
|
24165
|
+
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
24166
|
+
function inlineFragment(xml) {
|
|
24167
|
+
const end = xml.indexOf(">");
|
|
24168
|
+
if (end < 0) return xml;
|
|
24169
|
+
const head = xml.slice(0, end);
|
|
24170
|
+
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
23898
24171
|
}
|
|
23899
24172
|
|
|
23900
24173
|
// xlsx/pivot/measures.ts
|
|
@@ -23902,7 +24175,7 @@ var pivotMeasures = (pivot) => [
|
|
|
23902
24175
|
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
23903
24176
|
...pivot.additionalValues ?? []
|
|
23904
24177
|
];
|
|
23905
|
-
function normalizedPivotMeasures(values2) {
|
|
24178
|
+
function normalizedPivotMeasures(values2, pivot) {
|
|
23906
24179
|
if (!Array.isArray(values2) || values2.length > 15)
|
|
23907
24180
|
throw new Error("Choose between one and sixteen PivotTable value fields.");
|
|
23908
24181
|
return values2.map((value2) => {
|
|
@@ -23914,7 +24187,7 @@ function normalizedPivotMeasures(values2) {
|
|
|
23914
24187
|
return {
|
|
23915
24188
|
field: value2.field,
|
|
23916
24189
|
aggregate: aggregate2,
|
|
23917
|
-
caption: value2.caption ??
|
|
24190
|
+
caption: value2.caption ?? pivotMeasureName(aggregate2, value2.field, pivot)
|
|
23918
24191
|
};
|
|
23919
24192
|
});
|
|
23920
24193
|
}
|
|
@@ -23946,329 +24219,16 @@ function aggregateValues(records, field2, type) {
|
|
|
23946
24219
|
return type === "average" ? sum3 / numbers3.length : sum3;
|
|
23947
24220
|
}
|
|
23948
24221
|
var pivotMeasureNumber = (pivot, records, measure2) => aggregateValues(records, pivot.fields.indexOf(measure2.field), measure2.aggregate);
|
|
23949
|
-
var pivotNumbers = (pivot, records) => pivotMeasures(pivot).map((measure2) => pivotMeasureNumber(pivot, records, measure2));
|
|
23950
|
-
function pivotHeaderDimensions(pivot, columnItems, rowLabels) {
|
|
23951
|
-
return {
|
|
23952
|
-
rows: (pivot.columnField ? 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
23953
|
-
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
23954
|
-
};
|
|
23955
|
-
}
|
|
23956
|
-
function pivotHeaders(pivot, columns, labels, label5) {
|
|
23957
|
-
const rowLabels = pivot.layout === "compact" ? ["Row Labels"] : pivot.valuesPosition === "first" ? ["Values", ...labels] : pivot.valuesPosition === "between" ? [labels[0], "Values", labels[1]] : [...labels, "Values"];
|
|
23958
|
-
return pivot.columnField ? [
|
|
23959
|
-
[
|
|
23960
|
-
...rowLabels.map(() => null),
|
|
23961
|
-
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
23962
|
-
...columns.map(() => null)
|
|
23963
|
-
],
|
|
23964
|
-
[...rowLabels, ...columns.map(label5), "Grand Total"]
|
|
23965
|
-
] : [[...rowLabels, null]];
|
|
23966
|
-
}
|
|
23967
|
-
|
|
23968
|
-
// xlsx/pivot/hierarchy-first.ts
|
|
23969
|
-
function appendFirstPivotValues(pivot, context) {
|
|
23970
|
-
const {
|
|
23971
|
-
rowItems,
|
|
23972
|
-
secondRowItems,
|
|
23973
|
-
columnItems,
|
|
23974
|
-
children: children4,
|
|
23975
|
-
innerIndices,
|
|
23976
|
-
groups,
|
|
23977
|
-
details,
|
|
23978
|
-
buckets,
|
|
23979
|
-
width,
|
|
23980
|
-
rowLabels,
|
|
23981
|
-
top,
|
|
23982
|
-
bottom,
|
|
23983
|
-
append
|
|
23984
|
-
} = context;
|
|
23985
|
-
const compact3 = pivot.layout === "compact";
|
|
23986
|
-
const tabular = !pivot.layout || pivot.layout === "tabular";
|
|
23987
|
-
const blank = () => Array(width - rowLabels).fill(null);
|
|
23988
|
-
pivotMeasures(pivot).forEach((measure2, m) => {
|
|
23989
|
-
const numbers3 = (keys, records) => [
|
|
23990
|
-
...columnItems.map(
|
|
23991
|
-
(column2) => pivotMeasureNumber(
|
|
23992
|
-
pivot,
|
|
23993
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column2)])) ?? [],
|
|
23994
|
-
measure2
|
|
23995
|
-
)
|
|
23996
|
-
),
|
|
23997
|
-
pivotMeasureNumber(pivot, records, measure2)
|
|
23998
|
-
];
|
|
23999
|
-
if (!tabular)
|
|
24000
|
-
append([measure2.caption, ...Array(rowLabels - 1).fill(null)], blank(), {
|
|
24001
|
-
indices: [m],
|
|
24002
|
-
measure: m
|
|
24003
|
-
});
|
|
24004
|
-
let first3 = true;
|
|
24005
|
-
rowItems.forEach((outer, outerIndex) => {
|
|
24006
|
-
const key2 = pivotValueKey(outer);
|
|
24007
|
-
const group = groups.get(key2) ?? [];
|
|
24008
|
-
if (!tabular)
|
|
24009
|
-
append(
|
|
24010
|
-
compact3 ? [pivotItemLabel(outer)] : [null, pivotItemLabel(outer), null],
|
|
24011
|
-
top ? numbers3([key2], group) : blank(),
|
|
24012
|
-
{ indices: [m, outerIndex], measure: m },
|
|
24013
|
-
compact3 ? 1 : 0
|
|
24014
|
-
);
|
|
24015
|
-
const innerKeys = [...children4.get(key2)].sort(
|
|
24016
|
-
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
24017
|
-
);
|
|
24018
|
-
innerKeys.forEach((innerKey, child7) => {
|
|
24019
|
-
const innerIndex = innerIndices.get(innerKey);
|
|
24020
|
-
append(
|
|
24021
|
-
compact3 ? [pivotItemLabel(secondRowItems[innerIndex])] : [
|
|
24022
|
-
tabular && first3 ? measure2.caption : null,
|
|
24023
|
-
pivot.repeatLabels || tabular && child7 === 0 ? pivotItemLabel(outer) : null,
|
|
24024
|
-
pivotItemLabel(secondRowItems[innerIndex])
|
|
24025
|
-
],
|
|
24026
|
-
numbers3([key2, innerKey], details.get(JSON.stringify([key2, innerKey]))),
|
|
24027
|
-
{ indices: [m, outerIndex, innerIndex], measure: m },
|
|
24028
|
-
compact3 ? 2 : 0
|
|
24029
|
-
);
|
|
24030
|
-
first3 = false;
|
|
24031
|
-
});
|
|
24032
|
-
if (bottom)
|
|
24033
|
-
append(
|
|
24034
|
-
compact3 ? [`${String(pivotItemLabel(outer))} Total`] : [null, `${String(pivotItemLabel(outer))} Total`, null],
|
|
24035
|
-
numbers3([key2], group),
|
|
24036
|
-
{ indices: [m, outerIndex], measure: m, type: "default" },
|
|
24037
|
-
compact3 ? 1 : 0
|
|
24038
|
-
);
|
|
24039
|
-
});
|
|
24040
|
-
});
|
|
24041
|
-
}
|
|
24042
|
-
|
|
24043
|
-
// xlsx/pivot/hierarchy.ts
|
|
24044
|
-
var label = pivotItemLabel;
|
|
24045
|
-
function hierarchicalPivotGrid(pivot) {
|
|
24046
|
-
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
24047
|
-
const secondRowItems = pivotItems(pivot, pivot.secondRowField);
|
|
24048
|
-
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
24049
|
-
const outerField = pivot.fields.indexOf(pivot.rowField);
|
|
24050
|
-
const innerField = pivot.fields.indexOf(pivot.secondRowField);
|
|
24051
|
-
const columnField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
24052
|
-
const layout3 = pivot.layout ?? "tabular";
|
|
24053
|
-
const compact3 = layout3 === "compact";
|
|
24054
|
-
const firstValues = pivot.valuesPosition === "first";
|
|
24055
|
-
const between = pivot.valuesPosition === "between";
|
|
24056
|
-
const measures2 = pivotMeasures(pivot);
|
|
24057
|
-
const top = firstValues && layout3 !== "tabular" && pivot.subtotals !== false && (pivot.subtotalPosition ?? "top") === "top";
|
|
24058
|
-
const bottom = pivot.subtotals !== false && !top;
|
|
24059
|
-
const rowLabelColumns = compact3 ? 1 : 3;
|
|
24060
|
-
const groups = /* @__PURE__ */ new Map();
|
|
24061
|
-
const details = /* @__PURE__ */ new Map();
|
|
24062
|
-
const children4 = /* @__PURE__ */ new Map();
|
|
24063
|
-
const innerIndices = new Map(secondRowItems.map((item, index3) => [pivotValueKey(item), index3]));
|
|
24064
|
-
const buckets = /* @__PURE__ */ new Map();
|
|
24065
|
-
const collect = (map, key2, record2) => {
|
|
24066
|
-
const list2 = map.get(key2);
|
|
24067
|
-
if (list2) list2.push(record2);
|
|
24068
|
-
else map.set(key2, [record2]);
|
|
24069
|
-
};
|
|
24070
|
-
for (const record2 of pivot.records) {
|
|
24071
|
-
const outer = pivotValueKey(record2[outerField] ?? null);
|
|
24072
|
-
const inner2 = pivotValueKey(record2[innerField] ?? null);
|
|
24073
|
-
collect(groups, outer, record2);
|
|
24074
|
-
collect(details, JSON.stringify([outer, inner2]), record2);
|
|
24075
|
-
if (!children4.has(outer)) children4.set(outer, /* @__PURE__ */ new Set());
|
|
24076
|
-
children4.get(outer).add(inner2);
|
|
24077
|
-
if (pivot.columnField) {
|
|
24078
|
-
const column2 = pivotValueKey(record2[columnField] ?? null);
|
|
24079
|
-
for (const key2 of [[], [outer], [outer, inner2]])
|
|
24080
|
-
collect(buckets, JSON.stringify([...key2, column2]), record2);
|
|
24081
|
-
}
|
|
24082
|
-
}
|
|
24083
|
-
const dimensions3 = pivotHeaderDimensions(pivot, columnItems.length, rowLabelColumns);
|
|
24084
|
-
const rows = (details.size + rowItems.length * Number(bottom) + 1) * measures2.length + rowItems.length * Number(layout3 !== "tabular") * (firstValues ? measures2.length : 1) + (firstValues ? measures2.length : between ? rowItems.length * measures2.length : details.size) * Number(layout3 !== "tabular") + dimensions3.rows;
|
|
24085
|
-
if (rows * dimensions3.width > 1e6) throw new Error("The PivotTable result is too large.");
|
|
24086
|
-
const labels = compact3 ? ["Row Labels"] : [pivot.rowField, pivot.secondRowField];
|
|
24087
|
-
const values2 = pivotHeaders(pivot, columnItems, labels, label);
|
|
24088
|
-
const firstDataRow = values2.length;
|
|
24089
|
-
const indents = values2.map(() => 0);
|
|
24090
|
-
const rowEntries = [];
|
|
24091
|
-
const append = (labels2, numbers4, entry3, indent = 0) => {
|
|
24092
|
-
values2.push([...labels2, ...numbers4]);
|
|
24093
|
-
rowEntries.push(entry3);
|
|
24094
|
-
indents.push(indent);
|
|
24095
|
-
};
|
|
24096
|
-
const bands = (keys, records) => [
|
|
24097
|
-
...columnItems.map(
|
|
24098
|
-
(column2) => pivotNumbers(pivot, buckets.get(JSON.stringify([...keys, pivotValueKey(column2)])) ?? [])
|
|
24099
|
-
),
|
|
24100
|
-
pivotNumbers(pivot, records)
|
|
24101
|
-
];
|
|
24102
|
-
const numbers3 = (keys, records) => bands(keys, records).flat();
|
|
24103
|
-
const appendMeasures = (labels2, keys, records, indices, type) => {
|
|
24104
|
-
const values3 = bands(keys, records);
|
|
24105
|
-
measures2.forEach(
|
|
24106
|
-
(measure2, m) => append(
|
|
24107
|
-
type ? [
|
|
24108
|
-
`${type === "grand" ? "Total" : String(labels2[0])} ${measure2.caption}`,
|
|
24109
|
-
...Array(rowLabelColumns - 1).fill(null)
|
|
24110
|
-
] : compact3 ? [measure2.caption] : [
|
|
24111
|
-
...labels2.map(
|
|
24112
|
-
(label5) => layout3 === "tabular" && m === 0 || pivot.repeatLabels ? label5 : null
|
|
24113
|
-
),
|
|
24114
|
-
measure2.caption
|
|
24115
|
-
],
|
|
24116
|
-
values3.map((band2) => band2[m] ?? null),
|
|
24117
|
-
{ indices: type ? indices : [...indices, m], measure: m, ...type ? { type } : {} },
|
|
24118
|
-
compact3 && !type ? 2 : 0
|
|
24119
|
-
)
|
|
24120
|
-
);
|
|
24121
|
-
};
|
|
24122
|
-
if (firstValues)
|
|
24123
|
-
appendFirstPivotValues(pivot, {
|
|
24124
|
-
rowItems,
|
|
24125
|
-
secondRowItems,
|
|
24126
|
-
columnItems,
|
|
24127
|
-
children: children4,
|
|
24128
|
-
innerIndices,
|
|
24129
|
-
groups,
|
|
24130
|
-
details,
|
|
24131
|
-
buckets,
|
|
24132
|
-
width: dimensions3.width,
|
|
24133
|
-
rowLabels: rowLabelColumns,
|
|
24134
|
-
top,
|
|
24135
|
-
bottom,
|
|
24136
|
-
append
|
|
24137
|
-
});
|
|
24138
|
-
else
|
|
24139
|
-
rowItems.forEach((outer, outerIndex) => {
|
|
24140
|
-
const key2 = pivotValueKey(outer);
|
|
24141
|
-
if (layout3 !== "tabular")
|
|
24142
|
-
append(
|
|
24143
|
-
[label(outer), ...Array(rowLabelColumns - 1).fill(null)],
|
|
24144
|
-
top ? numbers3([key2], groups.get(key2) ?? []) : Array(dimensions3.width - rowLabelColumns).fill(null),
|
|
24145
|
-
{ indices: [outerIndex] }
|
|
24146
|
-
);
|
|
24147
|
-
let first3 = true;
|
|
24148
|
-
const innerKeys = [...children4.get(key2)].sort(
|
|
24149
|
-
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
24150
|
-
);
|
|
24151
|
-
if (between)
|
|
24152
|
-
measures2.forEach((measure2, m) => {
|
|
24153
|
-
if (layout3 !== "tabular")
|
|
24154
|
-
append(
|
|
24155
|
-
compact3 ? [measure2.caption] : [pivot.repeatLabels ? label(outer) : null, measure2.caption, null],
|
|
24156
|
-
Array(dimensions3.width - rowLabelColumns).fill(null),
|
|
24157
|
-
{ indices: [outerIndex, m], measure: m },
|
|
24158
|
-
compact3 ? 1 : 0
|
|
24159
|
-
);
|
|
24160
|
-
innerKeys.forEach((innerKey, child7) => {
|
|
24161
|
-
const innerIndex = innerIndices.get(innerKey);
|
|
24162
|
-
const keys = [key2, innerKey];
|
|
24163
|
-
const records = details.get(JSON.stringify(keys));
|
|
24164
|
-
append(
|
|
24165
|
-
compact3 ? [label(secondRowItems[innerIndex])] : [
|
|
24166
|
-
pivot.repeatLabels || layout3 === "tabular" && m === 0 && child7 === 0 ? label(outer) : null,
|
|
24167
|
-
layout3 === "tabular" && child7 === 0 ? measure2.caption : null,
|
|
24168
|
-
label(secondRowItems[innerIndex])
|
|
24169
|
-
],
|
|
24170
|
-
[
|
|
24171
|
-
...columnItems.map(
|
|
24172
|
-
(column2) => pivotMeasureNumber(
|
|
24173
|
-
pivot,
|
|
24174
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column2)])) ?? [],
|
|
24175
|
-
measure2
|
|
24176
|
-
)
|
|
24177
|
-
),
|
|
24178
|
-
pivotMeasureNumber(pivot, records, measure2)
|
|
24179
|
-
],
|
|
24180
|
-
{ indices: [outerIndex, m, innerIndex], measure: m },
|
|
24181
|
-
compact3 ? 2 : 0
|
|
24182
|
-
);
|
|
24183
|
-
});
|
|
24184
|
-
});
|
|
24185
|
-
else
|
|
24186
|
-
innerKeys.forEach((innerKey) => {
|
|
24187
|
-
const innerIndex = innerIndices.get(innerKey);
|
|
24188
|
-
const inner2 = secondRowItems[innerIndex];
|
|
24189
|
-
const keys = [key2, innerKey];
|
|
24190
|
-
const records = details.get(JSON.stringify(keys));
|
|
24191
|
-
if (!records) return;
|
|
24192
|
-
if (layout3 !== "tabular")
|
|
24193
|
-
append(
|
|
24194
|
-
compact3 ? [label(inner2)] : [pivot.repeatLabels ? label(outer) : null, label(inner2), null],
|
|
24195
|
-
Array(dimensions3.width - rowLabelColumns).fill(null),
|
|
24196
|
-
{ indices: [outerIndex, innerIndex] },
|
|
24197
|
-
compact3 ? 1 : 0
|
|
24198
|
-
);
|
|
24199
|
-
appendMeasures(
|
|
24200
|
-
[pivot.repeatLabels || first3 ? label(outer) : null, label(inner2)],
|
|
24201
|
-
keys,
|
|
24202
|
-
records,
|
|
24203
|
-
[outerIndex, innerIndex]
|
|
24204
|
-
);
|
|
24205
|
-
first3 = false;
|
|
24206
|
-
});
|
|
24207
|
-
if (bottom)
|
|
24208
|
-
appendMeasures([label(outer)], [key2], groups.get(key2) ?? [], [outerIndex], "default");
|
|
24209
|
-
});
|
|
24210
|
-
appendMeasures([], [], pivot.records, [0], "grand");
|
|
24211
|
-
return {
|
|
24212
|
-
values: values2,
|
|
24213
|
-
rowItems,
|
|
24214
|
-
secondRowItems,
|
|
24215
|
-
columnItems,
|
|
24216
|
-
rowEntries,
|
|
24217
|
-
firstDataRow,
|
|
24218
|
-
rowLabelColumns,
|
|
24219
|
-
indents,
|
|
24220
|
-
firstHeaderRow: 1
|
|
24221
|
-
};
|
|
24222
|
-
}
|
|
24223
|
-
|
|
24224
|
-
// xlsx/write/xml-out.ts
|
|
24225
|
-
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
24226
|
-
var CONTROL2 = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
24227
|
-
var NEEDS_ESCAPE = new RegExp(`[${CONTROL2}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
24228
|
-
var ESCAPABLE = new RegExp(`[${CONTROL2}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
24229
|
-
function encodeEscapes(text8) {
|
|
24230
|
-
if (!NEEDS_ESCAPE.test(text8)) return text8;
|
|
24231
|
-
return text8.replace(
|
|
24232
|
-
ESCAPABLE,
|
|
24233
|
-
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
24234
|
-
);
|
|
24235
|
-
}
|
|
24236
|
-
var INVALID_XML2 = new RegExp(`[${CONTROL2}]`, "g");
|
|
24237
|
-
var escapeText3 = (text8) => text8.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
24238
|
-
var escapeAttr3 = (text8) => text8.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
24239
|
-
function attrs2(values2) {
|
|
24240
|
-
let out = "";
|
|
24241
|
-
for (const [name3, value2] of Object.entries(values2)) {
|
|
24242
|
-
if (value2 === void 0) continue;
|
|
24243
|
-
const text8 = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num(value2) : value2;
|
|
24244
|
-
out += ` ${name3}="${escapeAttr3(text8)}"`;
|
|
24245
|
-
}
|
|
24246
|
-
return out;
|
|
24247
|
-
}
|
|
24248
|
-
var el4 = (name3, values2 = {}, content2 = "") => content2 ? `<${name3}${attrs2(values2)}>${content2}</${name3}>` : `<${name3}${attrs2(values2)}/>`;
|
|
24249
|
-
var num = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
24250
|
-
function tElement(text8, name3 = "t") {
|
|
24251
|
-
const encoded = escapeText3(encodeEscapes(text8));
|
|
24252
|
-
const preserve = /^\s|\s$|\n|\t/.test(text8) ? ' xml:space="preserve"' : "";
|
|
24253
|
-
return `<${name3}${preserve}>${encoded}</${name3}>`;
|
|
24254
|
-
}
|
|
24255
|
-
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
24256
|
-
function inlineFragment(xml) {
|
|
24257
|
-
const end = xml.indexOf(">");
|
|
24258
|
-
if (end < 0) return xml;
|
|
24259
|
-
const head = xml.slice(0, end);
|
|
24260
|
-
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
24261
|
-
}
|
|
24262
24222
|
|
|
24263
24223
|
// xlsx/pivot/columns.ts
|
|
24264
24224
|
var SEPARATOR = "";
|
|
24265
|
-
var label2 = pivotItemLabel;
|
|
24266
24225
|
var columnKey = (keys, depth) => keys.slice(0, depth).join(SEPARATOR);
|
|
24267
24226
|
var recordColumnKeys = (record2, indices) => indices.map((index3) => pivotValueKey(record2[index3] ?? null));
|
|
24268
24227
|
function pivotColumnEntries(pivot) {
|
|
24269
24228
|
const names = pivotColumnFields(pivot);
|
|
24270
24229
|
const items = names.map((name3) => pivotItems(pivot, name3));
|
|
24271
24230
|
const entries = [];
|
|
24231
|
+
const functions = names.map((name3) => fieldSubtotalFunctions(pivot, name3));
|
|
24272
24232
|
if (names.length) {
|
|
24273
24233
|
const order = items.map(
|
|
24274
24234
|
(list2) => new Map(list2.map((item, index3) => [pivotValueKey(item), index3]))
|
|
@@ -24303,7 +24263,9 @@ function pivotColumnEntries(pivot) {
|
|
|
24303
24263
|
if (level === names.length - 1) entries.push({ kind: "leaf", ...entry3 });
|
|
24304
24264
|
else {
|
|
24305
24265
|
visit2(child7[1], level + 1, here.path, here.values, here.keys);
|
|
24306
|
-
|
|
24266
|
+
const own2 = functions[level];
|
|
24267
|
+
if (own2 === "auto") entries.push({ kind: "subtotal", ...entry3 });
|
|
24268
|
+
else for (const fn of own2) entries.push({ kind: "subtotal", ...entry3, fn });
|
|
24307
24269
|
}
|
|
24308
24270
|
}
|
|
24309
24271
|
};
|
|
@@ -24312,26 +24274,31 @@ function pivotColumnEntries(pivot) {
|
|
|
24312
24274
|
entries.push({ kind: "grand", path: [], key: "", values: [] });
|
|
24313
24275
|
return { names, items, entries };
|
|
24314
24276
|
}
|
|
24315
|
-
function pivotColumnDimensions(pivot, columns, labelColumns) {
|
|
24316
|
-
const measures2 = 1 + (pivot.additionalValues?.length ?? 0);
|
|
24277
|
+
function pivotColumnDimensions(pivot, columns, labelColumns, valuesOnRows = false) {
|
|
24278
|
+
const measures2 = valuesOnRows ? 1 : 1 + (pivot.additionalValues?.length ?? 0);
|
|
24317
24279
|
const levels = columns.names.length;
|
|
24318
24280
|
return {
|
|
24319
24281
|
rows: (levels ? levels + 1 + Number(measures2 > 1) : 1) + (pivot.pageFilter ? 2 : 0),
|
|
24320
24282
|
width: labelColumns + (levels ? columns.entries.length : 1) * measures2
|
|
24321
24283
|
};
|
|
24322
24284
|
}
|
|
24323
|
-
function pivotColumnHeaders(pivot, columns, rowLabels) {
|
|
24324
|
-
const measures2 = pivotMeasures(pivot);
|
|
24285
|
+
function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
24286
|
+
const measures2 = valuesOnRows ? pivotMeasures(pivot).slice(0, 1) : pivotMeasures(pivot);
|
|
24325
24287
|
const count2 = measures2.length;
|
|
24326
24288
|
const levels = columns.names.length;
|
|
24327
|
-
if (!levels)
|
|
24289
|
+
if (!levels)
|
|
24290
|
+
return [
|
|
24291
|
+
[...rowLabels, ...valuesOnRows ? [null] : measures2.map((measure2) => measure2.caption)]
|
|
24292
|
+
];
|
|
24328
24293
|
const compact3 = pivot.layout === "compact";
|
|
24329
24294
|
const labelColumns = rowLabels.length;
|
|
24330
24295
|
const width = labelColumns + columns.entries.length * count2;
|
|
24331
24296
|
const rows = levels + 1 + Number(count2 > 1);
|
|
24332
24297
|
const grid = Array.from({ length: rows }, () => Array(width).fill(null));
|
|
24333
|
-
if (count2 === 1) grid[0][0] = pivot.valueCaption;
|
|
24334
|
-
const
|
|
24298
|
+
if (count2 === 1 && !valuesOnRows) grid[0][0] = pivot.valueCaption;
|
|
24299
|
+
const caps = pivotCaptions(pivot);
|
|
24300
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24301
|
+
const titles = compact3 ? [caps.columnLabels] : [...columns.names, ...count2 > 1 ? [caps.values] : []];
|
|
24335
24302
|
titles.forEach((title, i2) => {
|
|
24336
24303
|
grid[0][labelColumns + i2] = title;
|
|
24337
24304
|
});
|
|
@@ -24344,16 +24311,17 @@ function pivotColumnHeaders(pivot, columns, rowLabels) {
|
|
|
24344
24311
|
if (entry3.kind === "leaf") {
|
|
24345
24312
|
entry3.path.forEach((_index, level) => {
|
|
24346
24313
|
const continued = entry3.path.slice(0, level + 1).every((p, i2) => p === previous[i2]);
|
|
24347
|
-
if (!continued) grid[1 + level][at2] =
|
|
24314
|
+
if (!continued) grid[1 + level][at2] = labelOf(columns.names[level], entry3.values[level]);
|
|
24348
24315
|
});
|
|
24349
24316
|
previous = entry3.path;
|
|
24350
24317
|
if (count2 > 1) measures2.forEach((measure2, m) => grid[rows - 1][at2 + m] = measure2.caption);
|
|
24351
24318
|
return;
|
|
24352
24319
|
}
|
|
24353
24320
|
const row3 = entry3.kind === "grand" ? 1 : entry3.path.length;
|
|
24354
|
-
const name3 = entry3.kind === "grand" ? "" : String(
|
|
24321
|
+
const name3 = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
|
|
24355
24322
|
measures2.forEach((measure2, m) => {
|
|
24356
|
-
|
|
24323
|
+
const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
|
|
24324
|
+
grid[row3][at2 + m] = custom ? count2 === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure2.field}` : count2 === 1 ? entry3.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name3) : entry3.kind === "grand" ? fillCaption(caps.measureTotal, measure2.caption) : `${name3} ${measure2.caption}`;
|
|
24357
24325
|
});
|
|
24358
24326
|
});
|
|
24359
24327
|
return grid;
|
|
@@ -24378,7 +24346,7 @@ function pivotColumnItemsXml(entries, measures2, remap) {
|
|
|
24378
24346
|
const prefix3 = sharedPrefix(path2, previous);
|
|
24379
24347
|
const xs = path2.slice(prefix3).map((index3) => `<x${attrs2({ v: index3 || void 0 })}/>`);
|
|
24380
24348
|
out.push(
|
|
24381
|
-
`<i${attrs2({ t: entry3.kind === "subtotal" ? "default" : void 0, r: prefix3 || void 0, i: m || void 0 })}>${xs.join("")}</i>`
|
|
24349
|
+
`<i${attrs2({ t: entry3.kind === "subtotal" ? entry3.fn ? PIVOT_SUBTOTALS[entry3.fn].item : "default" : void 0, r: prefix3 || void 0, i: m || void 0 })}>${xs.join("")}</i>`
|
|
24382
24350
|
);
|
|
24383
24351
|
previous = path2;
|
|
24384
24352
|
}
|
|
@@ -24386,7 +24354,6 @@ function pivotColumnItemsXml(entries, measures2, remap) {
|
|
|
24386
24354
|
}
|
|
24387
24355
|
|
|
24388
24356
|
// xlsx/pivot/nested.ts
|
|
24389
|
-
var label3 = pivotItemLabel;
|
|
24390
24357
|
var MAX_CELLS = 1e6;
|
|
24391
24358
|
var node = (index3, value2) => ({
|
|
24392
24359
|
index: index3,
|
|
@@ -24398,6 +24365,10 @@ var node = (index3, value2) => ({
|
|
|
24398
24365
|
function nestedPivotGrid(pivot) {
|
|
24399
24366
|
const names = pivotRowFields(pivot);
|
|
24400
24367
|
const depth = names.length;
|
|
24368
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
24369
|
+
const onRows = valuesAt >= 0;
|
|
24370
|
+
const levels = depth + (onRows ? 1 : 0);
|
|
24371
|
+
const fieldOf = (level) => !onRows || level < valuesAt ? level : level === valuesAt ? -1 : level - 1;
|
|
24401
24372
|
const axisItems = names.map((name3) => pivotItems(pivot, name3));
|
|
24402
24373
|
const itemIndices = axisItems.map(
|
|
24403
24374
|
(items) => new Map(items.map((item, index3) => [pivotValueKey(item), index3]))
|
|
@@ -24409,125 +24380,170 @@ function nestedPivotGrid(pivot) {
|
|
|
24409
24380
|
const compact3 = layout3 === "compact";
|
|
24410
24381
|
const tabular = layout3 === "tabular";
|
|
24411
24382
|
const above = !tabular && (pivot.subtotalPosition ?? "top") === "top";
|
|
24412
|
-
const labelColumns = compact3 ? 1 :
|
|
24383
|
+
const labelColumns = compact3 ? 1 : levels;
|
|
24413
24384
|
const measures2 = pivotMeasures(pivot);
|
|
24385
|
+
const functions = names.map((name3) => fieldSubtotalFunctions(pivot, name3));
|
|
24386
|
+
const caps = pivotCaptions(pivot);
|
|
24387
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24414
24388
|
const root = node(0, null);
|
|
24415
24389
|
for (const record2 of pivot.records) {
|
|
24416
24390
|
const keys = recordColumnKeys(record2, columnFields);
|
|
24417
24391
|
let current = root;
|
|
24418
|
-
for (let
|
|
24419
|
-
if (
|
|
24420
|
-
const value2 = record2[fieldIndices[
|
|
24392
|
+
for (let field2 = -1; field2 < depth; field2++) {
|
|
24393
|
+
if (field2 >= 0) {
|
|
24394
|
+
const value2 = record2[fieldIndices[field2]] ?? null;
|
|
24421
24395
|
const key2 = pivotValueKey(value2);
|
|
24422
24396
|
let child7 = current.children.get(key2);
|
|
24423
24397
|
if (!child7) {
|
|
24424
|
-
child7 = node(itemIndices[
|
|
24398
|
+
child7 = node(itemIndices[field2].get(key2), value2);
|
|
24425
24399
|
current.children.set(key2, child7);
|
|
24426
24400
|
}
|
|
24427
24401
|
current = child7;
|
|
24428
24402
|
}
|
|
24429
24403
|
current.records.push(record2);
|
|
24430
|
-
for (let
|
|
24431
|
-
const key2 = columnKey(keys,
|
|
24404
|
+
for (let width2 = 1; width2 <= keys.length; width2++) {
|
|
24405
|
+
const key2 = columnKey(keys, width2);
|
|
24432
24406
|
const list2 = current.columns.get(key2);
|
|
24433
24407
|
if (list2) list2.push(record2);
|
|
24434
24408
|
else current.columns.set(key2, [record2]);
|
|
24435
24409
|
}
|
|
24436
24410
|
}
|
|
24437
24411
|
}
|
|
24438
|
-
const dimensions3 = pivotColumnDimensions(pivot, columns, labelColumns);
|
|
24439
|
-
const
|
|
24440
|
-
|
|
24441
|
-
|
|
24442
|
-
|
|
24443
|
-
rows++;
|
|
24444
|
-
if (level < depth - 1) {
|
|
24445
|
-
const f6 = functions[level];
|
|
24446
|
-
rows += f6 === "auto" ? 1 : f6.length;
|
|
24447
|
-
count2(child7, level + 1);
|
|
24448
|
-
}
|
|
24449
|
-
}
|
|
24450
|
-
};
|
|
24451
|
-
count2(root, 0);
|
|
24452
|
-
if ((rows + dimensions3.rows) * dimensions3.width > MAX_CELLS)
|
|
24453
|
-
throw new Error("The PivotTable result is too large.");
|
|
24454
|
-
const values2 = pivotColumnHeaders(pivot, columns, compact3 ? ["Row Labels"] : names);
|
|
24455
|
-
const firstDataRow = values2.length;
|
|
24456
|
-
const indents = values2.map(() => 0);
|
|
24412
|
+
const dimensions3 = pivotColumnDimensions(pivot, columns, labelColumns, onRows);
|
|
24413
|
+
const rowTitles = names.map((name3) => name3);
|
|
24414
|
+
if (onRows) rowTitles.splice(valuesAt, 0, caps.values);
|
|
24415
|
+
let values2 = [];
|
|
24416
|
+
let indents = [];
|
|
24457
24417
|
const rowEntries = [];
|
|
24458
|
-
|
|
24459
|
-
|
|
24460
|
-
|
|
24461
|
-
);
|
|
24462
|
-
const
|
|
24463
|
-
|
|
24464
|
-
|
|
24465
|
-
(
|
|
24466
|
-
|
|
24467
|
-
|
|
24418
|
+
let counting = true;
|
|
24419
|
+
let rowCount = 0;
|
|
24420
|
+
const width = dimensions3.width - labelColumns;
|
|
24421
|
+
const blanks = () => Array(width).fill(null);
|
|
24422
|
+
const cells3 = (group, rowFn, measure2) => columns.entries.flatMap((entry3) => {
|
|
24423
|
+
const records = entry3.kind === "grand" ? group.records : group.columns.get(entry3.key) ?? [];
|
|
24424
|
+
const picked = measure2 === void 0 ? measures2 : [measures2[measure2]];
|
|
24425
|
+
if (rowFn && entry3.fn && rowFn !== entry3.fn) return picked.map(() => null);
|
|
24426
|
+
const fn = rowFn ?? entry3.fn;
|
|
24427
|
+
return picked.map(
|
|
24428
|
+
(one2) => fn ? aggregateValues(records, pivot.fields.indexOf(one2.field), fn) : pivotMeasureNumber(pivot, records, one2)
|
|
24429
|
+
);
|
|
24430
|
+
});
|
|
24431
|
+
const labelCells = (path2, shown, level, text8) => {
|
|
24468
24432
|
if (compact3) return [text8];
|
|
24469
|
-
const
|
|
24470
|
-
path2.forEach((value2,
|
|
24471
|
-
if (shown[
|
|
24433
|
+
const row3 = Array(levels).fill(null);
|
|
24434
|
+
path2.labels.forEach((value2, at2) => {
|
|
24435
|
+
if (shown[at2]) row3[at2] = value2;
|
|
24472
24436
|
});
|
|
24473
|
-
|
|
24474
|
-
return
|
|
24437
|
+
row3[level] = text8;
|
|
24438
|
+
return row3;
|
|
24475
24439
|
};
|
|
24476
|
-
const push3 = (
|
|
24477
|
-
|
|
24440
|
+
const push3 = (indent, build3) => {
|
|
24441
|
+
if (counting) {
|
|
24442
|
+
if ((++rowCount + dimensions3.rows) * dimensions3.width > MAX_CELLS)
|
|
24443
|
+
throw new Error("The PivotTable result is too large.");
|
|
24444
|
+
return;
|
|
24445
|
+
}
|
|
24446
|
+
const [cells4, numbers3, entry3] = build3();
|
|
24447
|
+
values2.push([...cells4, ...numbers3]);
|
|
24478
24448
|
rowEntries.push(entry3);
|
|
24479
24449
|
indents.push(compact3 ? indent : 0);
|
|
24480
24450
|
};
|
|
24481
|
-
const
|
|
24482
|
-
|
|
24483
|
-
|
|
24484
|
-
|
|
24451
|
+
const entryOf = (indices, measure2, type) => ({
|
|
24452
|
+
indices,
|
|
24453
|
+
...measure2 !== void 0 ? { measure: measure2 } : {},
|
|
24454
|
+
...type ? { type } : {}
|
|
24455
|
+
});
|
|
24456
|
+
const walk2 = (level, group, measure2, path2) => {
|
|
24457
|
+
const field2 = fieldOf(level);
|
|
24458
|
+
const last = level === levels - 1;
|
|
24459
|
+
const repeated = Array.from(
|
|
24460
|
+
{ length: level },
|
|
24461
|
+
(_v, k) => !!pivot.repeatLabels && fieldOf(k) >= 0
|
|
24462
|
+
);
|
|
24463
|
+
const leafShown = (firsts) => repeated.map((repeat, k) => repeat || tabular && firsts.slice(k + 1).every(Boolean));
|
|
24464
|
+
if (field2 < 0) {
|
|
24465
|
+
measures2.forEach((one2, m) => {
|
|
24466
|
+
const here = {
|
|
24467
|
+
labels: [...path2.labels, one2.caption],
|
|
24468
|
+
indices: [...path2.indices, m],
|
|
24469
|
+
firsts: [...path2.firsts, m === 0]
|
|
24470
|
+
};
|
|
24471
|
+
if (last)
|
|
24472
|
+
return push3(level, () => [
|
|
24473
|
+
labelCells(path2, leafShown(here.firsts), level, one2.caption),
|
|
24474
|
+
cells3(group, void 0, m),
|
|
24475
|
+
entryOf(here.indices, m)
|
|
24476
|
+
]);
|
|
24477
|
+
if (!tabular)
|
|
24478
|
+
push3(level, () => [
|
|
24479
|
+
labelCells(path2, repeated, level, one2.caption),
|
|
24480
|
+
blanks(),
|
|
24481
|
+
entryOf(here.indices, m)
|
|
24482
|
+
]);
|
|
24483
|
+
walk2(level + 1, group, m, here);
|
|
24484
|
+
});
|
|
24485
|
+
return;
|
|
24486
|
+
}
|
|
24487
|
+
const own2 = functions[field2];
|
|
24488
|
+
const valuesAbove = !onRows || valuesAt < level;
|
|
24489
|
+
const showsValue = above && own2 === "auto" && valuesAbove;
|
|
24490
|
+
const children4 = [...group.children.values()].sort((a2, b) => a2.index - b.index);
|
|
24485
24491
|
children4.forEach((child7, position2) => {
|
|
24486
|
-
const here =
|
|
24487
|
-
|
|
24488
|
-
|
|
24489
|
-
|
|
24490
|
-
|
|
24491
|
-
|
|
24492
|
-
|
|
24493
|
-
)
|
|
24494
|
-
|
|
24495
|
-
|
|
24496
|
-
|
|
24492
|
+
const here = {
|
|
24493
|
+
labels: [...path2.labels, labelOf(names[field2], child7.value)],
|
|
24494
|
+
indices: [...path2.indices, child7.index],
|
|
24495
|
+
firsts: [...path2.firsts, position2 === 0]
|
|
24496
|
+
};
|
|
24497
|
+
const text8 = labelOf(names[field2], child7.value);
|
|
24498
|
+
if (last)
|
|
24499
|
+
return push3(level, () => [
|
|
24500
|
+
labelCells(path2, leafShown(here.firsts), level, text8),
|
|
24501
|
+
cells3(child7, void 0, measure2),
|
|
24502
|
+
entryOf(here.indices, measure2)
|
|
24503
|
+
]);
|
|
24497
24504
|
if (!tabular)
|
|
24498
|
-
push3(
|
|
24499
|
-
labelCells(path2, repeated,
|
|
24500
|
-
|
|
24501
|
-
|
|
24502
|
-
|
|
24503
|
-
|
|
24504
|
-
|
|
24505
|
-
const caption = String(
|
|
24505
|
+
push3(level, () => [
|
|
24506
|
+
labelCells(path2, repeated, level, text8),
|
|
24507
|
+
showsValue ? cells3(child7, void 0, measure2) : blanks(),
|
|
24508
|
+
entryOf(here.indices, measure2)
|
|
24509
|
+
]);
|
|
24510
|
+
walk2(level + 1, child7, measure2, here);
|
|
24511
|
+
if (field2 === depth - 1) return;
|
|
24512
|
+
const caption = String(text8);
|
|
24513
|
+
const subtotal = (title, fn, one2) => push3(level, () => [
|
|
24514
|
+
labelCells(path2, repeated, level, title),
|
|
24515
|
+
cells3(child7, fn, one2),
|
|
24516
|
+
entryOf(here.indices, one2, fn ?? "default")
|
|
24517
|
+
]);
|
|
24506
24518
|
if (own2 === "auto") {
|
|
24507
|
-
if (
|
|
24508
|
-
|
|
24509
|
-
|
|
24510
|
-
numbers3(child7),
|
|
24511
|
-
{ indices: at2, type: "default" },
|
|
24512
|
-
level
|
|
24513
|
-
);
|
|
24519
|
+
if (showsValue) return;
|
|
24520
|
+
if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure2);
|
|
24521
|
+
else measures2.forEach((one2, m) => subtotal(`${caption} ${one2.caption}`, void 0, m));
|
|
24514
24522
|
} else
|
|
24515
24523
|
for (const fn of own2)
|
|
24516
|
-
|
|
24517
|
-
|
|
24518
|
-
|
|
24519
|
-
|
|
24520
|
-
|
|
24521
|
-
);
|
|
24524
|
+
if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure2);
|
|
24525
|
+
else
|
|
24526
|
+
measures2.forEach(
|
|
24527
|
+
(one2, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one2.field}`, fn, m)
|
|
24528
|
+
);
|
|
24522
24529
|
});
|
|
24523
24530
|
};
|
|
24524
|
-
|
|
24525
|
-
|
|
24526
|
-
|
|
24527
|
-
|
|
24528
|
-
|
|
24529
|
-
|
|
24530
|
-
|
|
24531
|
+
const grand = (text8, measure2) => push3(0, () => [
|
|
24532
|
+
compact3 ? [text8] : [text8, ...Array(levels - 1).fill(null)],
|
|
24533
|
+
cells3(root, void 0, measure2),
|
|
24534
|
+
entryOf([0], measure2, "grand")
|
|
24535
|
+
]);
|
|
24536
|
+
const build2 = () => {
|
|
24537
|
+
walk2(0, root, void 0, { labels: [], indices: [], firsts: [] });
|
|
24538
|
+
if (onRows) measures2.forEach((one2, m) => grand(fillCaption(caps.measureTotal, one2.caption), m));
|
|
24539
|
+
else grand(caps.grandTotal);
|
|
24540
|
+
};
|
|
24541
|
+
build2();
|
|
24542
|
+
counting = false;
|
|
24543
|
+
values2 = pivotColumnHeaders(pivot, columns, compact3 ? [caps.rowLabels] : rowTitles, onRows);
|
|
24544
|
+
const firstDataRow = values2.length;
|
|
24545
|
+
indents = values2.map(() => 0);
|
|
24546
|
+
build2();
|
|
24531
24547
|
return {
|
|
24532
24548
|
values: values2,
|
|
24533
24549
|
rowItems: axisItems[0],
|
|
@@ -24539,105 +24555,15 @@ function nestedPivotGrid(pivot) {
|
|
|
24539
24555
|
rowEntries,
|
|
24540
24556
|
firstDataRow,
|
|
24541
24557
|
rowLabelColumns: labelColumns,
|
|
24542
|
-
indents
|
|
24558
|
+
indents,
|
|
24559
|
+
...onRows ? { firstHeaderRow: 1 } : {}
|
|
24543
24560
|
};
|
|
24544
24561
|
}
|
|
24545
24562
|
|
|
24546
24563
|
// xlsx/pivot/aggregate.ts
|
|
24547
24564
|
function pivotGrid(pivot) {
|
|
24548
24565
|
validatePivotFields(pivot);
|
|
24549
|
-
return prependPivotPage(
|
|
24550
|
-
}
|
|
24551
|
-
function pivotDataGrid(pivot) {
|
|
24552
|
-
if (pivot.valuesAxis !== "rows") return nestedPivotGrid(pivot);
|
|
24553
|
-
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
24554
|
-
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
24555
|
-
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
24556
|
-
const compact3 = pivot.layout === "compact";
|
|
24557
|
-
const headings = pivot.layout !== void 0 && pivot.layout !== "tabular";
|
|
24558
|
-
const dimensions3 = pivotHeaderDimensions(pivot, columnItems.length, compact3 ? 1 : 2);
|
|
24559
|
-
const dataRows = (rowItems.length + 1) * (1 + (pivot.additionalValues?.length ?? 0)) + (headings ? rowItems.length : 0);
|
|
24560
|
-
if ((dataRows + dimensions3.rows) * dimensions3.width > 1e6)
|
|
24561
|
-
throw new Error("The PivotTable result is too large.");
|
|
24562
|
-
const label5 = pivotItemLabel;
|
|
24563
|
-
const values2 = pivotHeaders(pivot, columnItems, [compact3 ? "Row Labels" : pivot.rowField], label5);
|
|
24564
|
-
const rowField = pivot.fields.indexOf(pivot.rowField);
|
|
24565
|
-
const colField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
24566
|
-
const groups = /* @__PURE__ */ new Map();
|
|
24567
|
-
const cells3 = /* @__PURE__ */ new Map();
|
|
24568
|
-
const columns = /* @__PURE__ */ new Map();
|
|
24569
|
-
const collect = (map, key2, record2) => {
|
|
24570
|
-
const found = map.get(key2);
|
|
24571
|
-
if (found) found.push(record2);
|
|
24572
|
-
else map.set(key2, [record2]);
|
|
24573
|
-
};
|
|
24574
|
-
for (const record2 of pivot.records) {
|
|
24575
|
-
const key2 = pivotValueKey(record2[rowField] ?? null);
|
|
24576
|
-
collect(groups, key2, record2);
|
|
24577
|
-
if (pivot.columnField) {
|
|
24578
|
-
const col = pivotValueKey(record2[colField] ?? null);
|
|
24579
|
-
collect(columns, col, record2);
|
|
24580
|
-
collect(cells3, JSON.stringify([key2, col]), record2);
|
|
24581
|
-
}
|
|
24582
|
-
}
|
|
24583
|
-
const firstDataRow = values2.length;
|
|
24584
|
-
const measures2 = pivotMeasures(pivot);
|
|
24585
|
-
const rowEntries = [];
|
|
24586
|
-
const indents = values2.map(() => 0);
|
|
24587
|
-
const append = (caption, bands, index3, grand = false) => {
|
|
24588
|
-
measures2.forEach((measure2, m) => {
|
|
24589
|
-
values2.push([
|
|
24590
|
-
...compact3 ? [grand ? `Total ${measure2.caption}` : measure2.caption] : [
|
|
24591
|
-
grand ? `Total ${measure2.caption}` : pivot.repeatLabels || !headings && m === 0 ? caption : null,
|
|
24592
|
-
grand ? null : measure2.caption
|
|
24593
|
-
],
|
|
24594
|
-
...bands.map((band2) => band2[m] ?? null)
|
|
24595
|
-
]);
|
|
24596
|
-
indents.push(compact3 && !grand ? 1 : 0);
|
|
24597
|
-
rowEntries.push({
|
|
24598
|
-
indices: grand ? [0] : [index3, m],
|
|
24599
|
-
measure: m,
|
|
24600
|
-
...grand ? { type: "grand" } : {}
|
|
24601
|
-
});
|
|
24602
|
-
});
|
|
24603
|
-
};
|
|
24604
|
-
rowItems.forEach((item, index3) => {
|
|
24605
|
-
const key2 = pivotValueKey(item);
|
|
24606
|
-
if (headings) {
|
|
24607
|
-
values2.push([label5(item), ...Array(dimensions3.width - 1).fill(null)]);
|
|
24608
|
-
rowEntries.push({ indices: [index3] });
|
|
24609
|
-
indents.push(0);
|
|
24610
|
-
}
|
|
24611
|
-
append(
|
|
24612
|
-
label5(item),
|
|
24613
|
-
[
|
|
24614
|
-
...columnItems.map(
|
|
24615
|
-
(col) => pivotNumbers(pivot, cells3.get(JSON.stringify([key2, pivotValueKey(col)])) ?? [])
|
|
24616
|
-
),
|
|
24617
|
-
pivotNumbers(pivot, groups.get(key2) ?? [])
|
|
24618
|
-
],
|
|
24619
|
-
index3
|
|
24620
|
-
);
|
|
24621
|
-
});
|
|
24622
|
-
append(
|
|
24623
|
-
"Grand Total",
|
|
24624
|
-
[
|
|
24625
|
-
...columnItems.map((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
24626
|
-
pivotNumbers(pivot, pivot.records)
|
|
24627
|
-
],
|
|
24628
|
-
0,
|
|
24629
|
-
true
|
|
24630
|
-
);
|
|
24631
|
-
return {
|
|
24632
|
-
values: values2,
|
|
24633
|
-
rowItems,
|
|
24634
|
-
columnItems,
|
|
24635
|
-
firstDataRow,
|
|
24636
|
-
rowLabelColumns: compact3 ? 1 : 2,
|
|
24637
|
-
indents,
|
|
24638
|
-
firstHeaderRow: 1,
|
|
24639
|
-
rowEntries
|
|
24640
|
-
};
|
|
24566
|
+
return prependPivotPage(nestedPivotGrid(pivotPageProjection(pivot)), pivot);
|
|
24641
24567
|
}
|
|
24642
24568
|
function pivotTableAt(sheet, at2) {
|
|
24643
24569
|
return sheet.pivotTables?.find((pivot) => rangeContains(pivot.location, at2));
|
|
@@ -24647,14 +24573,14 @@ function pivotTableAt(sheet, at2) {
|
|
|
24647
24573
|
var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
24648
24574
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
24649
24575
|
var TABLE = {
|
|
24650
|
-
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",
|
|
24576
|
+
pivotTableDefinition: "name cacheId dataCaption grandTotalCaption rowHeaderCaption colHeaderCaption dataOnRows dataPosition updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
|
|
24651
24577
|
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
24652
24578
|
pageFields: "count",
|
|
24653
24579
|
pageField: "fld item hier",
|
|
24654
24580
|
pivotFields: "count",
|
|
24655
24581
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal numFmtId sumSubtotal countASubtotal avgSubtotal maxSubtotal minSubtotal productSubtotal countSubtotal stdDevSubtotal stdDevPSubtotal varSubtotal varPSubtotal",
|
|
24656
24582
|
items: "count",
|
|
24657
|
-
item: "x t h",
|
|
24583
|
+
item: "x t h n",
|
|
24658
24584
|
rowFields: "count",
|
|
24659
24585
|
colFields: "count",
|
|
24660
24586
|
field: "x",
|
|
@@ -24755,8 +24681,8 @@ function inspect(node3, profile, cache3) {
|
|
|
24755
24681
|
}
|
|
24756
24682
|
for (const child7 of elements(node3)) inspect(child7, profile, cache3);
|
|
24757
24683
|
}
|
|
24758
|
-
function assertPivotAdmission(
|
|
24759
|
-
inspect(
|
|
24684
|
+
function assertPivotAdmission(table4, cache3) {
|
|
24685
|
+
inspect(table4, TABLE, false);
|
|
24760
24686
|
inspect(cache3, CACHE, true);
|
|
24761
24687
|
}
|
|
24762
24688
|
function assertPivotRecords(records) {
|
|
@@ -24767,6 +24693,121 @@ function assertPivotRecords(records) {
|
|
|
24767
24693
|
);
|
|
24768
24694
|
}
|
|
24769
24695
|
|
|
24696
|
+
// xlsx/pivot/captions-read.ts
|
|
24697
|
+
var ATTRIBUTES2 = {
|
|
24698
|
+
rowHeaderCaption: "rowLabels",
|
|
24699
|
+
colHeaderCaption: "columnLabels",
|
|
24700
|
+
grandTotalCaption: "grandTotal",
|
|
24701
|
+
dataCaption: "values"
|
|
24702
|
+
};
|
|
24703
|
+
function readPivotCaptionAttributes(root) {
|
|
24704
|
+
const out = {};
|
|
24705
|
+
for (const [attribute4, key2] of Object.entries(ATTRIBUTES2)) {
|
|
24706
|
+
const text8 = att(root, attribute4);
|
|
24707
|
+
if (text8 !== void 0)
|
|
24708
|
+
out[key2] = decodeEscapes(text8);
|
|
24709
|
+
}
|
|
24710
|
+
return out;
|
|
24711
|
+
}
|
|
24712
|
+
function aggregateCaptionsOf(pivot) {
|
|
24713
|
+
const out = {};
|
|
24714
|
+
for (const measure2 of [
|
|
24715
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
24716
|
+
...pivot.additionalValues ?? []
|
|
24717
|
+
]) {
|
|
24718
|
+
const at2 = measure2.caption.indexOf(measure2.field);
|
|
24719
|
+
if (at2 < 0 || measure2.caption === measure2.field) continue;
|
|
24720
|
+
const template = `${measure2.caption.slice(0, at2)}{0}${measure2.caption.slice(at2 + measure2.field.length)}`;
|
|
24721
|
+
if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure2.aggregate])
|
|
24722
|
+
out[measure2.aggregate] = template;
|
|
24723
|
+
}
|
|
24724
|
+
return Object.keys(out).length ? out : void 0;
|
|
24725
|
+
}
|
|
24726
|
+
var MARK = "";
|
|
24727
|
+
var SENTINELS = {
|
|
24728
|
+
rowLabels: `${MARK}R`,
|
|
24729
|
+
columnLabels: `${MARK}C`,
|
|
24730
|
+
grandTotal: `${MARK}G`,
|
|
24731
|
+
values: `${MARK}V`,
|
|
24732
|
+
all: `${MARK}A`,
|
|
24733
|
+
blank: `${MARK}B`,
|
|
24734
|
+
subtotal: `{0}${MARK}S`,
|
|
24735
|
+
measureTotal: `${MARK}M{0}`,
|
|
24736
|
+
functions: Object.fromEntries(
|
|
24737
|
+
Object.keys(ENGLISH_PIVOT_CAPTIONS.functions).map((fn) => [fn, `${MARK}F${fn}`])
|
|
24738
|
+
),
|
|
24739
|
+
aggregates: ENGLISH_PIVOT_CAPTIONS.aggregates
|
|
24740
|
+
};
|
|
24741
|
+
function templateOf(cached6, arg) {
|
|
24742
|
+
if (!arg || !cached6.includes(arg)) return void 0;
|
|
24743
|
+
if (cached6.startsWith(arg)) return `{0}${cached6.slice(arg.length)}`;
|
|
24744
|
+
if (cached6.endsWith(arg)) return `${cached6.slice(0, -arg.length)}{0}`;
|
|
24745
|
+
const at2 = cached6.indexOf(arg);
|
|
24746
|
+
return `${cached6.slice(0, at2)}{0}${cached6.slice(at2 + arg.length)}`;
|
|
24747
|
+
}
|
|
24748
|
+
function inferPivotCaptions(pivot, sheet, named3) {
|
|
24749
|
+
const known = pivotCaptions({ captions: named3 });
|
|
24750
|
+
const probe = { ...SENTINELS };
|
|
24751
|
+
for (const key2 of Object.keys(named3))
|
|
24752
|
+
if (typeof named3[key2] === "string")
|
|
24753
|
+
probe[key2] = known[key2];
|
|
24754
|
+
const grid = pivotGrid({ ...pivot, captions: probe });
|
|
24755
|
+
const found = /* @__PURE__ */ new Map();
|
|
24756
|
+
const set = (key2, value2) => {
|
|
24757
|
+
if (value2 === void 0) return;
|
|
24758
|
+
const before = found.get(key2);
|
|
24759
|
+
found.set(key2, before === void 0 || before === value2 ? value2 : null);
|
|
24760
|
+
};
|
|
24761
|
+
grid.values.forEach(
|
|
24762
|
+
(line3, r) => line3.forEach((expected, c2) => {
|
|
24763
|
+
if (typeof expected !== "string" || !expected.includes(MARK)) return;
|
|
24764
|
+
const cached6 = getCell(
|
|
24765
|
+
sheet,
|
|
24766
|
+
pivot.location.start.row + r,
|
|
24767
|
+
pivot.location.start.col + c2
|
|
24768
|
+
)?.value;
|
|
24769
|
+
if (typeof cached6 !== "string") return;
|
|
24770
|
+
const kind = /\u0001([RCGVASMFB])(\w*)/.exec(expected);
|
|
24771
|
+
if (!kind) return;
|
|
24772
|
+
const at2 = kind.index;
|
|
24773
|
+
switch (kind[1]) {
|
|
24774
|
+
case "R":
|
|
24775
|
+
return set("rowLabels", cached6);
|
|
24776
|
+
case "C":
|
|
24777
|
+
return set("columnLabels", cached6);
|
|
24778
|
+
case "G":
|
|
24779
|
+
return set("grandTotal", cached6);
|
|
24780
|
+
case "V":
|
|
24781
|
+
return set("values", cached6);
|
|
24782
|
+
case "A":
|
|
24783
|
+
return set("all", cached6);
|
|
24784
|
+
case "B":
|
|
24785
|
+
return set("blank", cached6);
|
|
24786
|
+
case "S":
|
|
24787
|
+
return set("subtotal", templateOf(cached6, expected.slice(0, at2)));
|
|
24788
|
+
case "M":
|
|
24789
|
+
return set("measureTotal", templateOf(cached6, expected.slice(at2 + 2)));
|
|
24790
|
+
case "F": {
|
|
24791
|
+
const item = expected.slice(0, at2 - 1);
|
|
24792
|
+
const of = / of (.*)$/.exec(expected.slice(at2));
|
|
24793
|
+
const word = cached6.slice(item.length + 1, of ? cached6.length - of[0].length : void 0);
|
|
24794
|
+
if (cached6.startsWith(`${item} `) && (!of || cached6.endsWith(of[0])))
|
|
24795
|
+
set(`function:${kind[2]}`, word);
|
|
24796
|
+
}
|
|
24797
|
+
}
|
|
24798
|
+
})
|
|
24799
|
+
);
|
|
24800
|
+
const out = pivotCaptions({ captions: named3 });
|
|
24801
|
+
const functions = { ...out.functions };
|
|
24802
|
+
for (const [key2, value2] of found) {
|
|
24803
|
+
if (value2 === null) continue;
|
|
24804
|
+
if (key2.startsWith("function:")) functions[key2.slice(9)] = value2;
|
|
24805
|
+
else out[key2] = value2;
|
|
24806
|
+
}
|
|
24807
|
+
out.functions = functions;
|
|
24808
|
+
return trimmedCaptions(out);
|
|
24809
|
+
}
|
|
24810
|
+
|
|
24770
24811
|
// xlsx/slicer/read-slicers.ts
|
|
24771
24812
|
var TABLE_SLICER_URI = "{2F2917AC-EB37-4324-AD4E-5DD8C200BD13}";
|
|
24772
24813
|
var X152 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
@@ -24842,12 +24883,12 @@ function parseSlicerCache(xml, partName) {
|
|
|
24842
24883
|
if (data) return void 0;
|
|
24843
24884
|
const list2 = byLocal(root, "extLst");
|
|
24844
24885
|
const ext = list2 ? elements(list2).find((node3) => node3.getAttribute("uri") === TABLE_SLICER_URI) : void 0;
|
|
24845
|
-
const
|
|
24846
|
-
const tableId = numAttr(
|
|
24847
|
-
const column2 = numAttr(
|
|
24848
|
-
if (!
|
|
24886
|
+
const table4 = ext ? first(ext, "tableSlicerCache", X152) : void 0;
|
|
24887
|
+
const tableId = numAttr(table4, "tableId");
|
|
24888
|
+
const column2 = numAttr(table4, "column");
|
|
24889
|
+
if (!table4 || tableId === void 0 || column2 === void 0) return void 0;
|
|
24849
24890
|
const cache3 = { ...common, source: { kind: "table", tableId, column: column2 } };
|
|
24850
|
-
if (att(
|
|
24891
|
+
if (att(table4, "sortOrder") === "descending") cache3.sortOrder = "descending";
|
|
24851
24892
|
if (elements(root).some((node3) => node3.localName === "pivotTables")) return void 0;
|
|
24852
24893
|
return cache3;
|
|
24853
24894
|
}
|
|
@@ -24932,14 +24973,14 @@ function parseTimelineCache(xml, partName) {
|
|
|
24932
24973
|
}
|
|
24933
24974
|
|
|
24934
24975
|
// xlsx/slicer/table-filter.ts
|
|
24935
|
-
function tableFilterBounds(
|
|
24976
|
+
function tableFilterBounds(table4) {
|
|
24936
24977
|
return {
|
|
24937
|
-
start:
|
|
24938
|
-
end: { ...
|
|
24978
|
+
start: table4.range.start,
|
|
24979
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
24939
24980
|
};
|
|
24940
24981
|
}
|
|
24941
|
-
function tableAutoFilter(
|
|
24942
|
-
const columns =
|
|
24982
|
+
function tableAutoFilter(table4) {
|
|
24983
|
+
const columns = table4.columns.flatMap(
|
|
24943
24984
|
(column2, offset2) => column2.filter ? [
|
|
24944
24985
|
{
|
|
24945
24986
|
offset: offset2,
|
|
@@ -24949,12 +24990,12 @@ function tableAutoFilter(table3) {
|
|
|
24949
24990
|
] : []
|
|
24950
24991
|
);
|
|
24951
24992
|
if (!columns.length) return void 0;
|
|
24952
|
-
return { range: tableFilterBounds(
|
|
24993
|
+
return { range: tableFilterBounds(table4), columns };
|
|
24953
24994
|
}
|
|
24954
|
-
function applyTableFilter(workbook, sheet,
|
|
24955
|
-
if (!
|
|
24956
|
-
const bounds2 = tableFilterBounds(
|
|
24957
|
-
const filter2 = tableAutoFilter(
|
|
24995
|
+
function applyTableFilter(workbook, sheet, table4) {
|
|
24996
|
+
if (!table4.headerRow) return;
|
|
24997
|
+
const bounds2 = tableFilterBounds(table4);
|
|
24998
|
+
const filter2 = tableAutoFilter(table4);
|
|
24958
24999
|
for (let row3 = bounds2.start.row + 1; row3 <= bounds2.end.row; row3++) {
|
|
24959
25000
|
const visible = !filter2 || rowMatchesFilter(workbook, sheet, row3, filter2);
|
|
24960
25001
|
setRowFiltered(sheet, row3, !visible, !!filter2);
|
|
@@ -24962,8 +25003,8 @@ function applyTableFilter(workbook, sheet, table3) {
|
|
|
24962
25003
|
}
|
|
24963
25004
|
function readTableFilteredRows(workbook) {
|
|
24964
25005
|
for (const sheet of workbook.sheets)
|
|
24965
|
-
for (const
|
|
24966
|
-
const filter2 = tableAutoFilter(
|
|
25006
|
+
for (const table4 of sheet.tables) {
|
|
25007
|
+
const filter2 = tableAutoFilter(table4);
|
|
24967
25008
|
if (!filter2) continue;
|
|
24968
25009
|
for (let row3 = filter2.range.start.row + 1; row3 <= filter2.range.end.row; row3++) {
|
|
24969
25010
|
const info = sheet.rowInfo.get(row3);
|
|
@@ -25082,9 +25123,9 @@ function settleSlicers(workbook, warn) {
|
|
|
25082
25123
|
if (cache3.source.kind === "table") {
|
|
25083
25124
|
const { tableId, column: column2 } = cache3.source;
|
|
25084
25125
|
for (const sheet of workbook.sheets) {
|
|
25085
|
-
const
|
|
25086
|
-
if (
|
|
25087
|
-
return
|
|
25126
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === tableId);
|
|
25127
|
+
if (table4)
|
|
25128
|
+
return table4.headerRow && !table4.filterNotModeled && table4.columns.some((entry3) => entry3.sourceId === column2);
|
|
25088
25129
|
}
|
|
25089
25130
|
return false;
|
|
25090
25131
|
}
|
|
@@ -25262,7 +25303,7 @@ function readFieldGroups(fields, names) {
|
|
|
25262
25303
|
throw new Error("Unsupported pivot field group");
|
|
25263
25304
|
const labels = children(list2, "s", NS.x).map((node3) => decodeEscapes(att(node3, "v") ?? ""));
|
|
25264
25305
|
const expected = numberGroupLabels({ start, end, by });
|
|
25265
|
-
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((
|
|
25306
|
+
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((label2, i2) => label2 !== expected[i2]))
|
|
25266
25307
|
throw new Error("Unsupported pivot group items");
|
|
25267
25308
|
groups.push({ field: names[index3] ?? "", start, end, by });
|
|
25268
25309
|
});
|
|
@@ -25340,14 +25381,18 @@ function readDateGroups(fields, count2, names, dateFields, records, date1904) {
|
|
|
25340
25381
|
const expected = dateGroupRange(group, serials);
|
|
25341
25382
|
if (!close(expected.start, start) || !close(expected.end, end))
|
|
25342
25383
|
throw unsupported("stale range");
|
|
25384
|
+
const localized = {};
|
|
25343
25385
|
for (const entry3 of list2) {
|
|
25344
|
-
const labels =
|
|
25386
|
+
const labels = englishDateUnitLabels(entry3.unit, expected, dateGroupDays(group), date1904);
|
|
25345
25387
|
const node3 = first(first(entry3.node, "fieldGroup", NS.x), "groupItems", NS.x);
|
|
25346
25388
|
const actual = children(node3, "s", NS.x).map((item) => decodeEscapes(att(item, "v") ?? ""));
|
|
25347
|
-
|
|
25389
|
+
const name3 = decodeEscapes(att(entry3.node, "name") ?? "");
|
|
25390
|
+
if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((label2) => !label2) || new Set(actual).size !== actual.length)
|
|
25348
25391
|
throw unsupported("group items");
|
|
25392
|
+
if (name3 !== dateGroupFieldName(entry3.unit, field2) || actual.some((l, i2) => l !== labels[i2]))
|
|
25393
|
+
localized[entry3.unit] = { name: name3, labels: actual };
|
|
25349
25394
|
}
|
|
25350
|
-
groups.push(group);
|
|
25395
|
+
groups.push(Object.keys(localized).length ? { ...group, localized } : group);
|
|
25351
25396
|
}
|
|
25352
25397
|
return groups;
|
|
25353
25398
|
}
|
|
@@ -25400,12 +25445,32 @@ function readItemFilters(fields, names, shared) {
|
|
|
25400
25445
|
return filters.length ? filters : void 0;
|
|
25401
25446
|
}
|
|
25402
25447
|
|
|
25448
|
+
// xlsx/pivot/item-names-read.ts
|
|
25449
|
+
function readItemNames(tableFields, names, shared) {
|
|
25450
|
+
const out = [];
|
|
25451
|
+
tableFields.forEach((field2, index3) => {
|
|
25452
|
+
const list2 = first(field2, "items", NS.x);
|
|
25453
|
+
if (!list2 || index3 >= names.length) return;
|
|
25454
|
+
for (const item of children(list2, "item", NS.x)) {
|
|
25455
|
+
const name3 = att(item, "n");
|
|
25456
|
+
if (name3 === void 0) continue;
|
|
25457
|
+
const at2 = Number(att(item, "x"));
|
|
25458
|
+
const value2 = shared[index3]?.[at2];
|
|
25459
|
+
if (att(item, "t") !== void 0 || !Number.isInteger(at2) || value2 === void 0)
|
|
25460
|
+
throw new Error("Unsupported pivot item name");
|
|
25461
|
+
out.push({ field: names[index3], item: value2, name: decodeEscapes(name3) });
|
|
25462
|
+
}
|
|
25463
|
+
});
|
|
25464
|
+
return out;
|
|
25465
|
+
}
|
|
25466
|
+
|
|
25403
25467
|
// xlsx/pivot/values-axis.ts
|
|
25404
25468
|
function remapPivotRowEntries(entries, axes2) {
|
|
25405
25469
|
return entries.map(
|
|
25406
25470
|
(entry3) => entry3.type === "grand" ? entry3 : {
|
|
25407
25471
|
...entry3,
|
|
25408
25472
|
indices: entry3.indices.map((item, axis) => {
|
|
25473
|
+
if (axes2[axis] === null) return item;
|
|
25409
25474
|
const index3 = axes2[axis]?.[item];
|
|
25410
25475
|
if (index3 === void 0) throw new Error("Invalid report row axis item");
|
|
25411
25476
|
return index3;
|
|
@@ -25424,7 +25489,7 @@ function pivotValueIndex(root, axis) {
|
|
|
25424
25489
|
const position2 = root.getAttribute("dataPosition");
|
|
25425
25490
|
if (position2 !== null && (!/^\d+$/.test(position2.trim()) || Number(position2) !== index3))
|
|
25426
25491
|
throw new Error("Inconsistent Values axis position");
|
|
25427
|
-
if (
|
|
25492
|
+
if (index3 >= 0 && index3 < axis.length - 1 && position2 === null)
|
|
25428
25493
|
throw new Error("Missing leading or between-field Values position");
|
|
25429
25494
|
return index3;
|
|
25430
25495
|
}
|
|
@@ -25439,7 +25504,7 @@ function pivotValueAxisItems(measures2) {
|
|
|
25439
25504
|
function supportedPivotAxes(rows, columns, measures2, valuesOnRows) {
|
|
25440
25505
|
const index3 = pivotFieldIndex;
|
|
25441
25506
|
if (valuesOnRows)
|
|
25442
|
-
return measures2 > 1 &&
|
|
25507
|
+
return measures2 > 1 && rows.length > 1 && rows.filter((field2) => index3(field2) === -2).length === 1 && rows.filter((field2) => index3(field2) !== -2).every((field2) => index3(field2) >= 0) && columns.every((field2) => index3(field2) >= 0);
|
|
25443
25508
|
if (rows.some((field2) => !Number.isInteger(index3(field2)) || index3(field2) < 0)) return false;
|
|
25444
25509
|
if (measures2 > 1 && (!columns.length || index3(columns.at(-1)) !== -2)) return false;
|
|
25445
25510
|
return (measures2 > 1 ? columns.slice(0, -1) : columns).every(
|
|
@@ -25460,6 +25525,9 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25460
25525
|
literals(cache3);
|
|
25461
25526
|
literals(recordRoot);
|
|
25462
25527
|
const cacheFields = children(first(cache3, "cacheFields", NS.x), "cacheField", NS.x);
|
|
25528
|
+
const all2 = expandDateGroups(pivot).fields;
|
|
25529
|
+
const derived = all2.slice(pivot.fields.length).map((name3) => groupLabelsOf(pivot, name3) ?? []);
|
|
25530
|
+
const sharedAll = [...shared, ...derived];
|
|
25463
25531
|
if (pivot.columnField) {
|
|
25464
25532
|
const column2 = children(first(root, "pivotFields", NS.x), "pivotField", NS.x)[pivot.fields.indexOf(pivot.columnField)];
|
|
25465
25533
|
const list2 = first(column2, "extLst", NS.x);
|
|
@@ -25478,13 +25546,13 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25478
25546
|
))
|
|
25479
25547
|
throw new Error("Repeated report column labels are preserved");
|
|
25480
25548
|
}
|
|
25481
|
-
if (integer3(first(cache3, "cacheFields", NS.x)?.getAttribute("count") ?? null) !==
|
|
25549
|
+
if (integer3(first(cache3, "cacheFields", NS.x)?.getAttribute("count") ?? null) !== all2.length || integer3(cache3.getAttribute("recordCount")) !== pivot.records.length || integer3(recordRoot.getAttribute("count")) !== pivot.records.length)
|
|
25482
25550
|
throw new Error("Inconsistent report cache counts");
|
|
25483
25551
|
for (const name3 of [...pivotRowFields(pivot), pivot.columnField, pivot.pageFilter.field].filter(
|
|
25484
25552
|
Boolean
|
|
25485
25553
|
)) {
|
|
25486
|
-
const field2 =
|
|
25487
|
-
if (integer3(first(cacheFields[field2], "sharedItems", NS.x)?.getAttribute("count") ?? null) !== shared[field2].length)
|
|
25554
|
+
const field2 = all2.indexOf(name3);
|
|
25555
|
+
if (field2 < pivot.fields.length && integer3(first(cacheFields[field2], "sharedItems", NS.x)?.getAttribute("count") ?? null) !== shared[field2].length)
|
|
25488
25556
|
throw new Error("Inconsistent report shared-item counts");
|
|
25489
25557
|
}
|
|
25490
25558
|
for (const name3 of ["rowFields", "colFields"]) {
|
|
@@ -25494,7 +25562,7 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25494
25562
|
}
|
|
25495
25563
|
const projected = pivotPageProjection(pivot), fields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
25496
25564
|
const axisValues = (name3, axis) => {
|
|
25497
|
-
const f6 =
|
|
25565
|
+
const f6 = all2.indexOf(name3), node3 = fields[f6], list2 = first(node3, "items", NS.x), items = children(list2, "item", NS.x), count2 = sharedAll[f6].length;
|
|
25498
25566
|
if (node3.getAttribute("axis") !== axis) throw new Error("Inconsistent report axis field");
|
|
25499
25567
|
const defaults = node3.getAttribute("defaultSubtotal") !== "0";
|
|
25500
25568
|
if (!list2 || integer3(list2.getAttribute("count")) !== items.length || items.length !== count2 + Number(defaults))
|
|
@@ -25503,7 +25571,7 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25503
25571
|
const i2 = integer3(item.getAttribute("x"));
|
|
25504
25572
|
if (item.hasAttribute("t") || !Number.isInteger(i2) || i2 >= count2)
|
|
25505
25573
|
throw new Error("Invalid page-axis cache item");
|
|
25506
|
-
return
|
|
25574
|
+
return sharedAll[f6][i2];
|
|
25507
25575
|
});
|
|
25508
25576
|
if (new Set(data.map(pivotValueKey)).size !== count2 || defaults && (items.at(-1)?.getAttribute("t") !== "default" || items.at(-1)?.hasAttribute("x")))
|
|
25509
25577
|
throw new Error("Invalid page-axis default item");
|
|
@@ -25518,7 +25586,10 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25518
25586
|
};
|
|
25519
25587
|
const rowAxes = pivotRowFields(pivot).map((name3) => axisValues(name3, "axisRow")), rowItems = read("rowItems");
|
|
25520
25588
|
const grid = pivotGrid(pivot);
|
|
25521
|
-
const
|
|
25589
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
25590
|
+
const levelAxes = [...rowAxes];
|
|
25591
|
+
if (valuesAt >= 0) levelAxes.splice(valuesAt, 0, null);
|
|
25592
|
+
const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, levelAxes) : [
|
|
25522
25593
|
...rowAxes[0].map((index3) => ({ indices: [index3] })),
|
|
25523
25594
|
{ indices: [0], type: "grand" }
|
|
25524
25595
|
];
|
|
@@ -25528,11 +25599,11 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25528
25599
|
const expected2 = entries[i2];
|
|
25529
25600
|
const xs = children(item, "x", NS.x).map((x) => integer3(x.getAttribute("v"), 0)), prefix3 = integer3(item.getAttribute("r"), 0);
|
|
25530
25601
|
const type = expected2.type === void 0 || expected2.type === "default" || expected2.type === "grand" ? expected2.type : PIVOT_SUBTOTALS[expected2.type].item;
|
|
25531
|
-
if (item.getAttribute("t") !== (type ?? null) || !Number.isInteger(prefix3) || prefix3 < 0 || prefix3 > previousRow.length || prefix3 >= expected2.indices.length || expected2.type === "grand" && prefix3 !== 0 || integer3(item.getAttribute("i"), 0) !== 0 || JSON.stringify([...previousRow.slice(0, prefix3), ...xs]) !== JSON.stringify(expected2.indices))
|
|
25602
|
+
if (item.getAttribute("t") !== (type ?? null) || !Number.isInteger(prefix3) || prefix3 < 0 || prefix3 > previousRow.length || prefix3 >= expected2.indices.length || expected2.type === "grand" && prefix3 !== 0 || integer3(item.getAttribute("i"), 0) !== (expected2.measure ?? 0) || JSON.stringify([...previousRow.slice(0, prefix3), ...xs]) !== JSON.stringify(expected2.indices))
|
|
25532
25603
|
throw new Error("Unmodeled page row item");
|
|
25533
25604
|
previousRow = expected2.type === "grand" ? [] : expected2.indices;
|
|
25534
25605
|
});
|
|
25535
|
-
const measures2 = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25606
|
+
const measures2 = valuesAt >= 0 ? 1 : 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25536
25607
|
if (columns)
|
|
25537
25608
|
for (const col of columns)
|
|
25538
25609
|
for (let m = 0; m < measures2; m++) expected.push(measures2 > 1 ? [col, m] : [col]);
|
|
@@ -25574,6 +25645,10 @@ function value(node3, date1904 = false) {
|
|
|
25574
25645
|
if (node3.localName === "e" && isErrorCode(v)) return { error: v };
|
|
25575
25646
|
throw new Error("Unsupported pivot cache item");
|
|
25576
25647
|
}
|
|
25648
|
+
var namedAggregates = (pivot) => {
|
|
25649
|
+
const aggregates = aggregateCaptionsOf(pivot);
|
|
25650
|
+
return aggregates ? { aggregates } : {};
|
|
25651
|
+
};
|
|
25577
25652
|
function readOne(workbook, source2, part) {
|
|
25578
25653
|
const xml = source2.text(part);
|
|
25579
25654
|
const root = parseXml(xml).documentElement;
|
|
@@ -25639,7 +25714,7 @@ function readOne(workbook, source2, part) {
|
|
|
25639
25714
|
"dataField",
|
|
25640
25715
|
NS.x
|
|
25641
25716
|
);
|
|
25642
|
-
if (rowFields.length < 1 ||
|
|
25717
|
+
if (rowFields.length < 1 || dataFields.length < 1 || dataFields.length > 16 || !supportedPivotAxes(rowFields, colFields, dataFields.length, rowsAxis) || root.getAttribute("rowGrandTotals") === "0" || root.getAttribute("colGrandTotals") === "0")
|
|
25643
25718
|
throw new Error("Unsupported pivot layout");
|
|
25644
25719
|
const valueIndex = pivotValueIndex(root, rowsAxis ? rowFields : colFields);
|
|
25645
25720
|
const measure2 = dataFields[0];
|
|
@@ -25709,8 +25784,8 @@ function readOne(workbook, source2, part) {
|
|
|
25709
25784
|
const col = columnNames[0];
|
|
25710
25785
|
const moreColumns = columnNames.slice(1);
|
|
25711
25786
|
const columnDefinitions = columnDefs.map((field2) => tableFields[Number(att(field2, "x"))]);
|
|
25712
|
-
if (
|
|
25713
|
-
|
|
25787
|
+
if (columnNames.some((name3) => !name3)) throw new Error("Invalid pivot column fields");
|
|
25788
|
+
const columnSubtotals = fieldSubtotalsOf(columnDefinitions, columnNames);
|
|
25714
25789
|
const data = names[Number(att(measure2, "fld"))];
|
|
25715
25790
|
const location = parseRange(att(first(root, "location", NS.x), "ref") ?? "");
|
|
25716
25791
|
if (!row3 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
|
|
@@ -25720,6 +25795,7 @@ function readOne(workbook, source2, part) {
|
|
|
25720
25795
|
location.start.row -= 2;
|
|
25721
25796
|
}
|
|
25722
25797
|
const itemFilters = readItemFilters(tableFields, names, shared);
|
|
25798
|
+
const itemNames = readItemNames(tableFields, names, shared);
|
|
25723
25799
|
const slicerCacheId = readSlicerCacheId(cache3);
|
|
25724
25800
|
const fieldGroups = readFieldGroups(fields, names);
|
|
25725
25801
|
const dateFields = readDateFields(fields, names);
|
|
@@ -25751,11 +25827,14 @@ function readOne(workbook, source2, part) {
|
|
|
25751
25827
|
]);
|
|
25752
25828
|
if (dateFields.some((field2) => onAxis.has(field2)))
|
|
25753
25829
|
throw new Error("Date fields used as rows, columns or values are preserved");
|
|
25754
|
-
|
|
25755
|
-
|
|
25830
|
+
const fieldSubtotals = [
|
|
25831
|
+
...subtotalSettings.filter((entry4) => entry4.field !== row3 || entry4.functions.length),
|
|
25832
|
+
...columnSubtotals
|
|
25833
|
+
];
|
|
25756
25834
|
const pivot = {
|
|
25757
25835
|
...pageFilter ? { pageFilter } : {},
|
|
25758
25836
|
...itemFilters ? { itemFilters } : {},
|
|
25837
|
+
...itemNames.length ? { itemNames } : {},
|
|
25759
25838
|
...fieldGroups.length ? { fieldGroups } : {},
|
|
25760
25839
|
...dateFields.length ? { dateFields } : {},
|
|
25761
25840
|
...dateGroups.length ? { dateGroups } : {},
|
|
@@ -25767,13 +25846,11 @@ function readOne(workbook, source2, part) {
|
|
|
25767
25846
|
rowField: row3,
|
|
25768
25847
|
layout: layout3,
|
|
25769
25848
|
...rowsAxis ? { valuesAxis: "rows" } : {},
|
|
25770
|
-
...rowsAxis &&
|
|
25771
|
-
|
|
25772
|
-
...subtotalSettings.some((entry4) => entry4.field !== row3 || entry4.functions.length) ? {
|
|
25773
|
-
fieldSubtotals: subtotalSettings.filter(
|
|
25774
|
-
(entry4) => entry4.field !== row3 || entry4.functions.length
|
|
25775
|
-
)
|
|
25849
|
+
...rowsAxis && valueIndex < realRows.length ? {
|
|
25850
|
+
valuesPosition: valueIndex === 0 ? "first" : valueIndex === 1 && realRows.length === 2 ? "between" : valueIndex
|
|
25776
25851
|
} : {},
|
|
25852
|
+
subtotalPosition: att(outer, "subtotalTop") === "0" ? "bottom" : "top",
|
|
25853
|
+
...fieldSubtotals.length ? { fieldSubtotals } : {},
|
|
25777
25854
|
...more.length ? { moreRowFields: more } : {},
|
|
25778
25855
|
...second ? { secondRowField: second, subtotals: subtotal, repeatLabels: repeat[0] ?? false } : {
|
|
25779
25856
|
...subtotal ? {} : { subtotals: false },
|
|
@@ -25800,6 +25877,12 @@ function readOne(workbook, source2, part) {
|
|
|
25800
25877
|
...col ? { columnField: col } : {},
|
|
25801
25878
|
...moreColumns.length ? { moreColumnFields: moreColumns } : {}
|
|
25802
25879
|
};
|
|
25880
|
+
const captions = trimmedCaptions(
|
|
25881
|
+
pivotCaptions({
|
|
25882
|
+
captions: { ...readPivotCaptionAttributes(root), ...namedAggregates(pivot) }
|
|
25883
|
+
})
|
|
25884
|
+
);
|
|
25885
|
+
if (captions) pivot.captions = captions;
|
|
25803
25886
|
if (pageFilter && moreColumns.length) throw new Error("Report filters support one column field");
|
|
25804
25887
|
assertPageAxisItems(root, pivot, shared, cache3, recordRoot);
|
|
25805
25888
|
return pivot;
|
|
@@ -25827,6 +25910,12 @@ function readPivotTables(workbook, source2, warn, slicers) {
|
|
|
25827
25910
|
if (slicers.blocked.has(pivotKey(sheet.sheetId, name3)) || cache3 && (caches2.get(cache3) ?? 0) > 1)
|
|
25828
25911
|
throw new Error("Shared pivot cache or unsupported slicer connection");
|
|
25829
25912
|
const pivot = readOne(workbook, source2, part);
|
|
25913
|
+
const inferred = inferPivotCaptions(pivot, sheet, {
|
|
25914
|
+
...readPivotCaptionAttributes(parseXml(pivot.sourceXml).documentElement),
|
|
25915
|
+
...namedAggregates(pivot)
|
|
25916
|
+
});
|
|
25917
|
+
if (inferred) pivot.captions = inferred;
|
|
25918
|
+
else delete pivot.captions;
|
|
25830
25919
|
const grid = pivotGrid(pivot);
|
|
25831
25920
|
if (grid.values.length !== pivot.location.end.row - pivot.location.start.row + 1 || grid.values[0].length !== pivot.location.end.col - pivot.location.start.col + 1 || grid.values.some(
|
|
25832
25921
|
(line3, r) => line3.some(
|
|
@@ -26466,7 +26555,7 @@ function mergeSpacedAreas(tokens3) {
|
|
|
26466
26555
|
}
|
|
26467
26556
|
return out;
|
|
26468
26557
|
}
|
|
26469
|
-
function
|
|
26558
|
+
function templateOf2(formula) {
|
|
26470
26559
|
const cached6 = templates.get(formula);
|
|
26471
26560
|
if (cached6 !== void 0) return cached6;
|
|
26472
26561
|
const raw2 = safeTokens(formula);
|
|
@@ -26496,7 +26585,7 @@ function templateOf(formula) {
|
|
|
26496
26585
|
return template;
|
|
26497
26586
|
}
|
|
26498
26587
|
function rewriteTemplate(formula, rewrite2) {
|
|
26499
|
-
const template =
|
|
26588
|
+
const template = templateOf2(formula);
|
|
26500
26589
|
if (!template) return formula;
|
|
26501
26590
|
let next;
|
|
26502
26591
|
for (let i2 = 0; i2 < template.length; i2++) {
|
|
@@ -27797,14 +27886,14 @@ function readDataTable(f6) {
|
|
|
27797
27886
|
const ref = parseRange(att(f6, "ref") ?? "");
|
|
27798
27887
|
const r1 = att(f6, "r1");
|
|
27799
27888
|
if (!ref || !r1) return void 0;
|
|
27800
|
-
const
|
|
27889
|
+
const table4 = { ref, r1 };
|
|
27801
27890
|
const r2 = att(f6, "r2");
|
|
27802
|
-
if (r2)
|
|
27803
|
-
if (boolAttr(f6, "dt2D"))
|
|
27804
|
-
if (boolAttr(f6, "dtr"))
|
|
27805
|
-
if (boolAttr(f6, "del1"))
|
|
27806
|
-
if (boolAttr(f6, "del2"))
|
|
27807
|
-
return
|
|
27891
|
+
if (r2) table4.r2 = r2;
|
|
27892
|
+
if (boolAttr(f6, "dt2D")) table4.dt2D = true;
|
|
27893
|
+
if (boolAttr(f6, "dtr")) table4.dtr = true;
|
|
27894
|
+
if (boolAttr(f6, "del1")) table4.del1 = true;
|
|
27895
|
+
if (boolAttr(f6, "del2")) table4.del2 = true;
|
|
27896
|
+
return table4;
|
|
27808
27897
|
}
|
|
27809
27898
|
function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet) {
|
|
27810
27899
|
const kind = att(f6, "t") ?? "normal";
|
|
@@ -27828,8 +27917,8 @@ function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet
|
|
|
27828
27917
|
}
|
|
27829
27918
|
if (kind === "dataTable") {
|
|
27830
27919
|
delete cell.legacyFormula;
|
|
27831
|
-
const
|
|
27832
|
-
if (
|
|
27920
|
+
const table4 = readDataTable(f6);
|
|
27921
|
+
if (table4) (sheet.dataTables ??= []).push(table4);
|
|
27833
27922
|
else ctx.warn("A what-if data table formula could not be read; its cached values were kept.");
|
|
27834
27923
|
return;
|
|
27835
27924
|
}
|
|
@@ -28021,14 +28110,14 @@ function parseTable3(xml, partName) {
|
|
|
28021
28110
|
if (id3 !== void 0 && Number.isInteger(id3) && id3 >= 0) column2.sourceId = id3;
|
|
28022
28111
|
const fn = att(node3, "totalsRowFunction");
|
|
28023
28112
|
if (fn && fn !== "none") column2.totalsRowFunction = fn;
|
|
28024
|
-
const
|
|
28025
|
-
if (
|
|
28113
|
+
const label2 = att(node3, "totalsRowLabel");
|
|
28114
|
+
if (label2 !== void 0) column2.totalsRowLabel = label2;
|
|
28026
28115
|
const calculated = xFirst(node3, "calculatedColumnFormula");
|
|
28027
28116
|
if (calculated) column2.calculatedColumnFormula = stripFuturePrefixes(xText(calculated));
|
|
28028
28117
|
return column2;
|
|
28029
28118
|
}
|
|
28030
28119
|
);
|
|
28031
|
-
const
|
|
28120
|
+
const table4 = {
|
|
28032
28121
|
id: numAttr(root, "id") ?? 1,
|
|
28033
28122
|
name: name3,
|
|
28034
28123
|
displayName: att(root, "displayName") ?? name3,
|
|
@@ -28038,26 +28127,26 @@ function parseTable3(xml, partName) {
|
|
|
28038
28127
|
columns,
|
|
28039
28128
|
partName
|
|
28040
28129
|
};
|
|
28041
|
-
readColumnFilters(root,
|
|
28130
|
+
readColumnFilters(root, table4);
|
|
28042
28131
|
const info = xFirst(root, "tableStyleInfo");
|
|
28043
28132
|
if (info) {
|
|
28044
28133
|
const style3 = att(info, "name");
|
|
28045
|
-
if (style3)
|
|
28046
|
-
|
|
28047
|
-
|
|
28048
|
-
|
|
28049
|
-
|
|
28134
|
+
if (style3) table4.styleName = style3;
|
|
28135
|
+
table4.showRowStripes = boolAttr(info, "showRowStripes", false);
|
|
28136
|
+
table4.showColumnStripes = boolAttr(info, "showColumnStripes", false);
|
|
28137
|
+
table4.showFirstColumn = boolAttr(info, "showFirstColumn", false);
|
|
28138
|
+
table4.showLastColumn = boolAttr(info, "showLastColumn", false);
|
|
28050
28139
|
}
|
|
28051
|
-
return
|
|
28140
|
+
return table4;
|
|
28052
28141
|
}
|
|
28053
|
-
function readColumnFilters(root,
|
|
28142
|
+
function readColumnFilters(root, table4) {
|
|
28054
28143
|
const filter2 = xFirst(root, "autoFilter");
|
|
28055
28144
|
for (const node3 of filter2 ? xChildren(filter2, "filterColumn") : []) {
|
|
28056
|
-
const column2 =
|
|
28145
|
+
const column2 = table4.columns[numAttr(node3, "colId") ?? -1];
|
|
28057
28146
|
const filters = xChildren(node3, "filters");
|
|
28058
28147
|
const simple = column2 && isValueListFilterColumn(node3);
|
|
28059
28148
|
if (!simple) {
|
|
28060
|
-
|
|
28149
|
+
table4.filterNotModeled = true;
|
|
28061
28150
|
continue;
|
|
28062
28151
|
}
|
|
28063
28152
|
const values2 = xChildren(filters[0], "filter").map((child7) => att(child7, "val") ?? "");
|
|
@@ -28136,8 +28225,8 @@ function readTables(ctx, partName, node3, sheet) {
|
|
|
28136
28225
|
const rel = rels.get(relAttr(part, "id") ?? "");
|
|
28137
28226
|
const target2 = rel ? ctx.source.target(partName, rel) : void 0;
|
|
28138
28227
|
const xml = target2 ? ctx.source.text(target2) : void 0;
|
|
28139
|
-
const
|
|
28140
|
-
if (
|
|
28228
|
+
const table4 = target2 && xml ? parseTable3(xml, target2) : void 0;
|
|
28229
|
+
if (table4) sheet.tables.push(table4);
|
|
28141
28230
|
else ctx.warn("A table part could not be read and was dropped.");
|
|
28142
28231
|
}
|
|
28143
28232
|
}
|
|
@@ -30607,14 +30696,14 @@ function unique(args, ctx) {
|
|
|
30607
30696
|
const byCol = args.length > 1 && args[1] !== null && toBool(ctx.toScalar(args[1] ?? null));
|
|
30608
30697
|
const once = args.length > 2 && args[2] !== null && toBool(ctx.toScalar(args[2] ?? null));
|
|
30609
30698
|
if (byCol) m = transpose(m);
|
|
30610
|
-
const
|
|
30699
|
+
const keyOf3 = (row3) => JSON.stringify(
|
|
30611
30700
|
row3.map(
|
|
30612
30701
|
(v) => isError(v) ? `#${v.error}` : typeof v === "string" ? `s${v.toLowerCase()}` : v
|
|
30613
30702
|
)
|
|
30614
30703
|
);
|
|
30615
30704
|
const counts = /* @__PURE__ */ new Map();
|
|
30616
30705
|
for (const row3 of m.data) {
|
|
30617
|
-
const key2 =
|
|
30706
|
+
const key2 = keyOf3(row3);
|
|
30618
30707
|
const entry3 = counts.get(key2);
|
|
30619
30708
|
if (entry3) entry3.count++;
|
|
30620
30709
|
else counts.set(key2, { row: row3, count: 1 });
|
|
@@ -30899,30 +30988,30 @@ function gammaLn(z) {
|
|
|
30899
30988
|
|
|
30900
30989
|
// xlsx/formula/functions/database.ts
|
|
30901
30990
|
var C3 = "Database";
|
|
30902
|
-
var
|
|
30991
|
+
var label = (value2) => value2 === null ? "" : typeof value2 === "string" ? value2 : String(value2);
|
|
30903
30992
|
function tableOf(ctx, value2) {
|
|
30904
30993
|
const [head, ...records] = ctx.toMatrix(value2 ?? null).data;
|
|
30905
30994
|
if (!head || records.length === 0) fail(ERR.VALUE);
|
|
30906
|
-
return { headers: head.map((v) =>
|
|
30995
|
+
return { headers: head.map((v) => label(v).toLowerCase()), records };
|
|
30907
30996
|
}
|
|
30908
|
-
function fieldIndex(
|
|
30997
|
+
function fieldIndex(table4, field2) {
|
|
30909
30998
|
const value2 = scalar2(field2);
|
|
30910
30999
|
if (isError(value2)) fail(value2);
|
|
30911
31000
|
if (typeof value2 === "number") {
|
|
30912
31001
|
const index4 = Math.trunc(value2) - 1;
|
|
30913
|
-
if (index4 < 0 || index4 >=
|
|
31002
|
+
if (index4 < 0 || index4 >= table4.headers.length) fail(ERR.VALUE);
|
|
30914
31003
|
return index4;
|
|
30915
31004
|
}
|
|
30916
|
-
const index3 =
|
|
31005
|
+
const index3 = table4.headers.indexOf(label(value2).toLowerCase());
|
|
30917
31006
|
if (index3 < 0) fail(ERR.VALUE);
|
|
30918
31007
|
return index3;
|
|
30919
31008
|
}
|
|
30920
|
-
function recordFilter(
|
|
31009
|
+
function recordFilter(table4, criteria) {
|
|
30921
31010
|
const [head, ...rows] = criteria;
|
|
30922
31011
|
if (!head || rows.length === 0) fail(ERR.VALUE);
|
|
30923
31012
|
const columns = head.map((name3) => {
|
|
30924
31013
|
if (name3 === null || name3 === "") return -1;
|
|
30925
|
-
return
|
|
31014
|
+
return table4.headers.indexOf(label(name3).toLowerCase());
|
|
30926
31015
|
});
|
|
30927
31016
|
const alternatives = rows.map(
|
|
30928
31017
|
(row3) => row3.flatMap((cell, c2) => {
|
|
@@ -30936,10 +31025,10 @@ function recordFilter(table3, criteria) {
|
|
|
30936
31025
|
return (record2) => alternatives.some((tests) => tests.every((test) => test(record2)));
|
|
30937
31026
|
}
|
|
30938
31027
|
function selected(ctx, args) {
|
|
30939
|
-
const
|
|
30940
|
-
const column2 = fieldIndex(
|
|
30941
|
-
const matches2 = recordFilter(
|
|
30942
|
-
return
|
|
31028
|
+
const table4 = tableOf(ctx, args[0]);
|
|
31029
|
+
const column2 = fieldIndex(table4, args[1]);
|
|
31030
|
+
const matches2 = recordFilter(table4, ctx.toMatrix(args[2] ?? null).data);
|
|
31031
|
+
return table4.records.filter(matches2).map((record2) => record2[column2] ?? null);
|
|
30943
31032
|
}
|
|
30944
31033
|
var numbers = (values2) => {
|
|
30945
31034
|
for (const v of values2) if (isError(v)) fail(v);
|
|
@@ -31767,9 +31856,9 @@ var BESSEL_FUNCTIONS = [
|
|
|
31767
31856
|
];
|
|
31768
31857
|
|
|
31769
31858
|
// xlsx/formula/functions/convert.ts
|
|
31770
|
-
var
|
|
31859
|
+
var table2 = /* @__PURE__ */ new Map();
|
|
31771
31860
|
var add3 = (dimension3, names, factor, extra = {}) => {
|
|
31772
|
-
for (const name3 of names)
|
|
31861
|
+
for (const name3 of names) table2.set(name3, { dimension: dimension3, factor, ...extra });
|
|
31773
31862
|
};
|
|
31774
31863
|
add3("mass", ["g"], 1, { prefix: "metric" });
|
|
31775
31864
|
add3("mass", ["sg"], 14593.9029372064);
|
|
@@ -31900,10 +31989,10 @@ var BINARY2 = {
|
|
|
31900
31989
|
ki: 2 ** 10
|
|
31901
31990
|
};
|
|
31902
31991
|
function resolve(name3) {
|
|
31903
|
-
const direct =
|
|
31992
|
+
const direct = table2.get(name3);
|
|
31904
31993
|
if (direct) return { dimension: direct.dimension, factor: direct.factor };
|
|
31905
31994
|
for (const length of [2, 1]) {
|
|
31906
|
-
const unit3 =
|
|
31995
|
+
const unit3 = table2.get(name3.slice(length));
|
|
31907
31996
|
const prefix3 = name3.slice(0, length);
|
|
31908
31997
|
if (!unit3?.prefix) continue;
|
|
31909
31998
|
const scale2 = (unit3.prefix === "binary" ? BINARY2[prefix3] : void 0) ?? METRIC[prefix3];
|
|
@@ -33238,30 +33327,30 @@ function findTable(host, name3, sheet, row3, col) {
|
|
|
33238
33327
|
if (name3) {
|
|
33239
33328
|
const lower3 = name3.toLowerCase();
|
|
33240
33329
|
for (let s = 0; s < sheets.length; s++) {
|
|
33241
|
-
const
|
|
33330
|
+
const table5 = sheets[s]?.tables.find(
|
|
33242
33331
|
(t) => t.displayName.toLowerCase() === lower3 || t.name.toLowerCase() === lower3
|
|
33243
33332
|
);
|
|
33244
|
-
if (
|
|
33333
|
+
if (table5) return { table: table5, sheet: s };
|
|
33245
33334
|
}
|
|
33246
33335
|
return void 0;
|
|
33247
33336
|
}
|
|
33248
|
-
const
|
|
33337
|
+
const table4 = sheets[sheet]?.tables.find(
|
|
33249
33338
|
(t) => row3 >= t.range.start.row && row3 <= t.range.end.row && col >= t.range.start.col && col <= t.range.end.col
|
|
33250
33339
|
);
|
|
33251
|
-
return
|
|
33340
|
+
return table4 ? { table: table4, sheet } : void 0;
|
|
33252
33341
|
}
|
|
33253
33342
|
function resolveStructured(ref, frame2) {
|
|
33254
33343
|
const found = findTable(frame2.host, ref.table, frame2.sheet, frame2.row, frame2.col);
|
|
33255
33344
|
if (!found) return ref.table ? ERR.NAME : ERR.REF;
|
|
33256
|
-
const { table:
|
|
33257
|
-
const range2 = normalizeRange(
|
|
33258
|
-
const headerRow =
|
|
33259
|
-
const dataStart = range2.start.row + (
|
|
33260
|
-
const dataEnd = range2.end.row - (
|
|
33261
|
-
const totalsRow =
|
|
33345
|
+
const { table: table4, sheet } = found;
|
|
33346
|
+
const range2 = normalizeRange(table4.range);
|
|
33347
|
+
const headerRow = table4.headerRow ? range2.start.row : -1;
|
|
33348
|
+
const dataStart = range2.start.row + (table4.headerRow ? 1 : 0);
|
|
33349
|
+
const dataEnd = range2.end.row - (table4.totalsRow ? 1 : 0);
|
|
33350
|
+
const totalsRow = table4.totalsRow ? range2.end.row : -1;
|
|
33262
33351
|
const columnOf = (name3) => {
|
|
33263
33352
|
const lower3 = name3.toLowerCase();
|
|
33264
|
-
const index3 =
|
|
33353
|
+
const index3 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === lower3);
|
|
33265
33354
|
return index3 < 0 ? -1 : range2.start.col + index3;
|
|
33266
33355
|
};
|
|
33267
33356
|
let c1 = range2.start.col;
|
|
@@ -34573,16 +34662,16 @@ function lookupArray(value2) {
|
|
|
34573
34662
|
}
|
|
34574
34663
|
function vhlookup(args, ctx, vertical2) {
|
|
34575
34664
|
const lookup2 = blankAsZero(args);
|
|
34576
|
-
const
|
|
34665
|
+
const table4 = lookupArray(args[1] ?? null);
|
|
34577
34666
|
const index3 = int3(args[2]);
|
|
34578
34667
|
const approximate2 = args.length < 4 ? true : bool(args[3]);
|
|
34579
|
-
const { rows, cols } = shape(
|
|
34668
|
+
const { rows, cols } = shape(table4);
|
|
34580
34669
|
if (index3 < 1) fail(ERR.VALUE);
|
|
34581
34670
|
if (index3 > (vertical2 ? cols : rows)) fail(ERR.REF);
|
|
34582
|
-
const keys = line2(ctx,
|
|
34671
|
+
const keys = line2(ctx, table4, vertical2 ? "col" : "row", 0);
|
|
34583
34672
|
const at2 = approximate2 ? findAscending(keys, lookup2) : findExact(keys, lookup2, true);
|
|
34584
34673
|
if (at2 < 0) fail(ERR.NA);
|
|
34585
|
-
return vertical2 ? cellOf(
|
|
34674
|
+
return vertical2 ? cellOf(table4, at2, index3 - 1) : cellOf(table4, index3 - 1, at2);
|
|
34586
34675
|
}
|
|
34587
34676
|
function match(args, ctx) {
|
|
34588
34677
|
const lookup2 = blankAsZero(args);
|
|
@@ -36026,10 +36115,10 @@ var REGRESSION_FUNCTIONS = [
|
|
|
36026
36115
|
const lay = logs(layout2(ctx, args));
|
|
36027
36116
|
const fit3 = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
|
|
36028
36117
|
const stats = !omitted(args, 3) && bool(args[3]);
|
|
36029
|
-
const
|
|
36030
|
-
if (!stats) return
|
|
36118
|
+
const table4 = coefficientTable(fit3, stats, Math.exp);
|
|
36119
|
+
if (!stats) return table4;
|
|
36031
36120
|
const plain5 = coefficientTable(fit3, true, (v) => v).data;
|
|
36032
|
-
return new Matrix([
|
|
36121
|
+
return new Matrix([table4.data[0] ?? [], ...plain5.slice(1)]);
|
|
36033
36122
|
},
|
|
36034
36123
|
ARGS
|
|
36035
36124
|
),
|
|
@@ -38415,7 +38504,7 @@ function headerMode(args, i2, ctx, firstRow) {
|
|
|
38415
38504
|
if (mode === 1 || mode === 3) return true;
|
|
38416
38505
|
return fail(ERR.VALUE);
|
|
38417
38506
|
}
|
|
38418
|
-
var
|
|
38507
|
+
var keyOf2 = (values2) => JSON.stringify(values2);
|
|
38419
38508
|
var plain2 = (v) => v === void 0 || isError(v) ? null : v;
|
|
38420
38509
|
function compareBy(keys, rows) {
|
|
38421
38510
|
return (a2, b) => {
|
|
@@ -38455,12 +38544,12 @@ function groupby(args, ctx) {
|
|
|
38455
38544
|
if (rows.length === 0) fail(ERR.CALC);
|
|
38456
38545
|
const groups = /* @__PURE__ */ new Map();
|
|
38457
38546
|
for (const r of rows) {
|
|
38458
|
-
const key2 =
|
|
38547
|
+
const key2 = keyOf2(keysM.data[r]);
|
|
38459
38548
|
const found = groups.get(key2);
|
|
38460
38549
|
if (found) found.push(r);
|
|
38461
38550
|
else groups.set(key2, [r]);
|
|
38462
38551
|
}
|
|
38463
|
-
const
|
|
38552
|
+
const table4 = [...groups.values()].map((members3) => {
|
|
38464
38553
|
const key2 = keysM.data[members3[0]];
|
|
38465
38554
|
const cells3 = Array.from(
|
|
38466
38555
|
{ length: vCols },
|
|
@@ -38472,8 +38561,8 @@ function groupby(args, ctx) {
|
|
|
38472
38561
|
return [...key2, ...cells3];
|
|
38473
38562
|
});
|
|
38474
38563
|
for (const key2 of sort2) if (Math.abs(key2) > kCols + vCols) fail(ERR.VALUE);
|
|
38475
|
-
const order =
|
|
38476
|
-
const out = order.map((i2) =>
|
|
38564
|
+
const order = table4.map((_, i2) => i2).sort(compareBy(sort2, table4));
|
|
38565
|
+
const out = order.map((i2) => table4[i2]);
|
|
38477
38566
|
if (depth !== 0) {
|
|
38478
38567
|
const total2 = [
|
|
38479
38568
|
"Total",
|
|
@@ -38522,8 +38611,8 @@ function pivotby(args, ctx) {
|
|
|
38522
38611
|
const colKeys = /* @__PURE__ */ new Map();
|
|
38523
38612
|
for (const r of used) {
|
|
38524
38613
|
for (const [map, key2] of [
|
|
38525
|
-
[rowKeys,
|
|
38526
|
-
[colKeys,
|
|
38614
|
+
[rowKeys, keyOf2(rowsM.data[r])],
|
|
38615
|
+
[colKeys, keyOf2(colsM.data[r])]
|
|
38527
38616
|
]) {
|
|
38528
38617
|
const found = map.get(key2);
|
|
38529
38618
|
if (found) found.push(r);
|
|
@@ -39256,8 +39345,8 @@ function resolveName(node3, frame2) {
|
|
|
39256
39345
|
const value2 = evaluateDefinedName(node3.name, sheet, node3.prefix !== void 0, frame2);
|
|
39257
39346
|
if (value2 !== void 0) return value2;
|
|
39258
39347
|
if (!node3.prefix) {
|
|
39259
|
-
const
|
|
39260
|
-
if (!(isError(
|
|
39348
|
+
const table4 = resolveStructured({ table: node3.name, specials: [] }, frame2);
|
|
39349
|
+
if (!(isError(table4) && table4.error === "#NAME?")) return table4;
|
|
39261
39350
|
}
|
|
39262
39351
|
return ERR.NAME;
|
|
39263
39352
|
}
|
|
@@ -40907,8 +40996,8 @@ function deleteSheetInFormula(formula, sheetName, tableNames = []) {
|
|
|
40907
40996
|
for (const token of tokens3) {
|
|
40908
40997
|
const prefix3 = token.prefix;
|
|
40909
40998
|
const onSheet = prefix3 !== void 0 && prefix3.book === void 0 && prefix3.sheet2 === void 0 && same5(prefix3.sheet, sheetName);
|
|
40910
|
-
const
|
|
40911
|
-
if ((token.kind === "ref" || token.kind === "name") && onSheet ||
|
|
40999
|
+
const table4 = typeof token.value === "string" && tables.has(token.value.toLowerCase()) && (token.kind === "structured" || token.kind === "name" && !prefix3);
|
|
41000
|
+
if ((token.kind === "ref" || token.kind === "name") && onSheet || table4) {
|
|
40912
41001
|
token.text = "#REF!";
|
|
40913
41002
|
changed = true;
|
|
40914
41003
|
}
|
|
@@ -40971,11 +41060,11 @@ function renameTableColumnInFormula(formula, tableName, oldName, newName, inside
|
|
|
40971
41060
|
// xlsx/formula/structured-to-a1.ts
|
|
40972
41061
|
var abs = (row3, col, rowAbs = true) => `$${columnLabel(col)}${rowAbs ? "$" : ""}${row3 + 1}`;
|
|
40973
41062
|
function a1For(ref, t) {
|
|
40974
|
-
const { table:
|
|
40975
|
-
const { start, end } =
|
|
41063
|
+
const { table: table4 } = t;
|
|
41064
|
+
const { start, end } = table4.range;
|
|
40976
41065
|
const index3 = (name3) => {
|
|
40977
41066
|
if (name3 === void 0) return void 0;
|
|
40978
|
-
const i2 =
|
|
41067
|
+
const i2 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === name3.toLowerCase());
|
|
40979
41068
|
return i2 < 0 ? -1 : start.col + i2;
|
|
40980
41069
|
};
|
|
40981
41070
|
const c1 = index3(ref.column);
|
|
@@ -40983,10 +41072,10 @@ function a1For(ref, t) {
|
|
|
40983
41072
|
if (c1 === -1 || c2 === -1) return "#REF!";
|
|
40984
41073
|
const colLo = c1 ?? start.col;
|
|
40985
41074
|
const colHi = c2 ?? end.col;
|
|
40986
|
-
const headerRow =
|
|
40987
|
-
const totalsRow =
|
|
40988
|
-
const dataLo = start.row + (
|
|
40989
|
-
const dataHi = end.row - (
|
|
41075
|
+
const headerRow = table4.headerRow ? start.row : void 0;
|
|
41076
|
+
const totalsRow = table4.totalsRow ? end.row : void 0;
|
|
41077
|
+
const dataLo = start.row + (table4.headerRow ? 1 : 0);
|
|
41078
|
+
const dataHi = end.row - (table4.totalsRow ? 1 : 0);
|
|
40990
41079
|
const specials = new Set(ref.specials);
|
|
40991
41080
|
let rowLo;
|
|
40992
41081
|
let rowHi;
|
|
@@ -42419,8 +42508,8 @@ function sheetDataXml(ctx, sheet) {
|
|
|
42419
42508
|
].sort((a2, b) => a2 - b);
|
|
42420
42509
|
const spills = new SpillPlan(sheet);
|
|
42421
42510
|
const tables = /* @__PURE__ */ new Map();
|
|
42422
|
-
for (const
|
|
42423
|
-
tables.set(`${
|
|
42511
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
42512
|
+
tables.set(`${table4.ref.start.row}:${table4.ref.start.col}`, table4);
|
|
42424
42513
|
let out = "";
|
|
42425
42514
|
for (const row3 of rows) {
|
|
42426
42515
|
const cells3 = sheet.rows.get(row3);
|
|
@@ -42902,29 +42991,29 @@ function setChildText(doc, parent, local, text8, before) {
|
|
|
42902
42991
|
node3.textContent = text8;
|
|
42903
42992
|
if (!existing) insertBefore(parent, node3, before);
|
|
42904
42993
|
}
|
|
42905
|
-
function tableFilterRange(
|
|
42994
|
+
function tableFilterRange(table4) {
|
|
42906
42995
|
return {
|
|
42907
|
-
start:
|
|
42908
|
-
end: { ...
|
|
42996
|
+
start: table4.range.start,
|
|
42997
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
42909
42998
|
};
|
|
42910
42999
|
}
|
|
42911
|
-
function sourceColumnsForPatch(root,
|
|
43000
|
+
function sourceColumnsForPatch(root, table4, names) {
|
|
42912
43001
|
const list2 = xKid(root, "tableColumns");
|
|
42913
43002
|
const source2 = list2 ? xKids(list2, "tableColumn") : [];
|
|
42914
43003
|
const byId2 = new Map(source2.map((c2) => [Number(c2.getAttribute("id")), c2]));
|
|
42915
43004
|
const byName2 = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
42916
|
-
const tracked =
|
|
43005
|
+
const tracked = table4.partName !== void 0 || table4.columns.some((c2) => c2.sourceId !== void 0);
|
|
42917
43006
|
const used = /* @__PURE__ */ new Set();
|
|
42918
43007
|
return names.map((name3, index3) => {
|
|
42919
|
-
const id3 =
|
|
43008
|
+
const id3 = table4.columns[index3]?.sourceId;
|
|
42920
43009
|
const match2 = id3 !== void 0 ? byId2.get(id3) : tracked ? void 0 : source2.length === names.length ? source2[index3] : byName2.get(name3.toLowerCase());
|
|
42921
43010
|
if (!match2 || used.has(match2)) return void 0;
|
|
42922
43011
|
used.add(match2);
|
|
42923
43012
|
return match2;
|
|
42924
43013
|
});
|
|
42925
43014
|
}
|
|
42926
|
-
function syncColumnFilters(doc, filter2,
|
|
42927
|
-
|
|
43015
|
+
function syncColumnFilters(doc, filter2, table4) {
|
|
43016
|
+
table4.columns.forEach((column2, index3) => {
|
|
42928
43017
|
const node3 = xKids(filter2, "filterColumn").find(
|
|
42929
43018
|
(n) => Number(n.getAttribute("colId")) === index3
|
|
42930
43019
|
);
|
|
@@ -42946,29 +43035,29 @@ function syncColumnFilters(doc, filter2, table3) {
|
|
|
42946
43035
|
}
|
|
42947
43036
|
});
|
|
42948
43037
|
}
|
|
42949
|
-
function patchAutoFilter(doc, root,
|
|
43038
|
+
function patchAutoFilter(doc, root, table4, before, names) {
|
|
42950
43039
|
const existing = xKid(root, "autoFilter");
|
|
42951
|
-
if (!
|
|
43040
|
+
if (!table4.headerRow) {
|
|
42952
43041
|
if (existing) root.removeChild(existing);
|
|
42953
43042
|
return;
|
|
42954
43043
|
}
|
|
42955
43044
|
const filter2 = existing ?? doc.createElementNS(NS.x, "autoFilter");
|
|
42956
|
-
const range2 = tableFilterRange(
|
|
43045
|
+
const range2 = tableFilterRange(table4);
|
|
42957
43046
|
filter2.setAttribute("ref", formatRange(range2));
|
|
42958
43047
|
const list2 = xKid(root, "tableColumns");
|
|
42959
43048
|
const original = list2 ? xKids(list2, "tableColumn") : [];
|
|
42960
|
-
const current = new Map(sourceColumnsForPatch(root,
|
|
43049
|
+
const current = new Map(sourceColumnsForPatch(root, table4, names).map((c2, index3) => [c2, index3]));
|
|
42961
43050
|
for (const column2 of xKids(filter2, "filterColumn")) {
|
|
42962
43051
|
const old = original[Number(column2.getAttribute("colId") ?? "0")];
|
|
42963
43052
|
const index3 = old ? current.get(old) : void 0;
|
|
42964
43053
|
if (index3 === void 0) filter2.removeChild(column2);
|
|
42965
43054
|
else column2.setAttribute("colId", num(index3));
|
|
42966
43055
|
}
|
|
42967
|
-
syncColumnFilters(doc, filter2,
|
|
43056
|
+
syncColumnFilters(doc, filter2, table4);
|
|
42968
43057
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
42969
43058
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
42970
43059
|
if (!sort2) return;
|
|
42971
|
-
const moved = before.start.row !==
|
|
43060
|
+
const moved = before.start.row !== table4.range.start.row || before.start.col !== table4.range.start.col || before.end.col !== table4.range.end.col;
|
|
42972
43061
|
if (moved) {
|
|
42973
43062
|
sort2.parentNode?.removeChild(sort2);
|
|
42974
43063
|
return;
|
|
@@ -42990,7 +43079,7 @@ function patchAutoFilter(doc, root, table3, before, names) {
|
|
|
42990
43079
|
}
|
|
42991
43080
|
}
|
|
42992
43081
|
var COLUMN_CHILD_ORDER = ["calculatedColumnFormula", "totalsRowFormula", "xmlColumnPr", "extLst"];
|
|
42993
|
-
function patchColumns(doc, root, sheet,
|
|
43082
|
+
function patchColumns(doc, root, sheet, table4, names) {
|
|
42994
43083
|
let list2 = xKid(root, "tableColumns");
|
|
42995
43084
|
if (!list2) {
|
|
42996
43085
|
list2 = doc.createElementNS(NS.x, "tableColumns");
|
|
@@ -42998,7 +43087,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42998
43087
|
}
|
|
42999
43088
|
const sourceColumns = xKids(list2, "tableColumn");
|
|
43000
43089
|
const ids = /* @__PURE__ */ new Set();
|
|
43001
|
-
const picked = sourceColumnsForPatch(root,
|
|
43090
|
+
const picked = sourceColumnsForPatch(root, table4, names).map((match2) => {
|
|
43002
43091
|
if (!match2) return void 0;
|
|
43003
43092
|
const id3 = Number(match2.getAttribute("id"));
|
|
43004
43093
|
if (Number.isInteger(id3) && id3 >= 0 && !ids.has(id3)) ids.add(id3);
|
|
@@ -43007,15 +43096,15 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
43007
43096
|
});
|
|
43008
43097
|
for (const column2 of sourceColumns) list2.removeChild(column2);
|
|
43009
43098
|
let nextId3 = Math.max(0, ...ids) + 1;
|
|
43010
|
-
const totalsRow =
|
|
43099
|
+
const totalsRow = table4.range.end.row;
|
|
43011
43100
|
names.forEach((name3, index3) => {
|
|
43012
43101
|
const column2 = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
43013
43102
|
if (!column2.getAttribute("id")) column2.setAttribute("id", num(nextId3++));
|
|
43014
43103
|
column2.setAttribute("name", name3);
|
|
43015
|
-
const model =
|
|
43016
|
-
const fn =
|
|
43104
|
+
const model = table4.columns[index3];
|
|
43105
|
+
const fn = table4.totalsRow ? model?.totalsRowFunction : void 0;
|
|
43017
43106
|
setOrRemove(column2, "totalsRowFunction", fn);
|
|
43018
|
-
setOrRemove(column2, "totalsRowLabel",
|
|
43107
|
+
setOrRemove(column2, "totalsRowLabel", table4.totalsRow ? model?.totalsRowLabel : void 0);
|
|
43019
43108
|
const calculated = model?.calculatedColumnFormula;
|
|
43020
43109
|
setChildText(
|
|
43021
43110
|
doc,
|
|
@@ -43026,7 +43115,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
43026
43115
|
);
|
|
43027
43116
|
if (fn !== "custom") setChildText(doc, column2, "totalsRowFormula", void 0, []);
|
|
43028
43117
|
else {
|
|
43029
|
-
const cellFormula = sheet.rows.get(totalsRow)?.get(
|
|
43118
|
+
const cellFormula = sheet.rows.get(totalsRow)?.get(table4.range.start.col + index3)?.formula;
|
|
43030
43119
|
if (cellFormula)
|
|
43031
43120
|
setChildText(
|
|
43032
43121
|
doc,
|
|
@@ -43040,19 +43129,19 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
43040
43129
|
});
|
|
43041
43130
|
list2.setAttribute("count", num(names.length));
|
|
43042
43131
|
}
|
|
43043
|
-
function patchStyleInfo(doc, root,
|
|
43132
|
+
function patchStyleInfo(doc, root, table4) {
|
|
43044
43133
|
let info = xKid(root, "tableStyleInfo");
|
|
43045
43134
|
if (!info) {
|
|
43046
43135
|
info = doc.createElementNS(NS.x, "tableStyleInfo");
|
|
43047
43136
|
insertBefore(root, info, ["extLst"]);
|
|
43048
43137
|
}
|
|
43049
|
-
setOrRemove(info, "name",
|
|
43050
|
-
info.setAttribute("showFirstColumn", flag2(
|
|
43051
|
-
info.setAttribute("showLastColumn", flag2(
|
|
43052
|
-
info.setAttribute("showRowStripes", flag2(
|
|
43053
|
-
info.setAttribute("showColumnStripes", flag2(
|
|
43138
|
+
setOrRemove(info, "name", table4.styleName);
|
|
43139
|
+
info.setAttribute("showFirstColumn", flag2(table4.showFirstColumn, false));
|
|
43140
|
+
info.setAttribute("showLastColumn", flag2(table4.showLastColumn, false));
|
|
43141
|
+
info.setAttribute("showRowStripes", flag2(table4.showRowStripes, true));
|
|
43142
|
+
info.setAttribute("showColumnStripes", flag2(table4.showColumnStripes, false));
|
|
43054
43143
|
}
|
|
43055
|
-
function patchTableXml(sourceXml, sheet,
|
|
43144
|
+
function patchTableXml(sourceXml, sheet, table4, id3, names) {
|
|
43056
43145
|
let doc;
|
|
43057
43146
|
try {
|
|
43058
43147
|
doc = parseXml(sourceXml, { label: "XLSX table" });
|
|
@@ -43061,80 +43150,80 @@ function patchTableXml(sourceXml, sheet, table3, id3, names) {
|
|
|
43061
43150
|
}
|
|
43062
43151
|
const root = doc.documentElement;
|
|
43063
43152
|
if (root.localName !== "table") return void 0;
|
|
43064
|
-
const before = parseRange(root.getAttribute("ref") ?? "") ??
|
|
43153
|
+
const before = parseRange(root.getAttribute("ref") ?? "") ?? table4.range;
|
|
43065
43154
|
root.setAttribute("id", num(id3));
|
|
43066
|
-
root.setAttribute("name",
|
|
43067
|
-
root.setAttribute("displayName",
|
|
43068
|
-
root.setAttribute("ref", formatRange(
|
|
43069
|
-
setOrRemove(root, "headerRowCount",
|
|
43070
|
-
if (
|
|
43155
|
+
root.setAttribute("name", table4.name);
|
|
43156
|
+
root.setAttribute("displayName", table4.displayName || table4.name);
|
|
43157
|
+
root.setAttribute("ref", formatRange(table4.range));
|
|
43158
|
+
setOrRemove(root, "headerRowCount", table4.headerRow ? void 0 : "0");
|
|
43159
|
+
if (table4.totalsRow) {
|
|
43071
43160
|
root.setAttribute("totalsRowCount", "1");
|
|
43072
43161
|
root.removeAttribute("totalsRowShown");
|
|
43073
43162
|
} else {
|
|
43074
43163
|
root.removeAttribute("totalsRowCount");
|
|
43075
43164
|
if (!root.hasAttribute("totalsRowShown")) root.setAttribute("totalsRowShown", "0");
|
|
43076
43165
|
}
|
|
43077
|
-
patchAutoFilter(doc, root,
|
|
43078
|
-
patchColumns(doc, root, sheet,
|
|
43079
|
-
patchStyleInfo(doc, root,
|
|
43166
|
+
patchAutoFilter(doc, root, table4, before, names);
|
|
43167
|
+
patchColumns(doc, root, sheet, table4, names);
|
|
43168
|
+
patchStyleInfo(doc, root, table4);
|
|
43080
43169
|
return buildXml(doc);
|
|
43081
43170
|
}
|
|
43082
43171
|
|
|
43083
43172
|
// xlsx/write/tables.ts
|
|
43084
43173
|
var headerTextOf = (value2) => typeof value2 === "string" ? value2 : typeof value2 === "number" || typeof value2 === "boolean" ? String(value2).toUpperCase() : void 0;
|
|
43085
|
-
function resolveTableColumns(sheet,
|
|
43174
|
+
function resolveTableColumns(sheet, table4) {
|
|
43086
43175
|
const headerText = /* @__PURE__ */ new Map();
|
|
43087
43176
|
const used = /* @__PURE__ */ new Set();
|
|
43088
|
-
const width =
|
|
43177
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
43089
43178
|
const names = [];
|
|
43090
43179
|
for (let i2 = 0; i2 < width; i2++) {
|
|
43091
|
-
const col =
|
|
43092
|
-
const row3 =
|
|
43093
|
-
const fromCell =
|
|
43094
|
-
let name3 = (fromCell?.trim() ? fromCell : void 0) ??
|
|
43180
|
+
const col = table4.range.start.col + i2;
|
|
43181
|
+
const row3 = table4.range.start.row;
|
|
43182
|
+
const fromCell = table4.headerRow ? headerTextOf(sheet.rows.get(row3)?.get(col)?.value) : void 0;
|
|
43183
|
+
let name3 = (fromCell?.trim() ? fromCell : void 0) ?? table4.columns[i2]?.name ?? `Column${i2 + 1}`;
|
|
43095
43184
|
if (!name3.trim()) name3 = `Column${i2 + 1}`;
|
|
43096
43185
|
let unique4 = name3;
|
|
43097
43186
|
for (let n = 2; used.has(unique4.toLowerCase()); n++) unique4 = `${name3}${n}`;
|
|
43098
43187
|
used.add(unique4.toLowerCase());
|
|
43099
43188
|
names.push(unique4);
|
|
43100
43189
|
const cell = sheet.rows.get(row3)?.get(col);
|
|
43101
|
-
if (
|
|
43190
|
+
if (table4.headerRow && (typeof cell?.value !== "string" || cell.value !== unique4))
|
|
43102
43191
|
headerText.set(`${row3}:${col}`, unique4);
|
|
43103
43192
|
}
|
|
43104
43193
|
return { names, headerText };
|
|
43105
43194
|
}
|
|
43106
|
-
function tableXml(
|
|
43107
|
-
const range2 = formatRange(
|
|
43108
|
-
const filterEnd = { ...
|
|
43109
|
-
const criteria =
|
|
43110
|
-
const filterRef = formatRange({ start:
|
|
43111
|
-
const filter2 =
|
|
43195
|
+
function tableXml(table4, id3, names) {
|
|
43196
|
+
const range2 = formatRange(table4.range);
|
|
43197
|
+
const filterEnd = { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) };
|
|
43198
|
+
const criteria = table4.columns.map((column2, index3) => column2.filter ? filterColumnXml(index3, column2.filter) : "").join("");
|
|
43199
|
+
const filterRef = formatRange({ start: table4.range.start, end: filterEnd });
|
|
43200
|
+
const filter2 = table4.headerRow ? criteria ? `<autoFilter ref="${filterRef}">${criteria}</autoFilter>` : `<autoFilter ref="${filterRef}"/>` : "";
|
|
43112
43201
|
const columns = names.map((name3, index3) => {
|
|
43113
|
-
const column2 =
|
|
43202
|
+
const column2 = table4.columns[index3];
|
|
43114
43203
|
const calculated = column2?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText3(addFuturePrefixes(column2.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
43115
43204
|
const values2 = attrs2({
|
|
43116
43205
|
id: index3 + 1,
|
|
43117
43206
|
name: name3,
|
|
43118
|
-
totalsRowFunction:
|
|
43119
|
-
totalsRowLabel:
|
|
43207
|
+
totalsRowFunction: table4.totalsRow ? column2?.totalsRowFunction : void 0,
|
|
43208
|
+
totalsRowLabel: table4.totalsRow ? column2?.totalsRowLabel : void 0
|
|
43120
43209
|
});
|
|
43121
43210
|
return calculated ? `<tableColumn${values2}>${calculated}</tableColumn>` : `<tableColumn${values2}/>`;
|
|
43122
43211
|
}).join("");
|
|
43123
43212
|
const style3 = attrs2({
|
|
43124
|
-
name:
|
|
43125
|
-
showFirstColumn:
|
|
43126
|
-
showLastColumn:
|
|
43127
|
-
showRowStripes:
|
|
43128
|
-
showColumnStripes:
|
|
43213
|
+
name: table4.styleName,
|
|
43214
|
+
showFirstColumn: table4.showFirstColumn ?? false,
|
|
43215
|
+
showLastColumn: table4.showLastColumn ?? false,
|
|
43216
|
+
showRowStripes: table4.showRowStripes ?? true,
|
|
43217
|
+
showColumnStripes: table4.showColumnStripes ?? false
|
|
43129
43218
|
});
|
|
43130
43219
|
const head = attrs2({
|
|
43131
43220
|
id: id3,
|
|
43132
|
-
name:
|
|
43133
|
-
displayName:
|
|
43221
|
+
name: table4.name,
|
|
43222
|
+
displayName: table4.displayName || table4.name,
|
|
43134
43223
|
ref: range2,
|
|
43135
|
-
headerRowCount:
|
|
43136
|
-
totalsRowCount:
|
|
43137
|
-
totalsRowShown:
|
|
43224
|
+
headerRowCount: table4.headerRow ? void 0 : 0,
|
|
43225
|
+
totalsRowCount: table4.totalsRow ? 1 : void 0,
|
|
43226
|
+
totalsRowShown: table4.totalsRow ? void 0 : false
|
|
43138
43227
|
});
|
|
43139
43228
|
return `${XML_HEADER}<table xmlns="${NS.x}"${head}>${filter2}<tableColumns count="${names.length}">${columns}</tableColumns><tableStyleInfo${style3}/></table>`;
|
|
43140
43229
|
}
|
|
@@ -43148,24 +43237,24 @@ var SUBTOTAL_CODES = {
|
|
|
43148
43237
|
sum: 109,
|
|
43149
43238
|
var: 110
|
|
43150
43239
|
};
|
|
43151
|
-
function totalsRowFormulas(sheet,
|
|
43240
|
+
function totalsRowFormulas(sheet, table4, names) {
|
|
43152
43241
|
const out = /* @__PURE__ */ new Map();
|
|
43153
|
-
if (!
|
|
43154
|
-
const row3 =
|
|
43242
|
+
if (!table4.totalsRow) return out;
|
|
43243
|
+
const row3 = table4.range.end.row;
|
|
43155
43244
|
names.forEach((name3, index3) => {
|
|
43156
|
-
const code = SUBTOTAL_CODES[
|
|
43245
|
+
const code = SUBTOTAL_CODES[table4.columns[index3]?.totalsRowFunction ?? ""];
|
|
43157
43246
|
if (code === void 0) return;
|
|
43158
|
-
const col =
|
|
43247
|
+
const col = table4.range.start.col + index3;
|
|
43159
43248
|
const escaped = name3.replace(/['#[\]]/g, "'$&");
|
|
43160
|
-
const formula = `SUBTOTAL(${code},${
|
|
43249
|
+
const formula = `SUBTOTAL(${code},${table4.displayName || table4.name}[${escaped}])`;
|
|
43161
43250
|
if (sheet.rows.get(row3)?.get(col)?.formula !== formula) out.set(`${row3}:${col}`, formula);
|
|
43162
43251
|
});
|
|
43163
43252
|
return out;
|
|
43164
43253
|
}
|
|
43165
|
-
function resolveTableNames(
|
|
43166
|
-
const display =
|
|
43254
|
+
function resolveTableNames(table4, before, index3) {
|
|
43255
|
+
const display = table4.displayName || table4.name;
|
|
43167
43256
|
const displayName = before && before.displayName === display ? display : safeTableName(display, index3);
|
|
43168
|
-
const name3 = before && before.name ===
|
|
43257
|
+
const name3 = before && before.name === table4.name ? table4.name : table4.name === display ? displayName : safeTableName(table4.name, index3);
|
|
43169
43258
|
return { name: name3, displayName };
|
|
43170
43259
|
}
|
|
43171
43260
|
function safeTableName(name3, index3) {
|
|
@@ -43258,21 +43347,21 @@ function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
|
43258
43347
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
43259
43348
|
const before = sourceXml && original.partName ? parseTable3(sourceXml, original.partName) : void 0;
|
|
43260
43349
|
const { name: name3, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
43261
|
-
const
|
|
43262
|
-
const { names, headerText: forced } = resolveTableColumns(sheet,
|
|
43350
|
+
const table4 = name3 === original.name && displayName === original.displayName ? original : { ...original, name: name3, displayName };
|
|
43351
|
+
const { names, headerText: forced } = resolveTableColumns(sheet, table4);
|
|
43263
43352
|
for (const [key2, text8] of forced) headerText.set(key2, text8);
|
|
43264
|
-
const totals = totalsRowFormulas(sheet,
|
|
43353
|
+
const totals = totalsRowFormulas(sheet, table4, names);
|
|
43265
43354
|
for (const [key2, formula] of totals) formulas.set(key2, formula);
|
|
43266
|
-
let id3 =
|
|
43267
|
-
const unchanged =
|
|
43355
|
+
let id3 = table4.id;
|
|
43356
|
+
const unchanged = table4.partName && sourceXml && !writer.has(table4.partName) && !ctx.tableIds.has(id3) && forced.size === 0 && totals.size === 0 && table4 === original && sameModel(before, table4);
|
|
43268
43357
|
let part;
|
|
43269
|
-
if (unchanged &&
|
|
43270
|
-
part =
|
|
43358
|
+
if (unchanged && table4.partName) {
|
|
43359
|
+
part = table4.partName;
|
|
43271
43360
|
writer.carry(part);
|
|
43272
43361
|
} else {
|
|
43273
43362
|
while (ctx.tableIds.has(id3) || id3 < 1) id3++;
|
|
43274
|
-
part =
|
|
43275
|
-
const xml = (sourceXml && patchTableXml(sourceXml, sheet,
|
|
43363
|
+
part = table4.partName && !writer.has(table4.partName) ? table4.partName : writer.uniqueName((n) => `xl/tables/table${n}.xml`, ctx.reserved);
|
|
43364
|
+
const xml = (sourceXml && patchTableXml(sourceXml, sheet, table4, id3, names)) ?? tableXml(table4, id3, names);
|
|
43276
43365
|
writer.add(part, xml, CONTENT_TYPES.table);
|
|
43277
43366
|
}
|
|
43278
43367
|
ctx.tableIds.add(id3);
|
|
@@ -43715,15 +43804,15 @@ function derivedFields(pivot, date1904) {
|
|
|
43715
43804
|
function derivedFieldXml(pivot, entry3, date1904) {
|
|
43716
43805
|
const range2 = { start: entry3.group.start, end: entry3.group.end };
|
|
43717
43806
|
const days = dateGroupDays(entry3.group);
|
|
43718
|
-
const labels = dateUnitLabels(entry3.unit, range2, days, date1904);
|
|
43807
|
+
const labels = dateUnitLabels(entry3.unit, range2, days, date1904, entry3.group);
|
|
43719
43808
|
const base2 = pivot.fields.indexOf(entry3.group.field);
|
|
43720
|
-
return `<cacheField${attrs2({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base2}"><rangePr${attrs2({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range2.start, date1904), endDate: serialToIso(range2.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((
|
|
43809
|
+
return `<cacheField${attrs2({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base2}"><rangePr${attrs2({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range2.start, date1904), endDate: serialToIso(range2.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup></cacheField>`;
|
|
43721
43810
|
}
|
|
43722
43811
|
function groupXml2(pivot, name3, index3) {
|
|
43723
43812
|
const group = groupOf(pivot, name3);
|
|
43724
43813
|
if (!group) return "";
|
|
43725
43814
|
const labels = numberGroupLabels(group);
|
|
43726
|
-
return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((
|
|
43815
|
+
return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup>`;
|
|
43727
43816
|
}
|
|
43728
43817
|
function slicerExt(pivot) {
|
|
43729
43818
|
if (pivot.slicerCacheId === void 0) return "";
|
|
@@ -43744,8 +43833,6 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43744
43833
|
const pivot = expandDateGroups(source2);
|
|
43745
43834
|
const rowNames = pivotRowFields(pivot);
|
|
43746
43835
|
const rowIdx = rowNames.map((name3) => pivot.fields.indexOf(name3));
|
|
43747
|
-
const row3 = rowIdx[0];
|
|
43748
|
-
const second = rowIdx[1] ?? -1;
|
|
43749
43836
|
const page = pivot.pageFilter ? pivot.fields.indexOf(pivot.pageFilter.field) : -1;
|
|
43750
43837
|
const pageItems = page >= 0 ? pivotItems(pivot, pivot.pageFilter.field) : [];
|
|
43751
43838
|
const filtered2 = filteredFields(pivot);
|
|
@@ -43773,7 +43860,10 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43773
43860
|
const columnIndicesFull = columnNames.map(
|
|
43774
43861
|
(_name, k) => itemIndices(visibleColumns[k], columnItemsFull[k])
|
|
43775
43862
|
);
|
|
43776
|
-
const
|
|
43863
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
43864
|
+
const levelAxes = [...rowIndicesFull];
|
|
43865
|
+
if (valuesAt >= 0) levelAxes.splice(valuesAt, 0, null);
|
|
43866
|
+
const rowEntries = anyFull && grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, levelAxes) : grid.rowEntries;
|
|
43777
43867
|
const pageOffset = page >= 0 ? 2 : 0;
|
|
43778
43868
|
const col = columnIdx[0] ?? -1;
|
|
43779
43869
|
const measures2 = pivotMeasures(pivot);
|
|
@@ -43782,13 +43872,17 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43782
43872
|
const compact3 = pivot.layout === "compact";
|
|
43783
43873
|
const outline2 = pivot.layout === "compact" || pivot.layout === "outline";
|
|
43784
43874
|
const top = (pivot.subtotalPosition ?? (outline2 ? "top" : "bottom")) === "top";
|
|
43875
|
+
const named3 = (field2, item) => {
|
|
43876
|
+
const text8 = pivotItemName(pivot, field2, item);
|
|
43877
|
+
return text8 === void 0 ? "" : attrs2({ n: encodeEscapes(text8) });
|
|
43878
|
+
};
|
|
43785
43879
|
const fields = pivot.fields.map((name3, index3) => {
|
|
43786
43880
|
const isDate = pivot.dateFields?.includes(name3) ?? false;
|
|
43787
43881
|
const at2 = rowIdx.indexOf(index3);
|
|
43788
43882
|
const colAt = columnIdx.indexOf(index3);
|
|
43789
43883
|
const items2 = index3 === page ? pageItems : at2 >= 0 ? rowItemsFull[at2] : colAt >= 0 ? columnItemsFull[colAt] : groupLabelsOf(pivot, name3) ?? (filtered2.has(name3) || isDate ? pivotItems(pivot, name3) : void 0);
|
|
43790
43884
|
const hidden = hiddenItemKeys(pivot, name3);
|
|
43791
|
-
const functions = at2 >= 0 ? fieldSubtotalFunctions(pivot, name3) : "auto";
|
|
43885
|
+
const functions = at2 >= 0 || colAt >= 0 ? fieldSubtotalFunctions(pivot, name3) : "auto";
|
|
43792
43886
|
const automatic = functions === "auto";
|
|
43793
43887
|
const custom = automatic ? [] : functions;
|
|
43794
43888
|
const repeated = pivot.repeatLabels && at2 >= 0 ? `<extLst><ext uri="{2946ED86-A175-432a-8AC1-64E0C546D7DE}"><x14:pivotField xmlns:x14="${X143}" fillDownLabels="1"/></ext></extLst>` : "";
|
|
@@ -43796,37 +43890,27 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43796
43890
|
custom.map((fn) => [PIVOT_SUBTOTALS[fn].attr, true])
|
|
43797
43891
|
);
|
|
43798
43892
|
const entries = automatic ? '<item t="default"/>' : custom.map((fn) => `<item t="${PIVOT_SUBTOTALS[fn].item}"/>`).join("");
|
|
43799
|
-
return `<pivotField${attrs2({ axis: index3 === page ? "axisPage" : at2 >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures2.some((measure2) => pivot.fields.indexOf(measure2.field) === index3) ? true : void 0, compact: compact3, outline: outline2, showAll: false, subtotalTop: at2 >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""} x="${itemX(index3, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
|
|
43893
|
+
return `<pivotField${attrs2({ axis: index3 === page ? "axisPage" : at2 >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures2.some((measure2) => pivot.fields.indexOf(measure2.field) === index3) ? true : void 0, compact: compact3, outline: outline2, showAll: false, subtotalTop: at2 >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""}${named3(name3, item)} x="${itemX(index3, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
|
|
43800
43894
|
}).join("");
|
|
43801
43895
|
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
43802
43896
|
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
43803
|
-
const rowIndices =
|
|
43897
|
+
const rowIndices = [...rowIdx];
|
|
43898
|
+
if (valuesAt >= 0) rowIndices.splice(valuesAt, 0, -2);
|
|
43804
43899
|
let previous = [];
|
|
43805
43900
|
const rowItems = rowEntries?.map((entry3) => {
|
|
43806
43901
|
let prefix3 = 0;
|
|
43807
43902
|
const type = entry3.type === void 0 || entry3.type === "default" || entry3.type === "grand" ? entry3.type : PIVOT_SUBTOTALS[entry3.type].item;
|
|
43808
|
-
if (
|
|
43809
|
-
|
|
43810
|
-
else if (!entry3.type)
|
|
43811
|
-
while (prefix3 < entry3.indices.length - 1 && entry3.indices[prefix3] === previous[prefix3])
|
|
43812
|
-
prefix3++;
|
|
43813
|
-
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
43814
|
-
} else {
|
|
43815
|
-
if (entry3.type !== "grand") prefix3 = sharedPrefix(entry3.indices, previous);
|
|
43816
|
-
previous = entry3.type === "grand" ? [] : entry3.indices;
|
|
43817
|
-
}
|
|
43903
|
+
if (entry3.type !== "grand") prefix3 = sharedPrefix(entry3.indices, previous);
|
|
43904
|
+
previous = entry3.type === "grand" ? [] : entry3.indices;
|
|
43818
43905
|
return `<i${attrs2({ t: type, r: prefix3 || void 0, i: entry3.measure || void 0 })}>${entry3.indices.slice(prefix3).map((index3) => `<x${attrs2({ v: index3 || void 0 })}/>`).join("")}</i>`;
|
|
43819
43906
|
}).join("") ?? items(grid.rowItems.length, rowIndicesFull[0]);
|
|
43820
43907
|
let body = `<location${attrs2({ 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>`;
|
|
43821
|
-
if (
|
|
43822
|
-
const fieldsOnColumns = [...columnIdx, ...multiple ? [-2] : []];
|
|
43823
|
-
body += `<colFields count="${fieldsOnColumns.length}">${fieldsOnColumns.map((index3) => `<field x="${index3}"/>`).join("")}</colFields>${pivotColumnItemsXml(grid.columnEntries, measures2.length, (level, index3) => columnIndicesFull[level][index3])}`;
|
|
43908
|
+
if (col >= 0 && grid.columnEntries) {
|
|
43909
|
+
const fieldsOnColumns = [...columnIdx, ...multiple && !rowsAxis ? [-2] : []];
|
|
43910
|
+
body += `<colFields count="${fieldsOnColumns.length}">${fieldsOnColumns.map((index3) => `<field x="${index3}"/>`).join("")}</colFields>${pivotColumnItemsXml(grid.columnEntries, rowsAxis ? 1 : measures2.length, (level, index3) => columnIndicesFull[level][index3])}`;
|
|
43824
43911
|
} else if (multiple && !rowsAxis)
|
|
43825
43912
|
body += `<colFields count="1"><field x="-2"/></colFields>${pivotValueAxisItems(measures2.length)}`;
|
|
43826
|
-
else
|
|
43827
|
-
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length, columnIndicesFull[0])}</colItems>`;
|
|
43828
|
-
else
|
|
43829
|
-
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : page >= 0 ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
43913
|
+
else body += '<colItems count="1"><i/></colItems>';
|
|
43830
43914
|
if (page >= 0)
|
|
43831
43915
|
body += `<pageFields count="1"><pageField${attrs2({ fld: page, hier: -1, item: pivot.pageFilter.item !== void 0 ? pageItems.findIndex((item) => pivotValueKey(item) === pivotValueKey(pivot.pageFilter.item)) : void 0 })}/></pageFields>`;
|
|
43832
43916
|
body += `<dataFields count="${measures2.length}">${measures2.map((measure2) => `<dataField${attrs2({ name: encodeEscapes(measure2.caption), fld: pivot.fields.indexOf(measure2.field), subtotal: measure2.aggregate, baseField: 0, baseItem: 0 })}/>`).join("")}</dataFields>`;
|
|
@@ -43836,9 +43920,17 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43836
43920
|
const root = doc.documentElement;
|
|
43837
43921
|
root.setAttribute("name", pivot.name);
|
|
43838
43922
|
root.setAttribute("cacheId", String(cacheId));
|
|
43923
|
+
const caps = pivotCaptions(pivot);
|
|
43924
|
+
root.setAttribute("dataCaption", caps.values);
|
|
43925
|
+
for (const [attribute4, key2] of [
|
|
43926
|
+
["rowHeaderCaption", "rowLabels"],
|
|
43927
|
+
["colHeaderCaption", "columnLabels"],
|
|
43928
|
+
["grandTotalCaption", "grandTotal"]
|
|
43929
|
+
])
|
|
43930
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2] || root.hasAttribute(attribute4))
|
|
43931
|
+
root.setAttribute(attribute4, caps[key2]);
|
|
43839
43932
|
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
43840
|
-
if (rowsAxis &&
|
|
43841
|
-
root.setAttribute("dataPosition", pivot.valuesPosition === "first" ? "0" : "1");
|
|
43933
|
+
if (rowsAxis && valuesAt < rowIdx.length) root.setAttribute("dataPosition", String(valuesAt));
|
|
43842
43934
|
else root.removeAttribute("dataPosition");
|
|
43843
43935
|
root.setAttribute("compact", compact3 ? "1" : "0");
|
|
43844
43936
|
root.setAttribute("compactData", compact3 ? "1" : "0");
|
|
@@ -43904,7 +43996,8 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43904
43996
|
}
|
|
43905
43997
|
function dateFilterXml(pivot, filter2) {
|
|
43906
43998
|
const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
43907
|
-
|
|
43999
|
+
const id3 = Number(/<filter [^>]*\bid="(\d+)"/.exec(pivot.sourceXml ?? "")?.[1] ?? 1);
|
|
44000
|
+
return `<filters count="1"><filter${attrs2({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id: id3, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
|
|
43908
44001
|
}
|
|
43909
44002
|
|
|
43910
44003
|
// xlsx/pivot/write.ts
|
|
@@ -43959,7 +44052,7 @@ var PivotWritePlan = class {
|
|
|
43959
44052
|
this.tableParts.set(pivot, pivot.partName);
|
|
43960
44053
|
continue;
|
|
43961
44054
|
}
|
|
43962
|
-
const
|
|
44055
|
+
const table4 = pivot.partName ?? writer.uniqueName((n) => `xl/pivotTables/pivotTable${n}.xml`, reserved);
|
|
43963
44056
|
const definition = writer.uniqueName(
|
|
43964
44057
|
(n) => `xl/pivotCache/pivotCacheDefinition${n}.xml`,
|
|
43965
44058
|
reserved
|
|
@@ -43981,24 +44074,24 @@ var PivotWritePlan = class {
|
|
|
43981
44074
|
TYPES2.definition
|
|
43982
44075
|
);
|
|
43983
44076
|
writer.rels(definition, cacheRels);
|
|
43984
|
-
writer.add(
|
|
44077
|
+
writer.add(table4, pivotTableXml(pivot, cacheId, cache3), TYPES2.table);
|
|
43985
44078
|
const tableRels = new RelationshipSet();
|
|
43986
|
-
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(
|
|
43987
|
-
writer.rels(
|
|
44079
|
+
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(table4, definition));
|
|
44080
|
+
writer.rels(table4, tableRels);
|
|
43988
44081
|
const rid2 = bookRels.add(
|
|
43989
44082
|
RELATIONSHIP_TYPES.pivotCacheDefinition,
|
|
43990
44083
|
relativeTarget(bookPart, definition)
|
|
43991
44084
|
);
|
|
43992
44085
|
entries.push(`<pivotCache cacheId="${cacheId++}" r:id="${rid2}"/>`);
|
|
43993
|
-
this.tableParts.set(pivot,
|
|
44086
|
+
this.tableParts.set(pivot, table4);
|
|
43994
44087
|
}
|
|
43995
44088
|
this.cachesXml = owns ? entries.length ? `<pivotCaches>${entries.join("")}</pivotCaches>` : "" : void 0;
|
|
43996
44089
|
}
|
|
43997
44090
|
writeSheet(writer, sheet, part, rels) {
|
|
43998
44091
|
for (const pivot of sheet.pivotTables ?? []) {
|
|
43999
|
-
const
|
|
44000
|
-
writer.carry(
|
|
44001
|
-
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part,
|
|
44092
|
+
const table4 = this.tableParts.get(pivot);
|
|
44093
|
+
writer.carry(table4);
|
|
44094
|
+
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part, table4));
|
|
44002
44095
|
}
|
|
44003
44096
|
}
|
|
44004
44097
|
};
|
|
@@ -44168,9 +44261,9 @@ function slicerTarget(workbook, cache3) {
|
|
|
44168
44261
|
const source2 = cache3.source;
|
|
44169
44262
|
for (const [sheetIndex2, sheet] of workbook.sheets.entries()) {
|
|
44170
44263
|
if (source2.kind === "table") {
|
|
44171
|
-
const
|
|
44172
|
-
const offset2 =
|
|
44173
|
-
if (
|
|
44264
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === source2.tableId);
|
|
44265
|
+
const offset2 = table4?.columns.findIndex((column2) => column2.sourceId === source2.column) ?? -1;
|
|
44266
|
+
if (table4 && offset2 >= 0) return { kind: "table", sheet, sheetIndex: sheetIndex2, table: table4, offset: offset2 };
|
|
44174
44267
|
} else {
|
|
44175
44268
|
const first3 = source2.pivots[0];
|
|
44176
44269
|
const pivot = first3 && sheet.sheetId === first3.tabId ? sheet.pivotTables?.find((entry3) => entry3.name === first3.name) : void 0;
|
|
@@ -44359,12 +44452,12 @@ function slicerCacheXml(cache3, facts) {
|
|
|
44359
44452
|
ext.setAttribute("xmlns:x15", X153);
|
|
44360
44453
|
list2.appendChild(ext);
|
|
44361
44454
|
}
|
|
44362
|
-
let
|
|
44363
|
-
if (!
|
|
44364
|
-
|
|
44365
|
-
|
|
44366
|
-
if (cache3.sortOrder === "descending")
|
|
44367
|
-
else
|
|
44455
|
+
let table4 = first(ext, "tableSlicerCache", X153);
|
|
44456
|
+
if (!table4) table4 = ext.appendChild(make2(X153, "x15:tableSlicerCache"));
|
|
44457
|
+
table4.setAttribute("tableId", String(source2.tableId));
|
|
44458
|
+
table4.setAttribute("column", String(source2.column));
|
|
44459
|
+
if (cache3.sortOrder === "descending") table4.setAttribute("sortOrder", "descending");
|
|
44460
|
+
else table4.removeAttribute("sortOrder");
|
|
44368
44461
|
return XML_HEADER + buildXml(root);
|
|
44369
44462
|
}
|
|
44370
44463
|
|
|
@@ -44917,12 +45010,12 @@ function rewriteSheetFormulas(sheet, rewrite2, formulaCells) {
|
|
|
44917
45010
|
}
|
|
44918
45011
|
{
|
|
44919
45012
|
const name3 = sheet.name;
|
|
44920
|
-
for (const
|
|
44921
|
-
for (const [index3, column2] of
|
|
45013
|
+
for (const table4 of sheet.tables)
|
|
45014
|
+
for (const [index3, column2] of table4.columns.entries())
|
|
44922
45015
|
if (column2.calculatedColumnFormula !== void 0)
|
|
44923
45016
|
column2.calculatedColumnFormula = safe(rewrite2, column2.calculatedColumnFormula, name3, {
|
|
44924
|
-
row:
|
|
44925
|
-
col:
|
|
45017
|
+
row: table4.range.start.row + (table4.headerRow ? 1 : 0),
|
|
45018
|
+
col: table4.range.start.col + index3
|
|
44926
45019
|
});
|
|
44927
45020
|
if (formulaCells) {
|
|
44928
45021
|
for (const at2 of formulaCells) {
|
|
@@ -44987,14 +45080,14 @@ function tableHeaderAt(sheet, row3, col) {
|
|
|
44987
45080
|
);
|
|
44988
45081
|
}
|
|
44989
45082
|
function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
44990
|
-
const
|
|
44991
|
-
if (!
|
|
44992
|
-
const column2 =
|
|
45083
|
+
const table4 = tableHeaderAt(sheet, row3, col);
|
|
45084
|
+
if (!table4) return;
|
|
45085
|
+
const column2 = table4.columns[col - table4.range.start.col];
|
|
44993
45086
|
if (!column2) return;
|
|
44994
45087
|
const text8 = displayText(ctx.workbook, getCell(sheet, row3, col)).trim();
|
|
44995
45088
|
if (!text8 || column2.name === text8) return;
|
|
44996
45089
|
const oldName = column2.name;
|
|
44997
|
-
const others =
|
|
45090
|
+
const others = table4.columns.filter((entry3) => entry3 !== column2).map((entry3) => entry3.name);
|
|
44998
45091
|
const newName = uniqueHeaders([...others, text8]).at(-1);
|
|
44999
45092
|
column2.name = newName;
|
|
45000
45093
|
if (newName !== text8) writeValue(sheet, row3, col, newName);
|
|
@@ -45004,10 +45097,10 @@ function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
|
45004
45097
|
ctx.workbook,
|
|
45005
45098
|
(formula, formulaSheet, at2) => renameTableColumnInFormula(
|
|
45006
45099
|
formula,
|
|
45007
|
-
|
|
45100
|
+
table4.name,
|
|
45008
45101
|
oldName,
|
|
45009
45102
|
newName,
|
|
45010
|
-
formulaSheet === sheet.name && !!at2 && rangeContains(
|
|
45103
|
+
formulaSheet === sheet.name && !!at2 && rangeContains(table4.range, at2)
|
|
45011
45104
|
),
|
|
45012
45105
|
cells3
|
|
45013
45106
|
);
|
|
@@ -46131,11 +46224,11 @@ function uniqueColumnName(columns) {
|
|
|
46131
46224
|
const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
|
|
46132
46225
|
for (let n = 1; ; n++) if (!taken.has(`column${n}`)) return `Column${n}`;
|
|
46133
46226
|
}
|
|
46134
|
-
function shiftTable(sheet,
|
|
46135
|
-
const old =
|
|
46227
|
+
function shiftTable(sheet, table4, shift2, moveRange) {
|
|
46228
|
+
const old = table4.range;
|
|
46136
46229
|
const range2 = moveRange(old);
|
|
46137
46230
|
if (!range2) return [];
|
|
46138
|
-
const next = { ...
|
|
46231
|
+
const next = { ...table4, range: range2, columns: [...table4.columns] };
|
|
46139
46232
|
const widened = range2.end.col - range2.start.col !== old.end.col - old.start.col;
|
|
46140
46233
|
if (shift2.axis === "col" && widened) {
|
|
46141
46234
|
if (shift2.count > 0) {
|
|
@@ -46611,8 +46704,8 @@ function cellText(inner2) {
|
|
|
46611
46704
|
).replace(/ /g, " ").trim();
|
|
46612
46705
|
}
|
|
46613
46706
|
function parseHtmlTable(html, base2) {
|
|
46614
|
-
const
|
|
46615
|
-
if (
|
|
46707
|
+
const table4 = /<table\b[^>]*>([\s\S]*?)<\/table>/i.exec(html)?.[1];
|
|
46708
|
+
if (table4 === void 0) return void 0;
|
|
46616
46709
|
const classes = /* @__PURE__ */ new Map();
|
|
46617
46710
|
for (const block of html.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi))
|
|
46618
46711
|
for (const rule2 of removeAll(block[1] ?? "", ["<!--", "-->"]).matchAll(
|
|
@@ -46625,7 +46718,7 @@ function parseHtmlTable(html, base2) {
|
|
|
46625
46718
|
const hyperlinks = [];
|
|
46626
46719
|
let r = 0;
|
|
46627
46720
|
let spanned = 0;
|
|
46628
|
-
for (const tr of
|
|
46721
|
+
for (const tr of table4.matchAll(/<tr\b[^>]*>([\s\S]*?)(?=<tr\b|<\/tbody|<\/table|$)/gi)) {
|
|
46629
46722
|
const row3 = grid[r] ??= [];
|
|
46630
46723
|
let c2 = 0;
|
|
46631
46724
|
for (const td of (tr[1] ?? "").matchAll(
|
|
@@ -47477,9 +47570,9 @@ function filterColumn(ctx, s, col, values2) {
|
|
|
47477
47570
|
}
|
|
47478
47571
|
function sortByColumn(ctx, s, col, descending) {
|
|
47479
47572
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47480
|
-
const
|
|
47573
|
+
const table4 = sheet.tables.find((t) => col >= t.range.start.col && col <= t.range.end.col);
|
|
47481
47574
|
const filter2 = sheet.autoFilter;
|
|
47482
|
-
const target2 =
|
|
47575
|
+
const target2 = table4 ? { range: table4.range, header: table4.headerRow, totals: table4.totalsRow } : filter2 && rangeContains(filter2.range, { row: filter2.range.start.row, col }) ? { range: filter2.range, header: true, totals: false } : void 0;
|
|
47483
47576
|
if (!target2) throw new Error("The column is not inside a table or an auto-filter range.");
|
|
47484
47577
|
const range2 = target2.totals ? { start: target2.range.start, end: { ...target2.range.end, row: target2.range.end.row - 1 } } : target2.range;
|
|
47485
47578
|
ctx.run(
|
|
@@ -47539,12 +47632,12 @@ function restore(sheet, saved) {
|
|
|
47539
47632
|
Object.assign(cell, saved.fields);
|
|
47540
47633
|
}
|
|
47541
47634
|
var valueAt = (sheet, row3, col) => getCell(sheet, row3, col)?.value ?? null;
|
|
47542
|
-
function computeDataTable(workbook, calc, sheetIndex2,
|
|
47635
|
+
function computeDataTable(workbook, calc, sheetIndex2, table4) {
|
|
47543
47636
|
const sheet = sheetAt(workbook, sheetIndex2);
|
|
47544
|
-
const { ref } =
|
|
47545
|
-
const first3 = parseInputCell(sheet,
|
|
47546
|
-
const second =
|
|
47547
|
-
if (!first3 ||
|
|
47637
|
+
const { ref } = table4;
|
|
47638
|
+
const first3 = parseInputCell(sheet, table4.r1);
|
|
47639
|
+
const second = table4.dt2D && table4.r2 ? parseInputCell(sheet, table4.r2) : void 0;
|
|
47640
|
+
if (!first3 || table4.dt2D && !second || table4.del1 || table4.del2) return [];
|
|
47548
47641
|
const inputs = [first3, ...second ? [second] : []];
|
|
47549
47642
|
const saved = inputs.map((p) => save(sheet, p.row, p.col));
|
|
47550
47643
|
const top = ref.start.row - 1;
|
|
@@ -47563,11 +47656,11 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47563
47656
|
for (let row3 = ref.start.row; row3 <= ref.end.row; row3++) {
|
|
47564
47657
|
for (let col = ref.start.col; col <= ref.end.col; col++) {
|
|
47565
47658
|
let formulaAt;
|
|
47566
|
-
if (
|
|
47659
|
+
if (table4.dt2D) {
|
|
47567
47660
|
set(first3, valueAt(sheet, top, col));
|
|
47568
47661
|
if (second) set(second, valueAt(sheet, row3, left2));
|
|
47569
47662
|
formulaAt = { row: top, col: left2 };
|
|
47570
|
-
} else if (
|
|
47663
|
+
} else if (table4.dtr) {
|
|
47571
47664
|
set(first3, valueAt(sheet, top, col));
|
|
47572
47665
|
formulaAt = { row: row3, col: left2 };
|
|
47573
47666
|
} else {
|
|
@@ -47592,8 +47685,8 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47592
47685
|
function refreshDataTables(workbook, calc) {
|
|
47593
47686
|
const changed = [];
|
|
47594
47687
|
workbook.sheets.forEach((sheet, index3) => {
|
|
47595
|
-
for (const
|
|
47596
|
-
changed.push(...computeDataTable(workbook, calc, index3,
|
|
47688
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
47689
|
+
changed.push(...computeDataTable(workbook, calc, index3, table4));
|
|
47597
47690
|
});
|
|
47598
47691
|
if (changed.length) calc.recalculateFrom(changed);
|
|
47599
47692
|
}
|
|
@@ -47616,23 +47709,23 @@ function resolve2(sheet, request) {
|
|
|
47616
47709
|
const ref = cellRange(range2.start.row + 1, range2.start.col + 1, range2.end.row, range2.end.col);
|
|
47617
47710
|
if ([row3, col].some((p) => p && rangeContains(ref, p))) return { problem: "input-inside" };
|
|
47618
47711
|
const name3 = (p) => formatAddress(p);
|
|
47619
|
-
const
|
|
47712
|
+
const table4 = { ref, r1: "" };
|
|
47620
47713
|
if (row3 && col) {
|
|
47621
|
-
|
|
47622
|
-
|
|
47623
|
-
|
|
47624
|
-
|
|
47714
|
+
table4.dt2D = true;
|
|
47715
|
+
table4.dtr = true;
|
|
47716
|
+
table4.r1 = name3(row3);
|
|
47717
|
+
table4.r2 = name3(col);
|
|
47625
47718
|
} else if (row3) {
|
|
47626
|
-
|
|
47627
|
-
|
|
47628
|
-
} else if (col)
|
|
47629
|
-
return { table:
|
|
47719
|
+
table4.dtr = true;
|
|
47720
|
+
table4.r1 = name3(row3);
|
|
47721
|
+
} else if (col) table4.r1 = name3(col);
|
|
47722
|
+
return { table: table4 };
|
|
47630
47723
|
}
|
|
47631
47724
|
function createDataTable(ctx, s, request) {
|
|
47632
47725
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47633
47726
|
const result2 = resolve2(sheet, request);
|
|
47634
47727
|
if ("problem" in result2) throw new Error(MESSAGES[result2.problem]);
|
|
47635
|
-
const { table:
|
|
47728
|
+
const { table: table4 } = result2;
|
|
47636
47729
|
const range2 = normalizeRange(request.range);
|
|
47637
47730
|
ctx.run(
|
|
47638
47731
|
"Data Table",
|
|
@@ -47643,16 +47736,16 @@ function createDataTable(ctx, s, request) {
|
|
|
47643
47736
|
],
|
|
47644
47737
|
() => {
|
|
47645
47738
|
sheet.dataTables = (sheet.dataTables ?? []).filter((t) => !rangesIntersect(t.ref, range2));
|
|
47646
|
-
sheet.dataTables.push(
|
|
47647
|
-
for (let row3 =
|
|
47648
|
-
for (let col =
|
|
47739
|
+
sheet.dataTables.push(table4);
|
|
47740
|
+
for (let row3 = table4.ref.start.row; row3 <= table4.ref.end.row; row3++)
|
|
47741
|
+
for (let col = table4.ref.start.col; col <= table4.ref.end.col; col++) {
|
|
47649
47742
|
const cell = ensureCell(sheet, row3, col);
|
|
47650
47743
|
delete cell.formula;
|
|
47651
47744
|
delete cell.arrayRange;
|
|
47652
47745
|
delete cell.legacyFormula;
|
|
47653
47746
|
delete cell.dynamicArray;
|
|
47654
47747
|
}
|
|
47655
|
-
computeDataTable(ctx.workbook, ctx.calc, s,
|
|
47748
|
+
computeDataTable(ctx.workbook, ctx.calc, s, table4);
|
|
47656
47749
|
},
|
|
47657
47750
|
{ sheet: s, ranges: [range2] }
|
|
47658
47751
|
);
|
|
@@ -48889,7 +48982,7 @@ function pixelSizeToExtent(width, height) {
|
|
|
48889
48982
|
}
|
|
48890
48983
|
|
|
48891
48984
|
// xlsx/pivot/date-axes.ts
|
|
48892
|
-
var dateGroupAxisNames = (group) => dateGroupUnits(group).reverse().map((unit3) => dateGroupFieldName(unit3, group.field));
|
|
48985
|
+
var dateGroupAxisNames = (group) => dateGroupUnits(group).reverse().map((unit3) => dateGroupFieldName(unit3, group.field, group));
|
|
48893
48986
|
function replace(list2, names, replacement) {
|
|
48894
48987
|
const at2 = list2.findIndex((name3) => names.includes(name3));
|
|
48895
48988
|
if (at2 < 0) return list2;
|
|
@@ -48925,7 +49018,9 @@ function reconcileDateAxes(next, previous) {
|
|
|
48925
49018
|
if (columns.length > 1) next.moreColumnFields = columns.slice(1);
|
|
48926
49019
|
else delete next.moreColumnFields;
|
|
48927
49020
|
if (next.fieldSubtotals) {
|
|
48928
|
-
const kept = next.fieldSubtotals.filter(
|
|
49021
|
+
const kept = next.fieldSubtotals.filter(
|
|
49022
|
+
(entry3) => rows.includes(entry3.field) || columns.includes(entry3.field)
|
|
49023
|
+
);
|
|
48929
49024
|
if (kept.length) next.fieldSubtotals = kept;
|
|
48930
49025
|
else delete next.fieldSubtotals;
|
|
48931
49026
|
}
|
|
@@ -48967,7 +49062,7 @@ function plan(ctx, s, pivot, old) {
|
|
|
48967
49062
|
if (![start.row, start.col].every(Number.isInteger) || start.row < 0 || start.col < 0 || location.end.row > MAX_ROW || location.end.col > MAX_COL)
|
|
48968
49063
|
throw new Error("The PivotTable result does not fit on the worksheet.");
|
|
48969
49064
|
const source2 = sparklineDataRange(ctx.workbook, s, pivot.source);
|
|
48970
|
-
if (source2.sheet === s && rangesIntersect(source2.range, location) || sheet.merges.some((range2) => rangesIntersect(range2, location)) || sheet.tables.some((
|
|
49065
|
+
if (source2.sheet === s && rangesIntersect(source2.range, location) || sheet.merges.some((range2) => rangesIntersect(range2, location)) || sheet.tables.some((table4) => rangesIntersect(table4.range, location)) || sheet.pivotTables?.some((other) => other !== old && rangesIntersect(other.location, location)))
|
|
48971
49066
|
throw new Error("The PivotTable would overlap source data, another table or merged cells.");
|
|
48972
49067
|
let occupied = false;
|
|
48973
49068
|
forEachCellInRange(sheet, location, (cell, row3, col) => {
|
|
@@ -48977,12 +49072,12 @@ function plan(ctx, s, pivot, old) {
|
|
|
48977
49072
|
if (occupied) throw new Error("The PivotTable would overwrite existing cell content.");
|
|
48978
49073
|
return { grid, location };
|
|
48979
49074
|
}
|
|
48980
|
-
function writePivot(ctx, s, pivot, old,
|
|
49075
|
+
function writePivot(ctx, s, pivot, old, label2, inside2) {
|
|
48981
49076
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48982
49077
|
const { grid, location } = plan(ctx, s, pivot, old);
|
|
48983
49078
|
const ranges = [...old ? [old.location] : [], location];
|
|
48984
49079
|
ctx.run(
|
|
48985
|
-
|
|
49080
|
+
label2 ?? (old ? "Refresh PivotTable" : "Create PivotTable"),
|
|
48986
49081
|
"annotations",
|
|
48987
49082
|
[
|
|
48988
49083
|
{ kind: "parts", sheet: s, parts: ["pivotTables"] },
|
|
@@ -49039,8 +49134,10 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
49039
49134
|
const name3 = options.name ?? uniqueName(ctx);
|
|
49040
49135
|
checkName2(ctx, name3);
|
|
49041
49136
|
const aggregate2 = options.aggregate ?? "sum";
|
|
49137
|
+
const captions = authoredCaptions(options);
|
|
49042
49138
|
const pivot = {
|
|
49043
49139
|
...data,
|
|
49140
|
+
...captions ? { captions } : {},
|
|
49044
49141
|
name: name3,
|
|
49045
49142
|
rowField: options.rowField,
|
|
49046
49143
|
layout: options.layout ?? "tabular",
|
|
@@ -49054,12 +49151,12 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
49054
49151
|
...options.repeatLabels !== void 0 ? { repeatLabels: options.repeatLabels } : {},
|
|
49055
49152
|
valueField: options.valueField,
|
|
49056
49153
|
aggregate: aggregate2,
|
|
49057
|
-
valueCaption: pivotCaption(aggregate2, options.valueField),
|
|
49154
|
+
valueCaption: pivotCaption(aggregate2, options.valueField, { captions }),
|
|
49058
49155
|
...options.pageFilter !== void 0 ? { pageFilter: structuredClone(options.pageFilter) } : {},
|
|
49059
49156
|
...options.fieldGroups?.length ? { fieldGroups: structuredClone(options.fieldGroups) } : {},
|
|
49060
49157
|
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
49061
49158
|
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
49062
|
-
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
49159
|
+
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues, { captions }) } : {},
|
|
49063
49160
|
location: { start: { ...destination }, end: { ...destination } },
|
|
49064
49161
|
...options.columnField ? { columnField: options.columnField } : {},
|
|
49065
49162
|
...options.columnField && options.moreColumnFields?.length ? { moreColumnFields: [...options.moreColumnFields] } : {}
|
|
@@ -49082,7 +49179,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
49082
49179
|
rowField: patch2.rowField ?? old.rowField,
|
|
49083
49180
|
valueField,
|
|
49084
49181
|
aggregate: aggregate2,
|
|
49085
|
-
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField)
|
|
49182
|
+
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField, old)
|
|
49086
49183
|
};
|
|
49087
49184
|
if (patch2.columnField !== void 0) {
|
|
49088
49185
|
if (patch2.columnField) next.columnField = patch2.columnField;
|
|
@@ -49132,7 +49229,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
49132
49229
|
else if (patch2.valuesAxis === "columns" || patch2.secondRowField === "")
|
|
49133
49230
|
delete next.valuesPosition;
|
|
49134
49231
|
if (patch2.additionalValues !== void 0) {
|
|
49135
|
-
const measures2 = normalizedPivotMeasures(patch2.additionalValues);
|
|
49232
|
+
const measures2 = normalizedPivotMeasures(patch2.additionalValues, old);
|
|
49136
49233
|
if (measures2.length) next.additionalValues = measures2;
|
|
49137
49234
|
else delete next.additionalValues;
|
|
49138
49235
|
}
|
|
@@ -49141,6 +49238,12 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
49141
49238
|
else delete next.dateFields;
|
|
49142
49239
|
roundDateRecords(next, dates, ctx.workbook.date1904);
|
|
49143
49240
|
if (next.dateFilter && !dates.includes(next.dateFilter.field)) delete next.dateFilter;
|
|
49241
|
+
if (patch2.fieldSubtotals === void 0 && next.fieldSubtotals) {
|
|
49242
|
+
const onAxes = [...pivotRowFields(next), ...pivotColumnFields(next)];
|
|
49243
|
+
const left2 = next.fieldSubtotals.filter((entry3) => onAxes.includes(entry3.field));
|
|
49244
|
+
if (left2.length) next.fieldSubtotals = left2;
|
|
49245
|
+
else delete next.fieldSubtotals;
|
|
49246
|
+
}
|
|
49144
49247
|
const kept = pruneItemFilters(next);
|
|
49145
49248
|
if (kept) next.itemFilters = kept;
|
|
49146
49249
|
else delete next.itemFilters;
|
|
@@ -49596,10 +49699,10 @@ function validatePatch(group, patch2) {
|
|
|
49596
49699
|
delete next.manualMax;
|
|
49597
49700
|
validateSettings(next);
|
|
49598
49701
|
}
|
|
49599
|
-
function save2(ctx, s, next,
|
|
49702
|
+
function save2(ctx, s, next, label2, ranges) {
|
|
49600
49703
|
const sheet = sheetAt(ctx.workbook, s);
|
|
49601
49704
|
ctx.run(
|
|
49602
|
-
|
|
49705
|
+
label2,
|
|
49603
49706
|
"annotations",
|
|
49604
49707
|
[{ kind: "parts", sheet: s, parts: ["preserved"] }],
|
|
49605
49708
|
() => sheet.preserved.set("extLst", next),
|
|
@@ -49717,20 +49820,20 @@ function setSlicerSelection(ctx, cacheName, keys) {
|
|
|
49717
49820
|
const target2 = slicerTarget(ctx.workbook, cache3);
|
|
49718
49821
|
if (!target2) throw new Error("The slicer has no data source.");
|
|
49719
49822
|
if (target2.kind === "table") {
|
|
49720
|
-
const { sheet, table:
|
|
49823
|
+
const { sheet, table: table4, offset: offset2 } = target2;
|
|
49721
49824
|
ctx.run(
|
|
49722
49825
|
keys === null ? "Clear slicer filter" : "Filter slicer",
|
|
49723
49826
|
"view",
|
|
49724
49827
|
[{ kind: "sheet", sheet: target2.sheetIndex }],
|
|
49725
49828
|
() => {
|
|
49726
|
-
const column2 =
|
|
49829
|
+
const column2 = table4.columns[offset2];
|
|
49727
49830
|
if (keys === null) delete column2.filter;
|
|
49728
49831
|
else
|
|
49729
49832
|
column2.filter = {
|
|
49730
49833
|
values: keys.filter((key2) => key2 !== ""),
|
|
49731
49834
|
...keys.includes("") ? { blank: true } : {}
|
|
49732
49835
|
};
|
|
49733
|
-
applyTableFilter(ctx.workbook, sheet,
|
|
49836
|
+
applyTableFilter(ctx.workbook, sheet, table4);
|
|
49734
49837
|
},
|
|
49735
49838
|
{ sheet: target2.sheetIndex, structural: true }
|
|
49736
49839
|
);
|
|
@@ -49801,17 +49904,17 @@ function unique2(base2, taken) {
|
|
|
49801
49904
|
function insertSlicer(ctx, s, ref) {
|
|
49802
49905
|
const { workbook } = ctx;
|
|
49803
49906
|
const sheet = sheetAt(workbook, s);
|
|
49804
|
-
let
|
|
49907
|
+
let table4;
|
|
49805
49908
|
let pivot;
|
|
49806
49909
|
let field2;
|
|
49807
49910
|
if (ref.kind === "table") {
|
|
49808
|
-
|
|
49911
|
+
table4 = sheet.tables.find(
|
|
49809
49912
|
(entry3) => entry3.name === ref.table || entry3.displayName === ref.table
|
|
49810
49913
|
);
|
|
49811
|
-
if (!
|
|
49914
|
+
if (!table4?.headerRow || table4.filterNotModeled)
|
|
49812
49915
|
throw new Error("Choose a table with a header row and value filters.");
|
|
49813
49916
|
field2 = ref.column;
|
|
49814
|
-
if (!
|
|
49917
|
+
if (!table4.columns.some((column2) => column2.name === field2))
|
|
49815
49918
|
throw new Error("Choose a column of the table.");
|
|
49816
49919
|
} else {
|
|
49817
49920
|
pivot = sheet.pivotTables?.find((entry3) => entry3.name === ref.pivot);
|
|
@@ -49831,7 +49934,7 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49831
49934
|
(c2) => names.has(c2.toLowerCase())
|
|
49832
49935
|
).replace(/ /g, "_");
|
|
49833
49936
|
const metrics = createGridMetrics(sheet, { zoom: 100 });
|
|
49834
|
-
const anchorCell =
|
|
49937
|
+
const anchorCell = table4 ? { row: table4.range.start.row, col: table4.range.end.col + 2 } : { row: pivot.location.start.row, col: pivot.location.end.col + 2 };
|
|
49835
49938
|
const x = Math.max(metrics.colLeft(anchorCell.col), frameBounds(sheet) + 10);
|
|
49836
49939
|
const box5 = { x, y: metrics.rowTop(anchorCell.row), ...SLICER_BOX };
|
|
49837
49940
|
const anchor = pixelBoxToAnchor(sheet, box5, metrics, "twoCell");
|
|
@@ -49848,13 +49951,13 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49848
49951
|
() => {
|
|
49849
49952
|
const book = cloneBook(workbook);
|
|
49850
49953
|
let source2;
|
|
49851
|
-
if (
|
|
49852
|
-
if (
|
|
49853
|
-
|
|
49954
|
+
if (table4) {
|
|
49955
|
+
if (table4.columns.some((column2) => column2.sourceId === void 0))
|
|
49956
|
+
table4.columns.forEach((column2, index3) => column2.sourceId ??= index3 + 1);
|
|
49854
49957
|
source2 = {
|
|
49855
49958
|
kind: "table",
|
|
49856
|
-
tableId:
|
|
49857
|
-
column:
|
|
49959
|
+
tableId: table4.id,
|
|
49960
|
+
column: table4.columns.find((column2) => column2.name === field2).sourceId
|
|
49858
49961
|
};
|
|
49859
49962
|
} else {
|
|
49860
49963
|
const target2 = pivot;
|
|
@@ -50340,9 +50443,9 @@ var SUBTOTAL = {
|
|
|
50340
50443
|
var: 110
|
|
50341
50444
|
};
|
|
50342
50445
|
var escapeColumn = (name3) => name3.replace(/['#[\]]/g, "'$&");
|
|
50343
|
-
function applyTotalsRow(sheet,
|
|
50344
|
-
const row3 =
|
|
50345
|
-
const { columns } =
|
|
50446
|
+
function applyTotalsRow(sheet, table4) {
|
|
50447
|
+
const row3 = table4.range.end.row;
|
|
50448
|
+
const { columns } = table4;
|
|
50346
50449
|
if (!columns.some((c2) => c2.totalsRowFunction || c2.totalsRowLabel)) {
|
|
50347
50450
|
const first3 = columns[0];
|
|
50348
50451
|
const last = columns[columns.length - 1];
|
|
@@ -50350,12 +50453,12 @@ function applyTotalsRow(sheet, table3) {
|
|
|
50350
50453
|
if (last) last.totalsRowFunction = "sum";
|
|
50351
50454
|
}
|
|
50352
50455
|
columns.forEach((column2, i2) => {
|
|
50353
|
-
const col =
|
|
50456
|
+
const col = table4.range.start.col + i2;
|
|
50354
50457
|
const code = SUBTOTAL[column2.totalsRowFunction ?? ""];
|
|
50355
50458
|
if (code !== void 0) {
|
|
50356
50459
|
const cell = ensureCell(sheet, row3, col);
|
|
50357
50460
|
clearContents(cell);
|
|
50358
|
-
cell.formula = `SUBTOTAL(${code},${
|
|
50461
|
+
cell.formula = `SUBTOTAL(${code},${table4.name}[${escapeColumn(column2.name)}])`;
|
|
50359
50462
|
} else if (column2.totalsRowLabel && column2.totalsRowFunction !== "custom")
|
|
50360
50463
|
writeValue(sheet, row3, col, column2.totalsRowLabel);
|
|
50361
50464
|
});
|
|
@@ -50379,8 +50482,8 @@ function validateTableName(workbook, name3, self) {
|
|
|
50379
50482
|
) || workbook.definedNames.some((n) => n.name.toLowerCase() === lower3);
|
|
50380
50483
|
return taken ? "That name is already used by another table or name." : void 0;
|
|
50381
50484
|
}
|
|
50382
|
-
function renameTableIn(workbook,
|
|
50383
|
-
const old =
|
|
50485
|
+
function renameTableIn(workbook, table4, name3) {
|
|
50486
|
+
const old = table4.name;
|
|
50384
50487
|
if (old === name3) return;
|
|
50385
50488
|
const rename = (f6) => renameTableInFormula(f6, old, name3);
|
|
50386
50489
|
rewriteFormulas(workbook, rename);
|
|
@@ -50389,73 +50492,73 @@ function renameTableIn(workbook, table3, name3) {
|
|
|
50389
50492
|
for (const column2 of t.columns)
|
|
50390
50493
|
if (column2.calculatedColumnFormula)
|
|
50391
50494
|
column2.calculatedColumnFormula = rename(column2.calculatedColumnFormula);
|
|
50392
|
-
|
|
50393
|
-
|
|
50495
|
+
table4.name = name3;
|
|
50496
|
+
table4.displayName = name3;
|
|
50394
50497
|
}
|
|
50395
50498
|
var byId = (sheet, id3) => {
|
|
50396
|
-
const
|
|
50397
|
-
if (!
|
|
50398
|
-
return
|
|
50499
|
+
const table4 = sheet.tables.find((t) => t.id === id3);
|
|
50500
|
+
if (!table4) throw new Error("The table disappeared during the edit.");
|
|
50501
|
+
return table4;
|
|
50399
50502
|
};
|
|
50400
|
-
function insertBandRow(workbook, sheet,
|
|
50503
|
+
function insertBandRow(workbook, sheet, table4, row3) {
|
|
50401
50504
|
const shift2 = { axis: "row", at: row3, count: 1 };
|
|
50402
|
-
const band2 = { lo:
|
|
50505
|
+
const band2 = { lo: table4.range.start.col, hi: table4.range.end.col };
|
|
50403
50506
|
assertInsertFits(sheet, shift2, band2);
|
|
50404
50507
|
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band2));
|
|
50405
50508
|
shiftSheetContent(sheet, shift2, band2);
|
|
50406
50509
|
}
|
|
50407
50510
|
function setHeaderRow(workbook, sheet, id3, on) {
|
|
50408
|
-
let
|
|
50409
|
-
if (
|
|
50410
|
-
const { start, end } =
|
|
50511
|
+
let table4 = byId(sheet, id3);
|
|
50512
|
+
if (table4.headerRow === on) return;
|
|
50513
|
+
const { start, end } = table4.range;
|
|
50411
50514
|
if (!on) {
|
|
50412
50515
|
if (start.row === end.row) throw new Error("A table needs at least one row.");
|
|
50413
50516
|
clearRow(sheet, start.row, start.col, end.col);
|
|
50414
|
-
|
|
50415
|
-
|
|
50517
|
+
table4.range = { start: { row: start.row + 1, col: start.col }, end };
|
|
50518
|
+
table4.headerRow = false;
|
|
50416
50519
|
return;
|
|
50417
50520
|
}
|
|
50418
50521
|
if (start.row === 0 || !rowIsEmpty(sheet, start.row - 1, start.col, end.col)) {
|
|
50419
|
-
insertBandRow(workbook, sheet,
|
|
50420
|
-
|
|
50421
|
-
}
|
|
50422
|
-
const top =
|
|
50423
|
-
const left2 =
|
|
50424
|
-
|
|
50425
|
-
|
|
50426
|
-
uniqueHeaders(
|
|
50427
|
-
const column2 =
|
|
50522
|
+
insertBandRow(workbook, sheet, table4, start.row);
|
|
50523
|
+
table4 = byId(sheet, id3);
|
|
50524
|
+
}
|
|
50525
|
+
const top = table4.range.start.row - 1;
|
|
50526
|
+
const left2 = table4.range.start.col;
|
|
50527
|
+
table4.range = { start: { row: top, col: left2 }, end: table4.range.end };
|
|
50528
|
+
table4.headerRow = true;
|
|
50529
|
+
uniqueHeaders(table4.columns.map((c2) => c2.name)).forEach((name3, i2) => {
|
|
50530
|
+
const column2 = table4.columns[i2];
|
|
50428
50531
|
if (column2) column2.name = name3;
|
|
50429
50532
|
writeValue(sheet, top, left2 + i2, name3);
|
|
50430
50533
|
});
|
|
50431
50534
|
}
|
|
50432
50535
|
function setTotalsRow(workbook, sheet, id3, on) {
|
|
50433
|
-
let
|
|
50434
|
-
if (
|
|
50435
|
-
const { start, end } =
|
|
50536
|
+
let table4 = byId(sheet, id3);
|
|
50537
|
+
if (table4.totalsRow === on) return;
|
|
50538
|
+
const { start, end } = table4.range;
|
|
50436
50539
|
if (!on) {
|
|
50437
50540
|
clearRow(sheet, end.row, start.col, end.col);
|
|
50438
|
-
|
|
50439
|
-
|
|
50541
|
+
table4.range = { start, end: { row: end.row - 1, col: end.col } };
|
|
50542
|
+
table4.totalsRow = false;
|
|
50440
50543
|
return;
|
|
50441
50544
|
}
|
|
50442
50545
|
if (end.row === MAX_ROW) throw new RangeError("The insert area extends beyond the sheet.");
|
|
50443
50546
|
if (!rowIsEmpty(sheet, end.row + 1, start.col, end.col)) {
|
|
50444
|
-
insertBandRow(workbook, sheet,
|
|
50445
|
-
|
|
50547
|
+
insertBandRow(workbook, sheet, table4, end.row + 1);
|
|
50548
|
+
table4 = byId(sheet, id3);
|
|
50446
50549
|
}
|
|
50447
|
-
|
|
50448
|
-
|
|
50449
|
-
applyTotalsRow(sheet,
|
|
50550
|
+
table4.range = { start: table4.range.start, end: { row: table4.range.end.row + 1, col: end.col } };
|
|
50551
|
+
table4.totalsRow = true;
|
|
50552
|
+
applyTotalsRow(sheet, table4);
|
|
50450
50553
|
}
|
|
50451
|
-
function resizedColumns(workbook, sheet,
|
|
50554
|
+
function resizedColumns(workbook, sheet, table4, range2) {
|
|
50452
50555
|
const width = range2.end.col - range2.start.col + 1;
|
|
50453
|
-
const oldAt = (col) => col >=
|
|
50556
|
+
const oldAt = (col) => col >= table4.range.start.col && col <= table4.range.end.col ? table4.columns[col - table4.range.start.col] : void 0;
|
|
50454
50557
|
const texts = Array.from({ length: width }, (_v, i2) => {
|
|
50455
50558
|
const col = range2.start.col + i2;
|
|
50456
50559
|
const old = oldAt(col);
|
|
50457
50560
|
if (old) return old.name;
|
|
50458
|
-
return
|
|
50561
|
+
return table4.headerRow ? displayText(workbook, getCell(sheet, range2.start.row, col)) : "";
|
|
50459
50562
|
});
|
|
50460
50563
|
return uniqueHeaders(texts).map((name3, i2) => {
|
|
50461
50564
|
const old = oldAt(range2.start.col + i2);
|
|
@@ -50463,30 +50566,30 @@ function resizedColumns(workbook, sheet, table3, range2) {
|
|
|
50463
50566
|
});
|
|
50464
50567
|
}
|
|
50465
50568
|
function resizeTableIn(workbook, sheet, id3, range2) {
|
|
50466
|
-
const
|
|
50569
|
+
const table4 = byId(sheet, id3);
|
|
50467
50570
|
const r = normalizeRange(range2);
|
|
50468
|
-
if (
|
|
50571
|
+
if (table4.headerRow && r.start.row !== table4.range.start.row)
|
|
50469
50572
|
throw new Error("The table headers must remain in the same row.");
|
|
50470
|
-
if (!rangesIntersect(r,
|
|
50471
|
-
if (r.end.row - r.start.row + 1 < (
|
|
50573
|
+
if (!rangesIntersect(r, table4.range)) throw new Error("The new range must overlap the table.");
|
|
50574
|
+
if (r.end.row - r.start.row + 1 < (table4.headerRow ? 2 : 1) + (table4.totalsRow ? 1 : 0))
|
|
50472
50575
|
throw new Error("The table range is too small.");
|
|
50473
|
-
if (sheet.tables.some((t) => t !==
|
|
50576
|
+
if (sheet.tables.some((t) => t !== table4 && rangesIntersect(t.range, r)))
|
|
50474
50577
|
throw new Error("A table cannot overlap another table.");
|
|
50475
50578
|
if (sheet.pivotTables?.some((pivot) => rangesIntersect(pivot.location, r)))
|
|
50476
50579
|
throw new Error("A table cannot overlap a PivotTable.");
|
|
50477
50580
|
if (sheet.merges.some((m) => rangesIntersect(m, r)))
|
|
50478
50581
|
throw new Error("A table cannot contain merged cells.");
|
|
50479
|
-
const oldEnd =
|
|
50480
|
-
|
|
50481
|
-
|
|
50482
|
-
if (
|
|
50483
|
-
|
|
50582
|
+
const oldEnd = table4.range.end.row;
|
|
50583
|
+
table4.columns = resizedColumns(workbook, sheet, table4, r);
|
|
50584
|
+
table4.range = r;
|
|
50585
|
+
if (table4.headerRow)
|
|
50586
|
+
table4.columns.forEach((column2, i2) => {
|
|
50484
50587
|
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
50485
50588
|
if (cell?.value !== column2.name) writeValue(sheet, r.start.row, r.start.col + i2, column2.name);
|
|
50486
50589
|
});
|
|
50487
|
-
if (
|
|
50590
|
+
if (table4.totalsRow) {
|
|
50488
50591
|
if (oldEnd !== r.end.row) clearRow(sheet, oldEnd, r.start.col, r.end.col);
|
|
50489
|
-
applyTotalsRow(sheet,
|
|
50592
|
+
applyTotalsRow(sheet, table4);
|
|
50490
50593
|
}
|
|
50491
50594
|
}
|
|
50492
50595
|
var STYLE_KEYS = [
|
|
@@ -50514,20 +50617,20 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50514
50617
|
"structure",
|
|
50515
50618
|
[scope],
|
|
50516
50619
|
() => {
|
|
50517
|
-
const
|
|
50518
|
-
if (renaming) renameTableIn(workbook,
|
|
50620
|
+
const table4 = byId(sheet, id3);
|
|
50621
|
+
if (renaming) renameTableIn(workbook, table4, name3);
|
|
50519
50622
|
for (const key2 of STYLE_KEYS) {
|
|
50520
50623
|
if (!(key2 in patch2)) continue;
|
|
50521
50624
|
const value2 = patch2[key2];
|
|
50522
|
-
if (value2 === void 0) delete
|
|
50523
|
-
else
|
|
50625
|
+
if (value2 === void 0) delete table4[key2];
|
|
50626
|
+
else table4[key2] = value2;
|
|
50524
50627
|
}
|
|
50525
50628
|
if (patch2.columns) {
|
|
50526
|
-
const width =
|
|
50629
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
50527
50630
|
if (patch2.columns.length !== width) throw new Error("Give one column per table column.");
|
|
50528
|
-
const before =
|
|
50529
|
-
|
|
50530
|
-
for (const [index3, column2] of
|
|
50631
|
+
const before = table4.columns;
|
|
50632
|
+
table4.columns = structuredClone(patch2.columns);
|
|
50633
|
+
for (const [index3, column2] of table4.columns.entries()) {
|
|
50531
50634
|
const sourceId = before[index3]?.sourceId;
|
|
50532
50635
|
if (column2.sourceId === void 0 && sourceId !== void 0) column2.sourceId = sourceId;
|
|
50533
50636
|
const filter2 = before[index3]?.filter;
|
|
@@ -50536,7 +50639,7 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50536
50639
|
}
|
|
50537
50640
|
if (patch2.headerRow !== void 0) setHeaderRow(workbook, sheet, id3, patch2.headerRow);
|
|
50538
50641
|
if (patch2.totalsRow !== void 0) setTotalsRow(workbook, sheet, id3, patch2.totalsRow);
|
|
50539
|
-
else if (patch2.columns &&
|
|
50642
|
+
else if (patch2.columns && table4.totalsRow) applyTotalsRow(sheet, byId(sheet, id3));
|
|
50540
50643
|
if (patch2.range) resizeTableIn(workbook, sheet, id3, patch2.range);
|
|
50541
50644
|
},
|
|
50542
50645
|
{ sheet: s, ranges: [current.range], structural: true }
|
|
@@ -50556,13 +50659,13 @@ function resizeTable(ctx, s, ref, range2) {
|
|
|
50556
50659
|
function convertTableToRange(ctx, s, ref) {
|
|
50557
50660
|
const { workbook } = ctx;
|
|
50558
50661
|
const sheet = sheetAt(workbook, s);
|
|
50559
|
-
const
|
|
50662
|
+
const table4 = sheet.tables[tableIndex(sheet, ref)];
|
|
50560
50663
|
ctx.run(
|
|
50561
50664
|
"Convert to range",
|
|
50562
50665
|
"structure",
|
|
50563
50666
|
[{ kind: "workbook" }],
|
|
50564
50667
|
() => {
|
|
50565
|
-
const live2 = byId(sheet,
|
|
50668
|
+
const live2 = byId(sheet, table4.id);
|
|
50566
50669
|
const base2 = { table: live2, tableSheet: sheet.name };
|
|
50567
50670
|
const { start, end } = live2.range;
|
|
50568
50671
|
for (const ws of workbook.sheets)
|
|
@@ -50587,7 +50690,7 @@ function convertTableToRange(ctx, s, ref) {
|
|
|
50587
50690
|
});
|
|
50588
50691
|
sheet.tables = sheet.tables.filter((t) => t.id !== live2.id);
|
|
50589
50692
|
},
|
|
50590
|
-
{ sheet: s, ranges: [
|
|
50693
|
+
{ sheet: s, ranges: [table4.range], structural: true }
|
|
50591
50694
|
);
|
|
50592
50695
|
}
|
|
50593
50696
|
|
|
@@ -53493,7 +53596,7 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53493
53596
|
});
|
|
53494
53597
|
const name3 = nextTableName(workbook);
|
|
53495
53598
|
const id3 = Math.max(0, ...workbook.sheets.flatMap((ws) => ws.tables.map((t) => t.id))) + 1;
|
|
53496
|
-
const
|
|
53599
|
+
const table4 = {
|
|
53497
53600
|
id: id3,
|
|
53498
53601
|
name: name3,
|
|
53499
53602
|
displayName: name3,
|
|
@@ -53507,8 +53610,8 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53507
53610
|
showFirstColumn: false,
|
|
53508
53611
|
showLastColumn: false
|
|
53509
53612
|
};
|
|
53510
|
-
sheet.tables.push(
|
|
53511
|
-
return
|
|
53613
|
+
sheet.tables.push(table4);
|
|
53614
|
+
return table4;
|
|
53512
53615
|
},
|
|
53513
53616
|
{ sheet: s, ranges: [r], structural: !hasHeader }
|
|
53514
53617
|
);
|
|
@@ -53712,8 +53815,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
53712
53815
|
if (!workbook.warnings.includes(message)) workbook.warnings.push(message);
|
|
53713
53816
|
}
|
|
53714
53817
|
};
|
|
53715
|
-
const begin = (
|
|
53716
|
-
const step2 = { label:
|
|
53818
|
+
const begin = (label2, kind, info) => {
|
|
53819
|
+
const step2 = { label: label2, entries: [], structural: info.structural ?? false };
|
|
53717
53820
|
if (info.calc) step2.calc = info.calc;
|
|
53718
53821
|
return { step: step2, kind, sheet: info.sheet, ranges: [...info.ranges ?? []] };
|
|
53719
53822
|
};
|
|
@@ -53737,7 +53840,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53737
53840
|
}
|
|
53738
53841
|
current.step.entries.length = from;
|
|
53739
53842
|
};
|
|
53740
|
-
const run2 = (
|
|
53843
|
+
const run2 = (label2, kind, scopes, fn, info = {}) => {
|
|
53741
53844
|
if (kind === "cells") {
|
|
53742
53845
|
for (const scope of scopes)
|
|
53743
53846
|
if (scope.kind === "cells" && workbook.sheets[scope.sheet]?.pivotTables?.some(
|
|
@@ -53754,7 +53857,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53754
53857
|
}))
|
|
53755
53858
|
throw new Error(DATA_TABLE_PART_ERROR);
|
|
53756
53859
|
const outer = !open;
|
|
53757
|
-
const current = open ?? begin(
|
|
53860
|
+
const current = open ?? begin(label2, kind, info);
|
|
53758
53861
|
if (!outer) {
|
|
53759
53862
|
delete current.step.calc;
|
|
53760
53863
|
if (info.structural) current.step.structural = true;
|
|
@@ -53885,9 +53988,9 @@ function createEditSession(workbook, options = {}) {
|
|
|
53885
53988
|
removeConditionalFormat: (s, index3) => removeConditionalFormat(ctx, s, index3),
|
|
53886
53989
|
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
53887
53990
|
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
53888
|
-
updateTable: (s,
|
|
53889
|
-
resizeTable: (s,
|
|
53890
|
-
convertTableToRange: (s,
|
|
53991
|
+
updateTable: (s, table4, patch2) => updateTable(ctx, s, table4, patch2),
|
|
53992
|
+
resizeTable: (s, table4, range2) => resizeTable(ctx, s, table4, range2),
|
|
53993
|
+
convertTableToRange: (s, table4) => convertTableToRange(ctx, s, table4),
|
|
53891
53994
|
applyCellStyle: (s, ranges, name3) => applyCellStyle(ctx, s, ranges, name3),
|
|
53892
53995
|
setPageSetup: (s, patch2) => setPageSetup(ctx, s, patch2),
|
|
53893
53996
|
setPageBreak: (s, axis, before, present) => setPageBreak(ctx, s, axis, before, present),
|
|
@@ -53924,12 +54027,12 @@ function createEditSession(workbook, options = {}) {
|
|
|
53924
54027
|
validate: (s, r, c2, value2) => validateCellInput(workbook, s, r, c2, value2, {
|
|
53925
54028
|
evaluate: (formula, at2) => calc.evaluate(formula, at2)
|
|
53926
54029
|
}),
|
|
53927
|
-
batch(
|
|
54030
|
+
batch(label2, fn) {
|
|
53928
54031
|
if (open) {
|
|
53929
54032
|
fn();
|
|
53930
54033
|
return;
|
|
53931
54034
|
}
|
|
53932
|
-
const current = begin(
|
|
54035
|
+
const current = begin(label2, "batch", {});
|
|
53933
54036
|
open = current;
|
|
53934
54037
|
try {
|
|
53935
54038
|
fn();
|
|
@@ -54609,9 +54712,9 @@ var VisioPackage = class _VisioPackage {
|
|
|
54609
54712
|
};
|
|
54610
54713
|
|
|
54611
54714
|
// visio/metadata.ts
|
|
54612
|
-
function metadata(value2, max,
|
|
54715
|
+
function metadata(value2, max, label2) {
|
|
54613
54716
|
if (value2.length > max)
|
|
54614
|
-
throw new VisioPackageError("METADATA_LIMIT", `${
|
|
54717
|
+
throw new VisioPackageError("METADATA_LIMIT", `${label2} exceeds its metadata length limit.`);
|
|
54615
54718
|
return value2;
|
|
54616
54719
|
}
|
|
54617
54720
|
function metadataAttributes(node3) {
|
|
@@ -58563,15 +58666,15 @@ function legacyFillGradient(cells3, width, height, resolve3) {
|
|
|
58563
58666
|
|
|
58564
58667
|
// ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/utils/png-encoder.js
|
|
58565
58668
|
var CRC_TABLE = (() => {
|
|
58566
|
-
const
|
|
58669
|
+
const table4 = new Uint32Array(256);
|
|
58567
58670
|
for (let n = 0; n < 256; n++) {
|
|
58568
58671
|
let c2 = n;
|
|
58569
58672
|
for (let k = 0; k < 8; k++) {
|
|
58570
58673
|
c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
|
|
58571
58674
|
}
|
|
58572
|
-
|
|
58675
|
+
table4[n] = c2 >>> 0;
|
|
58573
58676
|
}
|
|
58574
|
-
return
|
|
58677
|
+
return table4;
|
|
58575
58678
|
})();
|
|
58576
58679
|
function crc322(bytes) {
|
|
58577
58680
|
let crc = 4294967295;
|
|
@@ -61245,7 +61348,7 @@ function property(row3, budget, report) {
|
|
|
61245
61348
|
"Shape data has no supported current cached typed value; original cached text is retained."
|
|
61246
61349
|
);
|
|
61247
61350
|
}
|
|
61248
|
-
const
|
|
61351
|
+
const label2 = get("Label"), format5 = get("Format"), prompt = get("Prompt"), sortKey = get("SortKey");
|
|
61249
61352
|
const invisible = boolean(row3.cells, "Invisible", budget, report);
|
|
61250
61353
|
const dataLinked = row3.cells.has("DataLinked") ? boolean(row3.cells, "DataLinked", budget, report) : void 0;
|
|
61251
61354
|
const unit3 = row3.cells.get("Value")?.unit, error = row3.cells.get("Value")?.error;
|
|
@@ -61257,7 +61360,7 @@ function property(row3, budget, report) {
|
|
|
61257
61360
|
...rawType === void 0 ? {} : { rawType },
|
|
61258
61361
|
...rawValue === void 0 ? {} : { rawValue },
|
|
61259
61362
|
...value2 === void 0 ? {} : { value: value2 },
|
|
61260
|
-
...
|
|
61363
|
+
...label2 === void 0 ? {} : { label: label2 },
|
|
61261
61364
|
...format5 === void 0 ? {} : { format: format5 },
|
|
61262
61365
|
...prompt === void 0 ? {} : { prompt },
|
|
61263
61366
|
...sortKey === void 0 ? {} : { sortKey },
|
|
@@ -61490,9 +61593,9 @@ async function readDataRecordsets(pkg, documentPart, check3) {
|
|
|
61490
61593
|
const declared = children3(children3(set, "DataColumns")[0], "DataColumn");
|
|
61491
61594
|
const columns = (declared.length ? declared : []).map((node3) => {
|
|
61492
61595
|
const name4 = attribute3(node3, "ColumnNameID") ?? attribute3(node3, "Name") ?? "";
|
|
61493
|
-
const
|
|
61494
|
-
if (!name4 || name4.length > 255 ||
|
|
61495
|
-
return { name: name4, label:
|
|
61596
|
+
const label2 = attribute3(node3, "Label") ?? attribute3(node3, "Name") ?? name4;
|
|
61597
|
+
if (!name4 || name4.length > 255 || label2.length > 255) invalid2("Invalid data column.");
|
|
61598
|
+
return { name: name4, label: label2, type: typeFromCode(attribute3(node3, "DataType")) };
|
|
61496
61599
|
});
|
|
61497
61600
|
if (!columns.length)
|
|
61498
61601
|
for (const column2 of ado.columns)
|
|
@@ -68155,18 +68258,18 @@ function advances(family, bold) {
|
|
|
68155
68258
|
const key2 = `${name3}|${bold ? "b" : "r"}`;
|
|
68156
68259
|
const known = decoded.get(key2);
|
|
68157
68260
|
if (known) return known;
|
|
68158
|
-
const
|
|
68159
|
-
if (!
|
|
68160
|
-
const values2 = (bold ?
|
|
68261
|
+
const table4 = Object.hasOwn(DESIGN_ADVANCES, name3) ? DESIGN_ADVANCES[name3] : void 0;
|
|
68262
|
+
if (!table4) return void 0;
|
|
68263
|
+
const values2 = (bold ? table4.bold : table4.regular).split(" ").map(Number);
|
|
68161
68264
|
decoded.set(key2, values2);
|
|
68162
68265
|
return values2;
|
|
68163
68266
|
}
|
|
68164
68267
|
function designTextWidthEm(text8, family, bold = false) {
|
|
68165
|
-
const
|
|
68166
|
-
if (!
|
|
68268
|
+
const table4 = advances(family, bold);
|
|
68269
|
+
if (!table4) return void 0;
|
|
68167
68270
|
let units2 = 0;
|
|
68168
68271
|
for (let index3 = 0; index3 < text8.length; ++index3) {
|
|
68169
|
-
const advance =
|
|
68272
|
+
const advance = table4[text8.charCodeAt(index3) - FIRST];
|
|
68170
68273
|
if (advance === void 0 || Number.isNaN(advance)) return void 0;
|
|
68171
68274
|
units2 += advance;
|
|
68172
68275
|
}
|
|
@@ -71377,9 +71480,9 @@ function visioBorderShapes(style3, width, height, title = VISIO_DEFAULT_TITLE) {
|
|
|
71377
71480
|
// visio/edit-page-setup-commands.ts
|
|
71378
71481
|
var VISIO_SCALE_UNITS = Object.freeze(["IN", "FT", "MM", "CM", "M"]);
|
|
71379
71482
|
var isVisioPageSetupEdit = (edit) => edit.type === "set-page-alt-text" || edit.type === "set-page-setup" || edit.type === "set-page-properties" || edit.type === "set-page-decoration" || edit.type === "set-page-layout" || edit.type === "set-snap-glue";
|
|
71380
|
-
var pageId = (value2,
|
|
71483
|
+
var pageId = (value2, label2) => {
|
|
71381
71484
|
if (typeof value2 !== "string" || !value2 || value2.length > 256)
|
|
71382
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71485
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71383
71486
|
return value2;
|
|
71384
71487
|
};
|
|
71385
71488
|
var newPageId = (value2) => {
|
|
@@ -71486,11 +71589,11 @@ var VISIO_SHAPE_DATA_TYPES = [
|
|
|
71486
71589
|
"date"
|
|
71487
71590
|
];
|
|
71488
71591
|
var invalidText2 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71489
|
-
function shapeDataText(value2,
|
|
71592
|
+
function shapeDataText(value2, label2) {
|
|
71490
71593
|
if (typeof value2 !== "string" || value2.length > VISIO_METADATA_TEXT_LIMIT)
|
|
71491
|
-
fail2("INVALID_EDIT", `${
|
|
71594
|
+
fail2("INVALID_EDIT", `${label2} must be a string within the length limit.`);
|
|
71492
71595
|
if (invalidText2.test(value2) || /[\r\n\t]/.test(value2))
|
|
71493
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71596
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid characters.`);
|
|
71494
71597
|
return value2;
|
|
71495
71598
|
}
|
|
71496
71599
|
function shapeDataRowName(value2) {
|
|
@@ -71498,9 +71601,9 @@ function shapeDataRowName(value2) {
|
|
|
71498
71601
|
fail2("INVALID_EDIT", "Shape Data row names use letters, digits and underscores.");
|
|
71499
71602
|
return value2;
|
|
71500
71603
|
}
|
|
71501
|
-
function visioShapeDataRowName(
|
|
71604
|
+
function visioShapeDataRowName(label2, taken = []) {
|
|
71502
71605
|
const used = new Set([...taken].map((name4) => name4.toLowerCase()));
|
|
71503
|
-
let base2 =
|
|
71606
|
+
let base2 = label2.normalize("NFKD").replace(/[^\w]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 48);
|
|
71504
71607
|
if (!base2) base2 = "Property";
|
|
71505
71608
|
if (/^\d/.test(base2)) base2 = `_${base2}`;
|
|
71506
71609
|
let name3 = base2;
|
|
@@ -71572,18 +71675,18 @@ var TYPES3 = [
|
|
|
71572
71675
|
"unlink-data-rows"
|
|
71573
71676
|
];
|
|
71574
71677
|
var isVisioDataEdit = (edit) => TYPES3.includes(edit.type);
|
|
71575
|
-
var id = (value2,
|
|
71678
|
+
var id = (value2, label2) => {
|
|
71576
71679
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71577
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71680
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71578
71681
|
return value2;
|
|
71579
71682
|
};
|
|
71580
|
-
var name = (value2,
|
|
71581
|
-
const text8 = shapeDataText(value2,
|
|
71683
|
+
var name = (value2, label2) => {
|
|
71684
|
+
const text8 = shapeDataText(value2, label2);
|
|
71582
71685
|
if (!text8.trim() || text8.length > 255)
|
|
71583
|
-
fail2("INVALID_EDIT", `${
|
|
71686
|
+
fail2("INVALID_EDIT", `${label2} must be 1 to 255 characters.`);
|
|
71584
71687
|
return text8;
|
|
71585
71688
|
};
|
|
71586
|
-
function
|
|
71689
|
+
function table3(columns, rows) {
|
|
71587
71690
|
if (!Array.isArray(columns) || !columns.length || columns.length > VISIO_DATA_LIMITS.maxColumns)
|
|
71588
71691
|
fail2("INVALID_EDIT", `A recordset needs 1 to ${VISIO_DATA_LIMITS.maxColumns} columns.`);
|
|
71589
71692
|
if (!Array.isArray(rows) || rows.length > VISIO_DATA_LIMITS.maxRows)
|
|
@@ -71629,14 +71732,14 @@ function snapshotDataEdit(edit) {
|
|
|
71629
71732
|
type: edit.type,
|
|
71630
71733
|
pageId: pageId2,
|
|
71631
71734
|
name: name(edit.name, "The recordset name"),
|
|
71632
|
-
...
|
|
71735
|
+
...table3(edit.columns, edit.rows)
|
|
71633
71736
|
};
|
|
71634
71737
|
case "refresh-data-recordset":
|
|
71635
71738
|
return {
|
|
71636
71739
|
type: edit.type,
|
|
71637
71740
|
pageId: pageId2,
|
|
71638
71741
|
recordsetId: id(edit.recordsetId, "recordset"),
|
|
71639
|
-
...
|
|
71742
|
+
...table3(edit.columns, edit.rows)
|
|
71640
71743
|
};
|
|
71641
71744
|
case "delete-data-recordset":
|
|
71642
71745
|
return { type: edit.type, pageId: pageId2, recordsetId: id(edit.recordsetId, "recordset") };
|
|
@@ -71695,16 +71798,16 @@ function snapshotPageTheme(edit) {
|
|
|
71695
71798
|
var isVisioCommentEdit = (edit) => edit.type === "add-comment" || edit.type === "edit-comment" || edit.type === "delete-comment";
|
|
71696
71799
|
var invalidText3 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71697
71800
|
var dateTime = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?(?:Z|[+-]\d{2}:\d{2})?$/;
|
|
71698
|
-
function string(value2, limit3,
|
|
71801
|
+
function string(value2, limit3, label2, required = true) {
|
|
71699
71802
|
if (typeof value2 !== "string" || value2.length > limit3 || required && !value2.trim())
|
|
71700
|
-
fail2("INVALID_EDIT", `${
|
|
71803
|
+
fail2("INVALID_EDIT", `${label2} must be a non-empty string within its length limit.`);
|
|
71701
71804
|
if (invalidText3.test(value2))
|
|
71702
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71805
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid XML characters.`);
|
|
71703
71806
|
return value2;
|
|
71704
71807
|
}
|
|
71705
|
-
var id2 = (value2,
|
|
71808
|
+
var id2 = (value2, label2) => {
|
|
71706
71809
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71707
|
-
fail2("INVALID_EDIT", `${
|
|
71810
|
+
fail2("INVALID_EDIT", `${label2} must be a canonical unsigned integer.`);
|
|
71708
71811
|
return value2;
|
|
71709
71812
|
};
|
|
71710
71813
|
var date = (value2) => {
|
|
@@ -72227,7 +72330,7 @@ async function editVsdxMasterInstance(pkg, parts, pages, edit, limits, maxOutput
|
|
|
72227
72330
|
|
|
72228
72331
|
// visio/paper-sizes.ts
|
|
72229
72332
|
var mm = (value2) => value2 / 25.4;
|
|
72230
|
-
var size = (id3,
|
|
72333
|
+
var size = (id3, label2, width, height, paperKind) => Object.freeze({ id: id3, label: label2, width, height, ...paperKind === void 0 ? {} : { paperKind } });
|
|
72231
72334
|
var VISIO_PAPER_SIZES = Object.freeze([
|
|
72232
72335
|
size("letter", "Letter", 8.5, 11, 1),
|
|
72233
72336
|
size("tabloid", "Tabloid", 11, 17, 3),
|
|
@@ -73597,7 +73700,7 @@ function snapshotFormatting(edit) {
|
|
|
73597
73700
|
if (!Number.isInteger(value2)) fail2("INVALID_EDIT", "Paint patterns require integers.");
|
|
73598
73701
|
result2[name3] = value2;
|
|
73599
73702
|
}
|
|
73600
|
-
for (const [name3, maximum,
|
|
73703
|
+
for (const [name3, maximum, label2] of [
|
|
73601
73704
|
["beginArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73602
73705
|
["endArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73603
73706
|
["beginArrowSize", 6, "Arrowhead sizes are numbered 0 to 6."],
|
|
@@ -73611,7 +73714,7 @@ function snapshotFormatting(edit) {
|
|
|
73611
73714
|
const value2 = edit[name3];
|
|
73612
73715
|
if (value2 === void 0) continue;
|
|
73613
73716
|
if (typeof value2 !== "number" || !Number.isInteger(value2) || value2 < 0 || value2 > maximum)
|
|
73614
|
-
fail2("INVALID_EDIT",
|
|
73717
|
+
fail2("INVALID_EDIT", label2);
|
|
73615
73718
|
result2[name3] = value2;
|
|
73616
73719
|
}
|
|
73617
73720
|
if (edit.rounding !== void 0) result2.rounding = points(edit.rounding, 0, 720);
|