ooxml-core 1.15.0 → 1.16.1
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-7RNEJ2IO.mjs +4 -0
- package/dist/PptxHandler-MK665E6Z.cjs +13 -0
- package/dist/{PptxHandler-R5BVKEBW.mjs → PptxHandler-ZF4G56V3.mjs} +2 -2
- package/dist/PresentationBuilder-HPHJTMIB.mjs +4 -0
- package/dist/{PresentationBuilder-W67DIJBV.mjs → PresentationBuilder-J7HAJGMB.mjs} +2 -2
- package/dist/{PresentationBuilder-4AF3PZHG.cjs → PresentationBuilder-JGYSF25G.cjs} +6 -5
- package/dist/automation/index.cjs +971 -544
- package/dist/automation/index.mjs +971 -544
- package/dist/chart/index.cjs +23 -4
- package/dist/chart/index.mjs +23 -4
- package/dist/{chunk-JFMIPOPV.mjs → chunk-5ROLXCIY.mjs} +439 -19
- package/dist/chunk-5W2QL4SB.cjs +244 -0
- package/dist/chunk-CA7KCNL3.mjs +236 -0
- package/dist/{chunk-BSUIDT6K.cjs → chunk-DWRJ62KP.cjs} +1 -0
- package/dist/{chunk-OPBZBSJF.mjs → chunk-HMZFUT65.mjs} +1 -1
- package/dist/{chunk-EMZIHAOH.mjs → chunk-IBFHMYJD.mjs} +1846 -565
- package/dist/{chunk-X7MGZQ6C.cjs → chunk-K7Z2EDI5.cjs} +419 -258
- package/dist/{chunk-NWAQEXBK.mjs → chunk-MVS2PT2Q.mjs} +1 -1
- package/dist/{chunk-PC4MTLG4.cjs → chunk-OA5V3JJC.cjs} +8 -8
- package/dist/{chunk-ZWI7MTLF.cjs → chunk-THEWZNWS.cjs} +2846 -1546
- package/dist/{chunk-2EBMHIGJ.mjs → chunk-TWXBU7RE.mjs} +402 -246
- package/dist/{chunk-AXF2FC4D.mjs → chunk-WSRCLCMB.mjs} +1 -0
- package/dist/{chunk-LMMP67YN.mjs → chunk-XCJRUBGJ.mjs} +1 -1
- package/dist/{chunk-7ZIZFJXT.mjs → chunk-YQ7HJOEZ.mjs} +1848 -548
- package/dist/{chunk-HU36GIYM.mjs → chunk-ZBCNC5RI.mjs} +421 -129
- package/dist/collab/broadcast-transport.d.ts.map +1 -1
- package/dist/collab/identity.d.ts +2 -0
- package/dist/collab/identity.d.ts.map +1 -1
- package/dist/collab/index.cjs +11 -2
- package/dist/collab/index.mjs +11 -3
- package/dist/crypto/index.cjs +23 -4
- package/dist/crypto/index.mjs +23 -4
- package/dist/diagram/index.cjs +23 -4
- package/dist/diagram/index.mjs +23 -4
- package/dist/docx/embedded.cjs +23 -4
- package/dist/docx/embedded.mjs +23 -4
- package/dist/docx/index.cjs +24 -5
- package/dist/docx/index.mjs +24 -5
- package/dist/docx/layout/index.cjs +24 -5
- package/dist/docx/layout/index.mjs +24 -5
- package/dist/docx/load/index.cjs +23 -4
- package/dist/docx/load/index.mjs +23 -4
- package/dist/docx/ui/index.cjs +32 -5
- package/dist/docx/ui/index.mjs +32 -5
- package/dist/drawingml/index.cjs +23 -4
- package/dist/drawingml/index.mjs +23 -4
- package/dist/index.cjs +23 -4
- package/dist/index.mjs +23 -4
- package/dist/math/index.cjs +23 -4
- package/dist/math/index.mjs +23 -4
- package/dist/opc/index.cjs +23 -4
- package/dist/opc/index.mjs +23 -4
- package/dist/pptx/automation/index.cjs +2690 -893
- package/dist/pptx/automation/index.d.ts +4 -4
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{elements-Cadkqht8.d.ts → elements-iUzpAeqR.d.ts} +114 -25
- package/dist/pptx/chunks/elements-iUzpAeqR.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-CJI2EugA.d.ts → index-BWHNCVNC.d.ts} +1671 -1534
- package/dist/pptx/chunks/index-BWHNCVNC.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-CozqpSPL.d.ts → index-CiyTR6mm.d.ts} +99 -10
- package/dist/pptx/chunks/index-CiyTR6mm.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-C3L9xrqx.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 +2680 -883
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +45 -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 +3236 -1115
- package/dist/pptx/index.d.ts +5 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +194 -74
- package/dist/teams/index.mjs +194 -74
- package/dist/visio/index.cjs +23 -4
- package/dist/visio/index.mjs +23 -4
- package/dist/visio/ui/index.cjs +23 -4
- package/dist/visio/ui/index.mjs +23 -4
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/edit/slicers.d.ts.map +1 -1
- package/dist/xlsx/edit/timelines.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +903 -476
- package/dist/xlsx/index.mjs +903 -476
- package/dist/xlsx/load/index.cjs +371 -104
- package/dist/xlsx/load/index.mjs +371 -104
- package/dist/xlsx/model-pivots.d.ts +47 -0
- package/dist/xlsx/model-pivots.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.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/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 -1
- package/dist/xlsx/pivot/measures.d.ts.map +1 -1
- 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/table-xml.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +833 -629
- package/dist/xlsx/ui/index.mjs +833 -629
- package/dist/xml/index.cjs +23 -4
- package/dist/xml/index.mjs +23 -4
- package/dist/xml/xml.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/PptxHandler-OGLITB3F.cjs +0 -12
- package/dist/PptxHandler-UKAA5T5U.mjs +0 -3
- package/dist/PresentationBuilder-54QGEZ2F.mjs +0 -3
- package/dist/pptx/chunks/elements-Cadkqht8.d.ts.map +0 -1
- package/dist/pptx/chunks/index-CJI2EugA.d.ts.map +0 -1
- package/dist/pptx/chunks/index-CozqpSPL.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-C3L9xrqx.d.ts.map +0 -1
|
@@ -80,30 +80,49 @@ var DEFAULT_XML_LIMITS = {
|
|
|
80
80
|
maxDepth: 512,
|
|
81
81
|
maxNodes: 5e6
|
|
82
82
|
};
|
|
83
|
-
var
|
|
84
|
-
|
|
83
|
+
var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
|
|
84
|
+
var MARKUP_SKIPS = [
|
|
85
|
+
["<!--", "-->"],
|
|
86
|
+
["<![CDATA[", "]]>"],
|
|
87
|
+
["<?", "?>"]
|
|
88
|
+
];
|
|
89
|
+
function checkXmlLimits(xml, label2, limits = {}) {
|
|
85
90
|
const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
86
91
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
87
92
|
let depth = 0;
|
|
88
93
|
let nodes = 0;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
let at2 = xml.indexOf("<");
|
|
95
|
+
while (at2 !== -1) {
|
|
96
|
+
const skip = MARKUP_SKIPS.find(([open]) => xml.startsWith(open, at2));
|
|
97
|
+
if (skip) {
|
|
98
|
+
const end = xml.indexOf(skip[1], at2 + skip[0].length);
|
|
99
|
+
if (end === -1) return;
|
|
100
|
+
at2 = xml.indexOf("<", end + skip[1].length);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
TAG_RE.lastIndex = at2;
|
|
104
|
+
const match2 = TAG_RE.exec(xml);
|
|
105
|
+
if (!match2) {
|
|
106
|
+
at2 = xml.indexOf("<", at2 + 1);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const [, closing, , selfClosing] = match2;
|
|
110
|
+
at2 = xml.indexOf("<", at2 + match2[0].length);
|
|
92
111
|
if (closing) {
|
|
93
112
|
depth--;
|
|
94
113
|
continue;
|
|
95
114
|
}
|
|
96
115
|
nodes++;
|
|
97
|
-
if (nodes > maxNodes) throw new Error(`${
|
|
116
|
+
if (nodes > maxNodes) throw new Error(`${label2} XML exceeds the limit of ${maxNodes} elements`);
|
|
98
117
|
if (!selfClosing && ++depth > maxDepth)
|
|
99
|
-
throw new Error(`${
|
|
118
|
+
throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
100
119
|
}
|
|
101
120
|
}
|
|
102
121
|
function parseXml(xml, options = {}) {
|
|
103
|
-
const
|
|
122
|
+
const label2 = options.label ?? "OOXML";
|
|
104
123
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
105
|
-
throw new Error(`${
|
|
106
|
-
checkXmlLimits(xml,
|
|
124
|
+
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
125
|
+
checkXmlLimits(xml, label2, options.limits);
|
|
107
126
|
let parseError = "";
|
|
108
127
|
let parsed;
|
|
109
128
|
try {
|
|
@@ -114,12 +133,12 @@ function parseXml(xml, options = {}) {
|
|
|
114
133
|
}).parseFromString(xml, "application/xml");
|
|
115
134
|
} catch (error) {
|
|
116
135
|
throw new Error(
|
|
117
|
-
`Invalid ${
|
|
136
|
+
`Invalid ${label2} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
118
137
|
{ cause: error }
|
|
119
138
|
);
|
|
120
139
|
}
|
|
121
140
|
if (parseError || !parsed.documentElement)
|
|
122
|
-
throw new Error(`Invalid ${
|
|
141
|
+
throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
|
|
123
142
|
return parsed;
|
|
124
143
|
}
|
|
125
144
|
var buildXml = (node3) => new xmldom.XMLSerializer().serializeToString(node3);
|
|
@@ -406,10 +425,10 @@ function withParseWarnings(warnings, fn) {
|
|
|
406
425
|
function reportParseWarning(message) {
|
|
407
426
|
if (sink && !sink.includes(message)) sink.push(message);
|
|
408
427
|
}
|
|
409
|
-
function enumValue(guard2, raw2,
|
|
428
|
+
function enumValue(guard2, raw2, label2) {
|
|
410
429
|
if (raw2 === null || raw2 === void 0 || raw2 === "") return void 0;
|
|
411
430
|
if (guard2(raw2)) return raw2;
|
|
412
|
-
reportParseWarning(`Ignored invalid ${
|
|
431
|
+
reportParseWarning(`Ignored invalid ${label2} value \u201C${raw2}\u201D; it is not allowed by the schema.`);
|
|
413
432
|
return void 0;
|
|
414
433
|
}
|
|
415
434
|
|
|
@@ -2298,7 +2317,7 @@ function flatChildren(parent, names, level = "block", enclosing, controls3 = /*
|
|
|
2298
2317
|
return found;
|
|
2299
2318
|
}
|
|
2300
2319
|
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
2301
|
-
var flatRows = (
|
|
2320
|
+
var flatRows = (table4) => flatChildren(table4, ["tr"], "row");
|
|
2302
2321
|
var flatCells = (row3) => flatChildren(row3, ["tc"], "cell");
|
|
2303
2322
|
var flatCellParagraphs = (cell) => flatChildren(cell, ["p"]);
|
|
2304
2323
|
|
|
@@ -3011,42 +3030,42 @@ function buildMargins(doc, margins, tag) {
|
|
|
3011
3030
|
}
|
|
3012
3031
|
return element2.childNodes.length ? element2 : void 0;
|
|
3013
3032
|
}
|
|
3014
|
-
function tableJustification(
|
|
3015
|
-
const { alignment, justification } =
|
|
3033
|
+
function tableJustification(table4) {
|
|
3034
|
+
const { alignment, justification } = table4;
|
|
3016
3035
|
const implied = justification === "start" ? "left" : justification === "end" ? "right" : justification;
|
|
3017
3036
|
return justification && implied === alignment ? justification : alignment;
|
|
3018
3037
|
}
|
|
3019
|
-
function tableColumnCount(
|
|
3038
|
+
function tableColumnCount(table4) {
|
|
3020
3039
|
return Math.max(
|
|
3021
3040
|
1,
|
|
3022
|
-
...
|
|
3041
|
+
...table4.rows.map((row3) => row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0))
|
|
3023
3042
|
);
|
|
3024
3043
|
}
|
|
3025
|
-
function buildNewTableProperties(doc,
|
|
3044
|
+
function buildNewTableProperties(doc, table4, contentWidthTwips) {
|
|
3026
3045
|
const tblPr = makeW(doc, "tblPr");
|
|
3027
|
-
if (
|
|
3046
|
+
if (table4.style) {
|
|
3028
3047
|
const style3 = makeW(doc, "tblStyle");
|
|
3029
|
-
setW2(style3, "val",
|
|
3048
|
+
setW2(style3, "val", table4.style);
|
|
3030
3049
|
tblPr.appendChild(style3);
|
|
3031
3050
|
}
|
|
3032
3051
|
const width = makeW(doc, "tblW");
|
|
3033
|
-
setW2(width, "w", String(
|
|
3034
|
-
setW2(width, "type",
|
|
3052
|
+
setW2(width, "w", String(table4.widthTwips ?? 0));
|
|
3053
|
+
setW2(width, "type", table4.widthTwips ? "dxa" : "auto");
|
|
3035
3054
|
tblPr.appendChild(width);
|
|
3036
|
-
const jcValue = tableJustification(
|
|
3055
|
+
const jcValue = tableJustification(table4);
|
|
3037
3056
|
if (jcValue) {
|
|
3038
3057
|
const jc = makeW(doc, "jc");
|
|
3039
3058
|
setW2(jc, "val", jcValue);
|
|
3040
3059
|
tblPr.appendChild(jc);
|
|
3041
3060
|
}
|
|
3042
|
-
if (
|
|
3061
|
+
if (table4.indentTwips !== void 0) {
|
|
3043
3062
|
const indent = makeW(doc, "tblInd");
|
|
3044
|
-
setW2(indent, "w", String(
|
|
3063
|
+
setW2(indent, "w", String(table4.indentTwips));
|
|
3045
3064
|
setW2(indent, "type", "dxa");
|
|
3046
3065
|
tblPr.appendChild(indent);
|
|
3047
3066
|
}
|
|
3048
|
-
if (
|
|
3049
|
-
const margins =
|
|
3067
|
+
if (table4.borders) tblPr.appendChild(buildBorders(doc, table4.borders, "tblBorders"));
|
|
3068
|
+
const margins = table4.cellMargins && buildMargins(doc, table4.cellMargins, "tblCellMar");
|
|
3050
3069
|
if (margins) tblPr.appendChild(margins);
|
|
3051
3070
|
const look = makeW(doc, "tblLook");
|
|
3052
3071
|
const lookAttributes = [
|
|
@@ -3061,8 +3080,8 @@ function buildNewTableProperties(doc, table3, contentWidthTwips) {
|
|
|
3061
3080
|
for (const [name3, value2] of lookAttributes) setW2(look, name3, value2);
|
|
3062
3081
|
tblPr.appendChild(look);
|
|
3063
3082
|
const tblGrid = makeW(doc, "tblGrid");
|
|
3064
|
-
const columns = tableColumnCount(
|
|
3065
|
-
const widths =
|
|
3083
|
+
const columns = tableColumnCount(table4);
|
|
3084
|
+
const widths = table4.grid?.length === columns ? table4.grid : Array.from({ length: columns }, () => Math.max(1, Math.floor(contentWidthTwips / columns)));
|
|
3066
3085
|
for (const value2 of widths) {
|
|
3067
3086
|
const column2 = makeW(doc, "gridCol");
|
|
3068
3087
|
setW2(column2, "w", String(value2));
|
|
@@ -3310,14 +3329,14 @@ function patchRowProperties(doc, tr, next, base2) {
|
|
|
3310
3329
|
}
|
|
3311
3330
|
orderChildren(props, ROW_ORDER);
|
|
3312
3331
|
}
|
|
3313
|
-
function patchTableMargins(doc,
|
|
3332
|
+
function patchTableMargins(doc, table4, node3, base2) {
|
|
3314
3333
|
patchMarginProperties(
|
|
3315
3334
|
doc,
|
|
3316
3335
|
node3,
|
|
3317
3336
|
"tblPr",
|
|
3318
3337
|
"tblCellMar",
|
|
3319
3338
|
TABLE_ORDER,
|
|
3320
|
-
|
|
3339
|
+
table4.cellMargins,
|
|
3321
3340
|
base2?.cellMargins
|
|
3322
3341
|
);
|
|
3323
3342
|
}
|
|
@@ -3412,12 +3431,12 @@ function patchCellShading(doc, tc, next, base2) {
|
|
|
3412
3431
|
}
|
|
3413
3432
|
|
|
3414
3433
|
// docx/write-table.ts
|
|
3415
|
-
function canEditTableStructure(
|
|
3434
|
+
function canEditTableStructure(table4) {
|
|
3416
3435
|
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node3) => allowed.some((name3) => named2(node3, name3)));
|
|
3417
|
-
if (!only(
|
|
3418
|
-
const grid = first2(
|
|
3436
|
+
if (!only(table4, ["tblPr", "tblGrid", "tr"])) return false;
|
|
3437
|
+
const grid = first2(table4, "tblGrid");
|
|
3419
3438
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
3420
|
-
const rows = children2(
|
|
3439
|
+
const rows = children2(table4, "tr");
|
|
3421
3440
|
if (!rows.length) return false;
|
|
3422
3441
|
const [firstRow] = rows;
|
|
3423
3442
|
if (!firstRow) return false;
|
|
@@ -3443,7 +3462,7 @@ function canEditTableStructure(table3) {
|
|
|
3443
3462
|
}
|
|
3444
3463
|
return true;
|
|
3445
3464
|
}
|
|
3446
|
-
var layout = (
|
|
3465
|
+
var layout = (table4) => table4.rows.map((row3) => row3.map((cell) => cell.paragraphs.map((p) => p.id)));
|
|
3447
3466
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
3448
3467
|
"grid",
|
|
3449
3468
|
"widthTwips",
|
|
@@ -3460,9 +3479,9 @@ function pick(source2, keys) {
|
|
|
3460
3479
|
for (const key2 of keys) if (record2[key2] !== void 0) result2[key2] = record2[key2];
|
|
3461
3480
|
return result2;
|
|
3462
3481
|
}
|
|
3463
|
-
function assertNoDescriptorEdits(
|
|
3482
|
+
function assertNoDescriptorEdits(table4, base2) {
|
|
3464
3483
|
if (!base2) return;
|
|
3465
|
-
if (JSON.stringify(pick(
|
|
3484
|
+
if (JSON.stringify(pick(table4, TABLE_DESCRIPTOR_KEYS)) !== JSON.stringify(pick(base2, TABLE_DESCRIPTOR_KEYS)))
|
|
3466
3485
|
throw new Error(
|
|
3467
3486
|
"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."
|
|
3468
3487
|
);
|
|
@@ -3472,7 +3491,7 @@ function assertNoDescriptorEdits(table3, base2) {
|
|
|
3472
3491
|
const id3 = cell.paragraphs[0]?.id;
|
|
3473
3492
|
if (id3) baseCellById.set(id3, cell);
|
|
3474
3493
|
}
|
|
3475
|
-
for (const row3 of
|
|
3494
|
+
for (const row3 of table4.rows)
|
|
3476
3495
|
for (const cell of row3) {
|
|
3477
3496
|
const id3 = cell.paragraphs[0]?.id;
|
|
3478
3497
|
const source2 = id3 ? baseCellById.get(id3) : void 0;
|
|
@@ -3488,23 +3507,23 @@ function writeNestedTables(doc, tc, cell, base2, writeParagraph, replaceSlots2)
|
|
|
3488
3507
|
const next = tables(cell.sourceBlocks);
|
|
3489
3508
|
const before = tables(base2?.sourceBlocks);
|
|
3490
3509
|
const nodes = children2(tc, "tbl");
|
|
3491
|
-
next.forEach((
|
|
3510
|
+
next.forEach((table4, index3) => {
|
|
3492
3511
|
const node3 = nodes[index3];
|
|
3493
3512
|
if (node3 && before[index3])
|
|
3494
|
-
writeTable(doc,
|
|
3513
|
+
writeTable(doc, table4, node3, before[index3], writeParagraph, replaceSlots2);
|
|
3495
3514
|
});
|
|
3496
3515
|
}
|
|
3497
|
-
function writeTable(doc,
|
|
3498
|
-
if (base2 && JSON.stringify(
|
|
3499
|
-
assertNoDescriptorEdits(
|
|
3500
|
-
patchTableMargins(doc,
|
|
3501
|
-
const structural = base2 && JSON.stringify(layout(
|
|
3516
|
+
function writeTable(doc, table4, node3, base2, writeParagraph, replaceSlots2) {
|
|
3517
|
+
if (base2 && JSON.stringify(table4) === JSON.stringify(base2)) return node3;
|
|
3518
|
+
assertNoDescriptorEdits(table4, base2);
|
|
3519
|
+
patchTableMargins(doc, table4, node3, base2);
|
|
3520
|
+
const structural = base2 && JSON.stringify(layout(table4)) !== JSON.stringify(layout(base2));
|
|
3502
3521
|
if (structural && !canEditTableStructure(node3))
|
|
3503
3522
|
throw new Error(
|
|
3504
3523
|
"Cannot change the structure of a merged, nested, or complex table. The original DOCX package remains unchanged."
|
|
3505
3524
|
);
|
|
3506
|
-
const width =
|
|
3507
|
-
if (!width ||
|
|
3525
|
+
const width = table4.rows[0]?.length ?? 0;
|
|
3526
|
+
if (!width || table4.rows.some((row3) => row3.length !== width || row3.some((cell) => !cell.paragraphs.length)))
|
|
3508
3527
|
throw new Error("Tables must contain rectangular rows and at least one paragraph per cell.");
|
|
3509
3528
|
const oldRows = flatRows(node3).map((entry3) => entry3.element);
|
|
3510
3529
|
const sourceById = /* @__PURE__ */ new Map();
|
|
@@ -3525,7 +3544,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3525
3544
|
const usedCells = /* @__PURE__ */ new Set();
|
|
3526
3545
|
const usedRows = /* @__PURE__ */ new Set();
|
|
3527
3546
|
const columns = /* @__PURE__ */ new Map();
|
|
3528
|
-
const nextRows =
|
|
3547
|
+
const nextRows = table4.rows.map((row3, rowIndex2) => {
|
|
3529
3548
|
const sources = row3.map(
|
|
3530
3549
|
(cell) => cell.paragraphs.map((p) => sourceById.get(p.id)).find(Boolean)
|
|
3531
3550
|
);
|
|
@@ -3540,7 +3559,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3540
3559
|
patchRowProperties(
|
|
3541
3560
|
doc,
|
|
3542
3561
|
tr,
|
|
3543
|
-
|
|
3562
|
+
table4.rowProperties?.[rowIndex2],
|
|
3544
3563
|
sourceRow === void 0 ? void 0 : base2?.rowProperties?.[sourceRow]
|
|
3545
3564
|
);
|
|
3546
3565
|
const nextCells = row3.map((cell, ci) => {
|
|
@@ -11566,8 +11585,8 @@ function gd14(name3, formula) {
|
|
|
11566
11585
|
const parts = formula.trim().split(/\s+/);
|
|
11567
11586
|
return { name: name3, formula, args: parts.slice(1) };
|
|
11568
11587
|
}
|
|
11569
|
-
function parseGdTable(
|
|
11570
|
-
return
|
|
11588
|
+
function parseGdTable(table4) {
|
|
11589
|
+
return table4.trim().split(/[\n;]/).filter((entry3) => entry3.length > 0).map((entry3) => {
|
|
11571
11590
|
const sep = entry3.indexOf("|");
|
|
11572
11591
|
return gd14(entry3.slice(0, sep), entry3.slice(sep + 1));
|
|
11573
11592
|
});
|
|
@@ -13460,8 +13479,8 @@ function parseDiagramDataModel(source2, part) {
|
|
|
13460
13479
|
"CONNECTION_ENDPOINT_MISSING",
|
|
13461
13480
|
`dgm:cxn ${attribute4} references missing point: ${id3}.`
|
|
13462
13481
|
);
|
|
13463
|
-
const
|
|
13464
|
-
connections2.push(
|
|
13482
|
+
const label2 = connectionLabel(connection, transitionText);
|
|
13483
|
+
connections2.push(label2 ? { ...connection, label: label2 } : connection);
|
|
13465
13484
|
if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
|
|
13466
13485
|
parentById.set(connection.destId, connection.sourceId);
|
|
13467
13486
|
}
|
|
@@ -13500,14 +13519,14 @@ function colorList(container) {
|
|
|
13500
13519
|
}
|
|
13501
13520
|
function parseDiagramColors(source2) {
|
|
13502
13521
|
const root = rootOf2(source2);
|
|
13503
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13504
|
-
name: stringAttribute(
|
|
13505
|
-
fill: colorList(first(
|
|
13506
|
-
line: colorList(first(
|
|
13507
|
-
effect: colorList(first(
|
|
13508
|
-
textLine: colorList(first(
|
|
13509
|
-
textFill: colorList(first(
|
|
13510
|
-
textEffect: colorList(first(
|
|
13522
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13523
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13524
|
+
fill: colorList(first(label2, "fillClrLst", NS.dgm)),
|
|
13525
|
+
line: colorList(first(label2, "linClrLst", NS.dgm)),
|
|
13526
|
+
effect: colorList(first(label2, "effectClrLst", NS.dgm)),
|
|
13527
|
+
textLine: colorList(first(label2, "txLinClrLst", NS.dgm)),
|
|
13528
|
+
textFill: colorList(first(label2, "txFillClrLst", NS.dgm)),
|
|
13529
|
+
textEffect: colorList(first(label2, "txEffectClrLst", NS.dgm))
|
|
13511
13530
|
}));
|
|
13512
13531
|
return { ...parseDefinitionHeader(root), labels };
|
|
13513
13532
|
}
|
|
@@ -13540,16 +13559,16 @@ function parseStyleReferences(style3) {
|
|
|
13540
13559
|
var hasContent = (element2) => Boolean(element2 && (element2.attributes.length > 0 || elements(element2).length > 0));
|
|
13541
13560
|
function parseDiagramQuickStyle(source2) {
|
|
13542
13561
|
const root = rootOf2(source2);
|
|
13543
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13544
|
-
name: stringAttribute(
|
|
13545
|
-
...parseStyleReferences(first(
|
|
13546
|
-
hasScene3d: Boolean(first(
|
|
13547
|
-
hasShape3d: hasContent(first(
|
|
13562
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13563
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13564
|
+
...parseStyleReferences(first(label2, "style", NS.dgm)),
|
|
13565
|
+
hasScene3d: Boolean(first(label2, "scene3d", NS.dgm)),
|
|
13566
|
+
hasShape3d: hasContent(first(label2, "sp3d", NS.dgm))
|
|
13548
13567
|
}));
|
|
13549
13568
|
return {
|
|
13550
13569
|
...parseDefinitionHeader(root),
|
|
13551
13570
|
labels,
|
|
13552
|
-
has3d: labels.some((
|
|
13571
|
+
has3d: labels.some((label2) => label2.hasShape3d)
|
|
13553
13572
|
};
|
|
13554
13573
|
}
|
|
13555
13574
|
function parseDiagramLayoutSummary(source2) {
|
|
@@ -14719,10 +14738,10 @@ function parseDisplayUnits(context, element2) {
|
|
|
14719
14738
|
if (!element2) return void 0;
|
|
14720
14739
|
reportUnmodelled(context, element2, DISPLAY_UNITS);
|
|
14721
14740
|
const labelElement = cChild(element2, "dispUnitsLbl");
|
|
14722
|
-
let
|
|
14741
|
+
let label2;
|
|
14723
14742
|
if (labelElement) {
|
|
14724
14743
|
reportUnmodelled(context, labelElement, DISPLAY_UNITS_LABEL);
|
|
14725
|
-
|
|
14744
|
+
label2 = assignDefined(
|
|
14726
14745
|
{},
|
|
14727
14746
|
{
|
|
14728
14747
|
layout: manualLayout(labelElement),
|
|
@@ -14737,7 +14756,7 @@ function parseDisplayUnits(context, element2) {
|
|
|
14737
14756
|
{
|
|
14738
14757
|
builtInUnit: cVal(element2, "builtInUnit"),
|
|
14739
14758
|
customUnit: cNumber(context, element2, "custUnit"),
|
|
14740
|
-
label:
|
|
14759
|
+
label: label2,
|
|
14741
14760
|
extLst: extensionList2(element2)
|
|
14742
14761
|
}
|
|
14743
14762
|
);
|
|
@@ -15591,10 +15610,10 @@ function titleXml(context, title) {
|
|
|
15591
15610
|
function labelOptionsXml(context, options) {
|
|
15592
15611
|
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));
|
|
15593
15612
|
}
|
|
15594
|
-
function labelXml(context,
|
|
15613
|
+
function labelXml(context, label2) {
|
|
15595
15614
|
return elementXml(
|
|
15596
15615
|
"dLbl",
|
|
15597
|
-
valXml("idx",
|
|
15616
|
+
valXml("idx", label2.index) + valXml("delete", label2.deleted) + layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + labelOptionsXml(context, label2) + raw(context, label2.extLst)
|
|
15598
15617
|
);
|
|
15599
15618
|
}
|
|
15600
15619
|
function dataLabelsXml(context, labels) {
|
|
@@ -15602,7 +15621,7 @@ function dataLabelsXml(context, labels) {
|
|
|
15602
15621
|
const leaderLines = labels.leaderLines ? elementXml("leaderLines", shapePropertiesXml(context, labels.leaderLines.spPr)) : "";
|
|
15603
15622
|
return elementXml(
|
|
15604
15623
|
"dLbls",
|
|
15605
|
-
labels.labels.map((
|
|
15624
|
+
labels.labels.map((label2) => labelXml(context, label2)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
|
|
15606
15625
|
);
|
|
15607
15626
|
}
|
|
15608
15627
|
|
|
@@ -15614,21 +15633,21 @@ function surfaceXml(context, local, surface) {
|
|
|
15614
15633
|
valXml("thickness", surface.thickness) + shapePropertiesXml(context, surface.spPr) + raw(context, surface.pictureOptionsXml) + raw(context, surface.extLst)
|
|
15615
15634
|
);
|
|
15616
15635
|
}
|
|
15617
|
-
function dataTableXml(context,
|
|
15618
|
-
if (!
|
|
15636
|
+
function dataTableXml(context, table4) {
|
|
15637
|
+
if (!table4) return "";
|
|
15619
15638
|
return elementXml(
|
|
15620
15639
|
"dTable",
|
|
15621
|
-
valXml("showHorzBorder",
|
|
15640
|
+
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)
|
|
15622
15641
|
);
|
|
15623
15642
|
}
|
|
15624
15643
|
function displayUnitsXml(context, units2) {
|
|
15625
15644
|
if (!units2) return "";
|
|
15626
|
-
const
|
|
15645
|
+
const label2 = units2.label;
|
|
15627
15646
|
return elementXml(
|
|
15628
15647
|
"dispUnits",
|
|
15629
|
-
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (
|
|
15648
|
+
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (label2 ? elementXml(
|
|
15630
15649
|
"dispUnitsLbl",
|
|
15631
|
-
layoutXml(context,
|
|
15650
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr)
|
|
15632
15651
|
) : "") + raw(context, units2.extLst)
|
|
15633
15652
|
);
|
|
15634
15653
|
}
|
|
@@ -15653,11 +15672,11 @@ function axisXml(context, axis) {
|
|
|
15653
15672
|
}
|
|
15654
15673
|
|
|
15655
15674
|
// chart/write-analysis.ts
|
|
15656
|
-
function trendlineLabelXml(context,
|
|
15657
|
-
if (!
|
|
15675
|
+
function trendlineLabelXml(context, label2) {
|
|
15676
|
+
if (!label2) return "";
|
|
15658
15677
|
return elementXml(
|
|
15659
15678
|
"trendlineLbl",
|
|
15660
|
-
layoutXml(context,
|
|
15679
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + numberFormatXml(label2.numberFormat) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr) + raw(context, label2.extLst)
|
|
15661
15680
|
);
|
|
15662
15681
|
}
|
|
15663
15682
|
function trendlineXml(context, trendline) {
|
|
@@ -17908,16 +17927,16 @@ var RelationshipAllocator = class {
|
|
|
17908
17927
|
|
|
17909
17928
|
// docx/write.ts
|
|
17910
17929
|
var twips2 = (pixels) => String(Math.round(pixels * 15));
|
|
17911
|
-
function createTable(doc,
|
|
17930
|
+
function createTable(doc, table4, allocator, contentWidthTwips, spans2) {
|
|
17912
17931
|
const node3 = makeW(doc, "tbl");
|
|
17913
|
-
const { tblPr, tblGrid } = buildNewTableProperties(doc,
|
|
17932
|
+
const { tblPr, tblGrid } = buildNewTableProperties(doc, table4, contentWidthTwips);
|
|
17914
17933
|
node3.appendChild(tblPr);
|
|
17915
17934
|
node3.appendChild(tblGrid);
|
|
17916
|
-
const columns = tableColumnCount(
|
|
17917
|
-
|
|
17935
|
+
const columns = tableColumnCount(table4);
|
|
17936
|
+
table4.rows.forEach((row3, rowIndex2) => {
|
|
17918
17937
|
const tr = makeW(doc, "tr");
|
|
17919
17938
|
const spanned = row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0);
|
|
17920
|
-
const trPr = buildRowProperties(doc,
|
|
17939
|
+
const trPr = buildRowProperties(doc, table4.rowProperties?.[rowIndex2], columns - spanned);
|
|
17921
17940
|
if (trPr) tr.appendChild(trPr);
|
|
17922
17941
|
for (const cell of row3) {
|
|
17923
17942
|
const tc = makeW(doc, "tc");
|
|
@@ -18320,28 +18339,28 @@ function validateCell(c2, cell) {
|
|
|
18320
18339
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18321
18340
|
c2.at(".margins").signed(side2, cell.margins[side2], "ST_SignedTwipsMeasure");
|
|
18322
18341
|
}
|
|
18323
|
-
function validateTable(c2,
|
|
18324
|
-
c2.unsigned("widthTwips",
|
|
18325
|
-
c2.signed("indentTwips",
|
|
18342
|
+
function validateTable(c2, table4) {
|
|
18343
|
+
c2.unsigned("widthTwips", table4.widthTwips, "ST_TwipsMeasure");
|
|
18344
|
+
c2.signed("indentTwips", table4.indentTwips, "ST_SignedTwipsMeasure");
|
|
18326
18345
|
c2.check(
|
|
18327
18346
|
"alignment",
|
|
18328
|
-
|
|
18347
|
+
table4.alignment,
|
|
18329
18348
|
(v) => v === "left" || v === "center" || v === "right",
|
|
18330
18349
|
'must be "left", "center" or "right"'
|
|
18331
18350
|
);
|
|
18332
|
-
c2.enum("justification",
|
|
18333
|
-
|
|
18351
|
+
c2.enum("justification", table4.justification, isStJcTable, "ST_JcTable");
|
|
18352
|
+
table4.grid?.forEach(
|
|
18334
18353
|
(width, index3) => c2.at(`.grid[${index3}]`).unsigned("width", width, "ST_TwipsMeasure")
|
|
18335
18354
|
);
|
|
18336
|
-
validateBorders(c2.at(".borders"),
|
|
18337
|
-
if (
|
|
18355
|
+
validateBorders(c2.at(".borders"), table4.borders);
|
|
18356
|
+
if (table4.cellMargins)
|
|
18338
18357
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18339
|
-
c2.at(".cellMargins").signed(side2,
|
|
18340
|
-
|
|
18358
|
+
c2.at(".cellMargins").signed(side2, table4.cellMargins[side2], "ST_SignedTwipsMeasure");
|
|
18359
|
+
table4.rowProperties?.forEach((row3, index3) => {
|
|
18341
18360
|
if (row3)
|
|
18342
18361
|
c2.at(`.rowProperties[${index3}]`).unsigned("heightTwips", row3.heightTwips, "ST_TwipsMeasure");
|
|
18343
18362
|
});
|
|
18344
|
-
|
|
18363
|
+
table4.rows.forEach(
|
|
18345
18364
|
(row3, r) => row3.forEach((cell, k) => validateCell(c2.at(`.rows[${r}][${k}]`), cell))
|
|
18346
18365
|
);
|
|
18347
18366
|
}
|
|
@@ -19773,40 +19792,40 @@ function parseTable(node3, id3, parseParagraph3) {
|
|
|
19773
19792
|
(cell, ci) => parseCell(cell.element, parseParagraph3, `${id3}-r${ri}c${ci}`, cell.control)
|
|
19774
19793
|
)
|
|
19775
19794
|
);
|
|
19776
|
-
const
|
|
19795
|
+
const table4 = { type: "table", id: id3, rows, structureEditable: canEditTableStructure(node3) };
|
|
19777
19796
|
const gridElement = first2(node3, "tblGrid");
|
|
19778
19797
|
const grid = gridElement ? children2(gridElement, "gridCol").flatMap((column2) => {
|
|
19779
19798
|
const width2 = dxa(getW(column2, "w"));
|
|
19780
19799
|
return width2 === void 0 ? [] : [width2];
|
|
19781
19800
|
}) : [];
|
|
19782
|
-
if (grid.length)
|
|
19801
|
+
if (grid.length) table4.grid = grid;
|
|
19783
19802
|
const tblPr = first2(node3, "tblPr");
|
|
19784
19803
|
const tableWidth = first2(tblPr, "tblW");
|
|
19785
19804
|
const width = (getW(tableWidth, "type") ?? "dxa") === "dxa" ? dxa(getW(tableWidth, "w")) : void 0;
|
|
19786
|
-
if (width !== void 0)
|
|
19805
|
+
if (width !== void 0) table4.widthTwips = width;
|
|
19787
19806
|
const justification = enumValue(isStJcTable, getW(first2(tblPr, "jc"), "val"), "w:tblPr/w:jc");
|
|
19788
19807
|
if (justification) {
|
|
19789
|
-
|
|
19808
|
+
table4.justification = justification;
|
|
19790
19809
|
const rtl = onOffElement(first2(tblPr, "bidiVisual")) === true;
|
|
19791
|
-
|
|
19810
|
+
table4.alignment = justification === "start" ? rtl ? "right" : "left" : justification === "end" ? rtl ? "left" : "right" : justification;
|
|
19792
19811
|
}
|
|
19793
19812
|
const indent = parseSignedTwips(getW(first2(tblPr, "tblInd"), "w"));
|
|
19794
|
-
if (indent !== void 0)
|
|
19813
|
+
if (indent !== void 0) table4.indentTwips = indent;
|
|
19795
19814
|
const borders = parseTableBorders(first2(tblPr, "tblBorders"));
|
|
19796
|
-
if (borders)
|
|
19815
|
+
if (borders) table4.borders = borders;
|
|
19797
19816
|
const styleId = getW(first2(tblPr, "tblStyle"), "val");
|
|
19798
|
-
if (styleId)
|
|
19817
|
+
if (styleId) table4.style = styleId;
|
|
19799
19818
|
const look = parseLook(first2(tblPr, "tblLook"));
|
|
19800
|
-
if (look)
|
|
19819
|
+
if (look) table4.look = look;
|
|
19801
19820
|
const cellMargins = parseMargins(first2(tblPr, "tblCellMar"));
|
|
19802
|
-
if (cellMargins)
|
|
19821
|
+
if (cellMargins) table4.cellMargins = cellMargins;
|
|
19803
19822
|
const rowProperties = rowEntries.map(({ element: element2, control }) => {
|
|
19804
19823
|
const properties = parseRowProperties(element2);
|
|
19805
19824
|
if (control) properties.contentControl = control;
|
|
19806
19825
|
return properties;
|
|
19807
19826
|
});
|
|
19808
|
-
if (rowProperties.some((row3) => Object.keys(row3).length))
|
|
19809
|
-
return
|
|
19827
|
+
if (rowProperties.some((row3) => Object.keys(row3).length)) table4.rowProperties = rowProperties;
|
|
19828
|
+
return table4;
|
|
19810
19829
|
}
|
|
19811
19830
|
|
|
19812
19831
|
// docx/hyperlink.ts
|
|
@@ -20860,19 +20879,19 @@ var nextSheetId = (workbook) => workbook.sheets.reduce((max, sheet) => Math.max(
|
|
|
20860
20879
|
var MAX_ROW = 1048575;
|
|
20861
20880
|
var MAX_COL = 16383;
|
|
20862
20881
|
function columnLabel(col) {
|
|
20863
|
-
let
|
|
20882
|
+
let label2 = "";
|
|
20864
20883
|
let n = col + 1;
|
|
20865
20884
|
while (n > 0) {
|
|
20866
20885
|
const rem = (n - 1) % 26;
|
|
20867
|
-
|
|
20886
|
+
label2 = String.fromCharCode(65 + rem) + label2;
|
|
20868
20887
|
n = Math.floor((n - 1) / 26);
|
|
20869
20888
|
}
|
|
20870
|
-
return
|
|
20889
|
+
return label2;
|
|
20871
20890
|
}
|
|
20872
|
-
function columnIndex(
|
|
20873
|
-
if (!/^[A-Za-z]{1,3}$/.test(
|
|
20891
|
+
function columnIndex(label2) {
|
|
20892
|
+
if (!/^[A-Za-z]{1,3}$/.test(label2)) return -1;
|
|
20874
20893
|
let n = 0;
|
|
20875
|
-
for (const ch of
|
|
20894
|
+
for (const ch of label2.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
20876
20895
|
return n - 1;
|
|
20877
20896
|
}
|
|
20878
20897
|
var formatAddress = (address2) => `${columnLabel(address2.col)}${address2.row + 1}`;
|
|
@@ -23243,6 +23262,223 @@ var pivotColumnFields = (pivot) => [
|
|
|
23243
23262
|
...pivot.columnField ? pivot.moreColumnFields ?? [] : []
|
|
23244
23263
|
];
|
|
23245
23264
|
|
|
23265
|
+
// i18n/locale.ts
|
|
23266
|
+
var SUPPORTED_OFFICE_LOCALES = ["en", "fr", "de", "es", "zh-CN"];
|
|
23267
|
+
var DEFAULT_REJECTED_SUBTAGS = ["hant", "tw", "hk", "mo"];
|
|
23268
|
+
function normalizeLocale(input, supported2, fallback, options = {}) {
|
|
23269
|
+
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
23270
|
+
const language = parts[0];
|
|
23271
|
+
if (!language) return fallback;
|
|
23272
|
+
const find3 = (tag) => supported2.find((item) => item.toLowerCase() === tag);
|
|
23273
|
+
const exact = find3(parts.join("-"));
|
|
23274
|
+
if (exact) return exact;
|
|
23275
|
+
const base2 = find3(language);
|
|
23276
|
+
if (base2) return base2;
|
|
23277
|
+
const rejected = options.rejectedSubtags ?? DEFAULT_REJECTED_SUBTAGS;
|
|
23278
|
+
if (parts.slice(1).some((part) => rejected.includes(part))) return fallback;
|
|
23279
|
+
return supported2.find((item) => item.toLowerCase().split("-")[0] === language && item.includes("-")) ?? fallback;
|
|
23280
|
+
}
|
|
23281
|
+
function normalizeOfficeLocale(input) {
|
|
23282
|
+
return normalizeLocale(input, SUPPORTED_OFFICE_LOCALES, "en");
|
|
23283
|
+
}
|
|
23284
|
+
|
|
23285
|
+
// xlsx/pivot/captions-locales.ts
|
|
23286
|
+
var table = (words2, prefix3, rest, functions) => ({
|
|
23287
|
+
...rest,
|
|
23288
|
+
functions,
|
|
23289
|
+
aggregates: Object.fromEntries(
|
|
23290
|
+
Object.keys(words2).map((fn) => [fn, prefix3(words2[fn])])
|
|
23291
|
+
)
|
|
23292
|
+
});
|
|
23293
|
+
var GERMAN = {
|
|
23294
|
+
sum: "Summe",
|
|
23295
|
+
count: "Anzahl",
|
|
23296
|
+
average: "Mittelwert",
|
|
23297
|
+
max: "Max",
|
|
23298
|
+
min: "Min",
|
|
23299
|
+
product: "Produkt",
|
|
23300
|
+
countNums: "Anzahl (Zahlen)",
|
|
23301
|
+
stdDev: "Standardabweichung",
|
|
23302
|
+
stdDevp: "Standardabweichung (Grundgesamtheit)",
|
|
23303
|
+
var: "Varianz",
|
|
23304
|
+
varp: "Varianz (Grundgesamtheit)"
|
|
23305
|
+
};
|
|
23306
|
+
var SPANISH = {
|
|
23307
|
+
sum: "Suma",
|
|
23308
|
+
count: "Cuenta",
|
|
23309
|
+
average: "Promedio",
|
|
23310
|
+
max: "M\xE1x",
|
|
23311
|
+
min: "M\xEDn",
|
|
23312
|
+
product: "Producto",
|
|
23313
|
+
countNums: "Cuenta de n\xFAmeros",
|
|
23314
|
+
stdDev: "Desvest",
|
|
23315
|
+
stdDevp: "Desvestp",
|
|
23316
|
+
var: "Var",
|
|
23317
|
+
varp: "Varp"
|
|
23318
|
+
};
|
|
23319
|
+
var FRENCH = {
|
|
23320
|
+
sum: "Somme",
|
|
23321
|
+
count: "Nombre",
|
|
23322
|
+
average: "Moyenne",
|
|
23323
|
+
max: "Max",
|
|
23324
|
+
min: "Min",
|
|
23325
|
+
product: "Produit",
|
|
23326
|
+
countNums: "Nombre (nombres)",
|
|
23327
|
+
stdDev: "\xC9cartype",
|
|
23328
|
+
stdDevp: "\xC9cartypep",
|
|
23329
|
+
var: "Var",
|
|
23330
|
+
varp: "Varp"
|
|
23331
|
+
};
|
|
23332
|
+
var CHINESE = {
|
|
23333
|
+
sum: "\u6C42\u548C",
|
|
23334
|
+
count: "\u8BA1\u6570",
|
|
23335
|
+
average: "\u5E73\u5747\u503C",
|
|
23336
|
+
max: "\u6700\u5927\u503C",
|
|
23337
|
+
min: "\u6700\u5C0F\u503C",
|
|
23338
|
+
product: "\u4E58\u79EF",
|
|
23339
|
+
countNums: "\u6570\u503C\u8BA1\u6570",
|
|
23340
|
+
stdDev: "\u6807\u51C6\u504F\u5DEE",
|
|
23341
|
+
stdDevp: "\u603B\u4F53\u6807\u51C6\u504F\u5DEE",
|
|
23342
|
+
var: "\u65B9\u5DEE",
|
|
23343
|
+
varp: "\u603B\u4F53\u65B9\u5DEE"
|
|
23344
|
+
};
|
|
23345
|
+
var LOCALIZED_PIVOT_CAPTIONS = {
|
|
23346
|
+
de: table(
|
|
23347
|
+
GERMAN,
|
|
23348
|
+
(word) => `${word} von {0}`,
|
|
23349
|
+
{
|
|
23350
|
+
rowLabels: "Zeilenbeschriftungen",
|
|
23351
|
+
columnLabels: "Spaltenbeschriftungen",
|
|
23352
|
+
grandTotal: "Gesamtergebnis",
|
|
23353
|
+
values: "Werte",
|
|
23354
|
+
all: "(Alle)",
|
|
23355
|
+
blank: "(leer)",
|
|
23356
|
+
subtotal: "{0} Ergebnis",
|
|
23357
|
+
measureTotal: "Gesamt {0}"
|
|
23358
|
+
},
|
|
23359
|
+
GERMAN
|
|
23360
|
+
),
|
|
23361
|
+
es: table(
|
|
23362
|
+
SPANISH,
|
|
23363
|
+
(word) => `${word} de {0}`,
|
|
23364
|
+
{
|
|
23365
|
+
rowLabels: "Etiquetas de fila",
|
|
23366
|
+
columnLabels: "Etiquetas de columna",
|
|
23367
|
+
grandTotal: "Total general",
|
|
23368
|
+
values: "Valores",
|
|
23369
|
+
all: "(Todas)",
|
|
23370
|
+
blank: "(en blanco)",
|
|
23371
|
+
subtotal: "{0} Total",
|
|
23372
|
+
measureTotal: "Total {0}"
|
|
23373
|
+
},
|
|
23374
|
+
SPANISH
|
|
23375
|
+
),
|
|
23376
|
+
fr: table(
|
|
23377
|
+
FRENCH,
|
|
23378
|
+
(word) => `${word} de {0}`,
|
|
23379
|
+
{
|
|
23380
|
+
rowLabels: "\xC9tiquettes de lignes",
|
|
23381
|
+
columnLabels: "\xC9tiquettes de colonnes",
|
|
23382
|
+
grandTotal: "Total g\xE9n\xE9ral",
|
|
23383
|
+
values: "Valeurs",
|
|
23384
|
+
all: "(Tous)",
|
|
23385
|
+
blank: "(vide)",
|
|
23386
|
+
subtotal: "{0} Total",
|
|
23387
|
+
measureTotal: "Total {0}"
|
|
23388
|
+
},
|
|
23389
|
+
FRENCH
|
|
23390
|
+
),
|
|
23391
|
+
"zh-CN": table(
|
|
23392
|
+
CHINESE,
|
|
23393
|
+
(word) => `${word}\u9879:{0}`,
|
|
23394
|
+
{
|
|
23395
|
+
rowLabels: "\u884C\u6807\u7B7E",
|
|
23396
|
+
columnLabels: "\u5217\u6807\u7B7E",
|
|
23397
|
+
grandTotal: "\u603B\u8BA1",
|
|
23398
|
+
values: "\u6570\u503C",
|
|
23399
|
+
all: "(\u5168\u90E8)",
|
|
23400
|
+
blank: "(\u7A7A\u767D)",
|
|
23401
|
+
subtotal: "{0} \u6C47\u603B",
|
|
23402
|
+
measureTotal: "\u603B\u8BA1 {0}"
|
|
23403
|
+
},
|
|
23404
|
+
CHINESE
|
|
23405
|
+
)
|
|
23406
|
+
};
|
|
23407
|
+
|
|
23408
|
+
// xlsx/pivot/captions.ts
|
|
23409
|
+
var FUNCTIONS = {
|
|
23410
|
+
sum: "Sum",
|
|
23411
|
+
count: "Count",
|
|
23412
|
+
average: "Average",
|
|
23413
|
+
max: "Max",
|
|
23414
|
+
min: "Min",
|
|
23415
|
+
product: "Product",
|
|
23416
|
+
countNums: "Count",
|
|
23417
|
+
stdDev: "StdDev",
|
|
23418
|
+
stdDevp: "StdDevp",
|
|
23419
|
+
var: "Var",
|
|
23420
|
+
varp: "Varp"
|
|
23421
|
+
};
|
|
23422
|
+
var aggregateNames = () => Object.fromEntries(
|
|
23423
|
+
Object.keys(FUNCTIONS).map((fn) => [
|
|
23424
|
+
fn,
|
|
23425
|
+
`${fn[0].toUpperCase()}${fn.slice(1)} of {0}`
|
|
23426
|
+
])
|
|
23427
|
+
);
|
|
23428
|
+
var ENGLISH_PIVOT_CAPTIONS = {
|
|
23429
|
+
rowLabels: "Row Labels",
|
|
23430
|
+
columnLabels: "Column Labels",
|
|
23431
|
+
grandTotal: "Grand Total",
|
|
23432
|
+
values: "Values",
|
|
23433
|
+
all: "(All)",
|
|
23434
|
+
blank: "(blank)",
|
|
23435
|
+
subtotal: "{0} Total",
|
|
23436
|
+
measureTotal: "Total {0}",
|
|
23437
|
+
functions: FUNCTIONS,
|
|
23438
|
+
aggregates: aggregateNames()
|
|
23439
|
+
};
|
|
23440
|
+
var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
|
|
23441
|
+
function pivotCaptions(pivot) {
|
|
23442
|
+
const own2 = pivot.captions;
|
|
23443
|
+
if (!own2) return ENGLISH_PIVOT_CAPTIONS;
|
|
23444
|
+
return {
|
|
23445
|
+
...ENGLISH_PIVOT_CAPTIONS,
|
|
23446
|
+
...Object.fromEntries(Object.entries(own2).filter(([, value2]) => typeof value2 === "string")),
|
|
23447
|
+
functions: { ...ENGLISH_PIVOT_CAPTIONS.functions, ...own2.functions },
|
|
23448
|
+
aggregates: { ...ENGLISH_PIVOT_CAPTIONS.aggregates, ...own2.aggregates }
|
|
23449
|
+
};
|
|
23450
|
+
}
|
|
23451
|
+
var pivotMeasureName = (aggregate2, field2, pivot = {}) => fillCaption(pivotCaptions(pivot).aggregates[aggregate2], field2);
|
|
23452
|
+
function localizedPivotCaptions(locale) {
|
|
23453
|
+
const caps = LOCALIZED_PIVOT_CAPTIONS[normalizeOfficeLocale(locale)];
|
|
23454
|
+
return caps ? structuredClone(caps) : void 0;
|
|
23455
|
+
}
|
|
23456
|
+
function trimmedCaptions(caps) {
|
|
23457
|
+
const out = {};
|
|
23458
|
+
for (const key2 of [
|
|
23459
|
+
"rowLabels",
|
|
23460
|
+
"columnLabels",
|
|
23461
|
+
"grandTotal",
|
|
23462
|
+
"values",
|
|
23463
|
+
"all",
|
|
23464
|
+
"blank",
|
|
23465
|
+
"subtotal",
|
|
23466
|
+
"measureTotal"
|
|
23467
|
+
])
|
|
23468
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2]) out[key2] = caps[key2];
|
|
23469
|
+
for (const key2 of ["functions", "aggregates"]) {
|
|
23470
|
+
const changed = Object.keys(caps[key2]).filter(
|
|
23471
|
+
(fn) => caps[key2][fn] !== ENGLISH_PIVOT_CAPTIONS[key2][fn]
|
|
23472
|
+
);
|
|
23473
|
+
if (changed.length) out[key2] = Object.fromEntries(changed.map((fn) => [fn, caps[key2][fn]]));
|
|
23474
|
+
}
|
|
23475
|
+
return Object.keys(out).length ? out : void 0;
|
|
23476
|
+
}
|
|
23477
|
+
function authoredCaptions(options) {
|
|
23478
|
+
const own2 = options.captions ?? localizedPivotCaptions(options.locale);
|
|
23479
|
+
return own2 && Object.keys(own2).length ? structuredClone(own2) : void 0;
|
|
23480
|
+
}
|
|
23481
|
+
|
|
23246
23482
|
// xlsx/formula/date-serial.ts
|
|
23247
23483
|
var DAY_MS = 864e5;
|
|
23248
23484
|
var EPOCH_19002 = Date.UTC(1899, 11, 30);
|
|
@@ -23501,9 +23737,9 @@ function expandDateGroups(pivot) {
|
|
|
23501
23737
|
fields: [...pivot.fields, ...derived.map((entry3) => entry3.name)],
|
|
23502
23738
|
records: pivot.records.map((record2) => [
|
|
23503
23739
|
...record2,
|
|
23504
|
-
...tables.map((
|
|
23505
|
-
const value2 = record2[
|
|
23506
|
-
return typeof value2 === "number" ?
|
|
23740
|
+
...tables.map((table4) => {
|
|
23741
|
+
const value2 = record2[table4.base];
|
|
23742
|
+
return typeof value2 === "number" ? table4.labels[table4.index(value2)] : null;
|
|
23507
23743
|
})
|
|
23508
23744
|
])
|
|
23509
23745
|
};
|
|
@@ -23707,6 +23943,17 @@ function pruneItemFilters(pivot) {
|
|
|
23707
23943
|
return next.length ? next : void 0;
|
|
23708
23944
|
}
|
|
23709
23945
|
|
|
23946
|
+
// xlsx/pivot/item-labels.ts
|
|
23947
|
+
var keyOf = (field2, item) => `${field2}\0${pivotValueKey(item)}`;
|
|
23948
|
+
function pivotItemLabeler(pivot) {
|
|
23949
|
+
const blank = pivotCaptions(pivot).blank;
|
|
23950
|
+
const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
|
|
23951
|
+
return (field2, value2) => names?.get(keyOf(field2, value2)) ?? (value2 === null || value2 === "" ? blank : pivotItemLabel(value2));
|
|
23952
|
+
}
|
|
23953
|
+
var pivotItemName = (pivot, field2, item) => pivot.itemNames?.find(
|
|
23954
|
+
(entry3) => entry3.field === field2 && pivotValueKey(entry3.item) === pivotValueKey(item)
|
|
23955
|
+
)?.name;
|
|
23956
|
+
|
|
23710
23957
|
// xlsx/pivot/page-filter.ts
|
|
23711
23958
|
function validatePivotPageFilter(pivot) {
|
|
23712
23959
|
const filter2 = pivot.pageFilter;
|
|
@@ -23718,8 +23965,8 @@ function validatePivotPageFilter(pivot) {
|
|
|
23718
23965
|
pivot.columnField,
|
|
23719
23966
|
pivot.valueField,
|
|
23720
23967
|
...extras.map((v) => v?.field)
|
|
23721
|
-
].includes(filter2.field)
|
|
23722
|
-
throw new Error("Report filters require
|
|
23968
|
+
].includes(filter2.field))
|
|
23969
|
+
throw new Error("Report filters require a separate source field.");
|
|
23723
23970
|
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))
|
|
23724
23971
|
throw new Error("Choose a cached literal report filter item.");
|
|
23725
23972
|
}
|
|
@@ -23732,10 +23979,10 @@ function pagedProjection(pivot) {
|
|
|
23732
23979
|
if (!filter2) return pivot;
|
|
23733
23980
|
const labels = /* @__PURE__ */ new Map();
|
|
23734
23981
|
for (const item of pivotItems(pivot, filter2.field)) {
|
|
23735
|
-
const
|
|
23736
|
-
if (
|
|
23982
|
+
const label2 = String(pivotItemLabel(item)).toLowerCase(), key3 = pivotValueKey(item);
|
|
23983
|
+
if (label2 === "(all)" || labels.has(label2) && labels.get(label2) !== key3)
|
|
23737
23984
|
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
23738
|
-
labels.set(
|
|
23985
|
+
labels.set(label2, key3);
|
|
23739
23986
|
}
|
|
23740
23987
|
if (filter2.item === void 0) return pivot;
|
|
23741
23988
|
const index3 = pivot.fields.indexOf(filter2.field), key2 = pivotValueKey(filter2.item);
|
|
@@ -23753,7 +24000,7 @@ function prependPivotPage(grid, pivot) {
|
|
|
23753
24000
|
values: [
|
|
23754
24001
|
[
|
|
23755
24002
|
pivot.pageFilter.field,
|
|
23756
|
-
pivot.pageFilter.item === void 0 ?
|
|
24003
|
+
pivot.pageFilter.item === void 0 ? pivotCaptions(pivot).all : pivotItemLabeler(pivot)(pivot.pageFilter.field, pivot.pageFilter.item),
|
|
23757
24004
|
...Array(width - 2).fill(null)
|
|
23758
24005
|
],
|
|
23759
24006
|
Array(width).fill(null),
|
|
@@ -23892,7 +24139,7 @@ function validatePivotFields(pivot) {
|
|
|
23892
24139
|
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
23893
24140
|
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
23894
24141
|
throw new Error("Values on rows require multiple measures.");
|
|
23895
|
-
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !==
|
|
24142
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
|
|
23896
24143
|
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
23897
24144
|
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
23898
24145
|
(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())
|
|
@@ -23905,8 +24152,8 @@ function validatePivotFields(pivot) {
|
|
|
23905
24152
|
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")
|
|
23906
24153
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
23907
24154
|
}
|
|
23908
|
-
function pivotCaption(aggregate2, field2) {
|
|
23909
|
-
return
|
|
24155
|
+
function pivotCaption(aggregate2, field2, pivot) {
|
|
24156
|
+
return pivotMeasureName(aggregate2, field2, pivot);
|
|
23910
24157
|
}
|
|
23911
24158
|
|
|
23912
24159
|
// xlsx/write/xml-out.ts
|
|
@@ -23953,7 +24200,7 @@ var pivotMeasures = (pivot) => [
|
|
|
23953
24200
|
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
23954
24201
|
...pivot.additionalValues ?? []
|
|
23955
24202
|
];
|
|
23956
|
-
function normalizedPivotMeasures(values2) {
|
|
24203
|
+
function normalizedPivotMeasures(values2, pivot) {
|
|
23957
24204
|
if (!Array.isArray(values2) || values2.length > 15)
|
|
23958
24205
|
throw new Error("Choose between one and sixteen PivotTable value fields.");
|
|
23959
24206
|
return values2.map((value2) => {
|
|
@@ -23965,7 +24212,7 @@ function normalizedPivotMeasures(values2) {
|
|
|
23965
24212
|
return {
|
|
23966
24213
|
field: value2.field,
|
|
23967
24214
|
aggregate: aggregate2,
|
|
23968
|
-
caption: value2.caption ??
|
|
24215
|
+
caption: value2.caption ?? pivotMeasureName(aggregate2, value2.field, pivot)
|
|
23969
24216
|
};
|
|
23970
24217
|
});
|
|
23971
24218
|
}
|
|
@@ -24000,7 +24247,6 @@ var pivotMeasureNumber = (pivot, records, measure2) => aggregateValues(records,
|
|
|
24000
24247
|
|
|
24001
24248
|
// xlsx/pivot/columns.ts
|
|
24002
24249
|
var SEPARATOR = "";
|
|
24003
|
-
var label = pivotItemLabel;
|
|
24004
24250
|
var columnKey = (keys, depth) => keys.slice(0, depth).join(SEPARATOR);
|
|
24005
24251
|
var recordColumnKeys = (record2, indices) => indices.map((index3) => pivotValueKey(record2[index3] ?? null));
|
|
24006
24252
|
function pivotColumnEntries(pivot) {
|
|
@@ -24075,7 +24321,9 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
|
24075
24321
|
const rows = levels + 1 + Number(count2 > 1);
|
|
24076
24322
|
const grid = Array.from({ length: rows }, () => Array(width).fill(null));
|
|
24077
24323
|
if (count2 === 1 && !valuesOnRows) grid[0][0] = pivot.valueCaption;
|
|
24078
|
-
const
|
|
24324
|
+
const caps = pivotCaptions(pivot);
|
|
24325
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24326
|
+
const titles = compact3 ? [caps.columnLabels] : [...columns.names, ...count2 > 1 ? [caps.values] : []];
|
|
24079
24327
|
titles.forEach((title, i2) => {
|
|
24080
24328
|
grid[0][labelColumns + i2] = title;
|
|
24081
24329
|
});
|
|
@@ -24088,17 +24336,17 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
|
24088
24336
|
if (entry3.kind === "leaf") {
|
|
24089
24337
|
entry3.path.forEach((_index, level) => {
|
|
24090
24338
|
const continued = entry3.path.slice(0, level + 1).every((p, i2) => p === previous[i2]);
|
|
24091
|
-
if (!continued) grid[1 + level][at2] =
|
|
24339
|
+
if (!continued) grid[1 + level][at2] = labelOf(columns.names[level], entry3.values[level]);
|
|
24092
24340
|
});
|
|
24093
24341
|
previous = entry3.path;
|
|
24094
24342
|
if (count2 > 1) measures2.forEach((measure2, m) => grid[rows - 1][at2 + m] = measure2.caption);
|
|
24095
24343
|
return;
|
|
24096
24344
|
}
|
|
24097
24345
|
const row3 = entry3.kind === "grand" ? 1 : entry3.path.length;
|
|
24098
|
-
const name3 = entry3.kind === "grand" ? "" : String(
|
|
24346
|
+
const name3 = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
|
|
24099
24347
|
measures2.forEach((measure2, m) => {
|
|
24100
|
-
const custom = entry3.fn ?
|
|
24101
|
-
grid[row3][at2 + m] = custom ? count2 === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure2.field}` : count2 === 1 ? entry3.kind === "grand" ?
|
|
24348
|
+
const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
|
|
24349
|
+
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}`;
|
|
24102
24350
|
});
|
|
24103
24351
|
});
|
|
24104
24352
|
return grid;
|
|
@@ -24131,7 +24379,6 @@ function pivotColumnItemsXml(entries, measures2, remap) {
|
|
|
24131
24379
|
}
|
|
24132
24380
|
|
|
24133
24381
|
// xlsx/pivot/nested.ts
|
|
24134
|
-
var label2 = pivotItemLabel;
|
|
24135
24382
|
var MAX_CELLS = 1e6;
|
|
24136
24383
|
var node = (index3, value2) => ({
|
|
24137
24384
|
index: index3,
|
|
@@ -24161,6 +24408,8 @@ function nestedPivotGrid(pivot) {
|
|
|
24161
24408
|
const labelColumns = compact3 ? 1 : levels;
|
|
24162
24409
|
const measures2 = pivotMeasures(pivot);
|
|
24163
24410
|
const functions = names.map((name3) => fieldSubtotalFunctions(pivot, name3));
|
|
24411
|
+
const caps = pivotCaptions(pivot);
|
|
24412
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24164
24413
|
const root = node(0, null);
|
|
24165
24414
|
for (const record2 of pivot.records) {
|
|
24166
24415
|
const keys = recordColumnKeys(record2, columnFields);
|
|
@@ -24187,7 +24436,7 @@ function nestedPivotGrid(pivot) {
|
|
|
24187
24436
|
}
|
|
24188
24437
|
const dimensions3 = pivotColumnDimensions(pivot, columns, labelColumns, onRows);
|
|
24189
24438
|
const rowTitles = names.map((name3) => name3);
|
|
24190
|
-
if (onRows) rowTitles.splice(valuesAt, 0,
|
|
24439
|
+
if (onRows) rowTitles.splice(valuesAt, 0, caps.values);
|
|
24191
24440
|
let values2 = [];
|
|
24192
24441
|
let indents = [];
|
|
24193
24442
|
const rowEntries = [];
|
|
@@ -24266,11 +24515,11 @@ function nestedPivotGrid(pivot) {
|
|
|
24266
24515
|
const children4 = [...group.children.values()].sort((a2, b) => a2.index - b.index);
|
|
24267
24516
|
children4.forEach((child7, position2) => {
|
|
24268
24517
|
const here = {
|
|
24269
|
-
labels: [...path2.labels,
|
|
24518
|
+
labels: [...path2.labels, labelOf(names[field2], child7.value)],
|
|
24270
24519
|
indices: [...path2.indices, child7.index],
|
|
24271
24520
|
firsts: [...path2.firsts, position2 === 0]
|
|
24272
24521
|
};
|
|
24273
|
-
const text8 =
|
|
24522
|
+
const text8 = labelOf(names[field2], child7.value);
|
|
24274
24523
|
if (last)
|
|
24275
24524
|
return push3(level, () => [
|
|
24276
24525
|
labelCells(path2, leafShown(here.firsts), level, text8),
|
|
@@ -24293,14 +24542,14 @@ function nestedPivotGrid(pivot) {
|
|
|
24293
24542
|
]);
|
|
24294
24543
|
if (own2 === "auto") {
|
|
24295
24544
|
if (showsValue) return;
|
|
24296
|
-
if (valuesAbove) subtotal(
|
|
24545
|
+
if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure2);
|
|
24297
24546
|
else measures2.forEach((one2, m) => subtotal(`${caption} ${one2.caption}`, void 0, m));
|
|
24298
24547
|
} else
|
|
24299
24548
|
for (const fn of own2)
|
|
24300
|
-
if (valuesAbove) subtotal(`${caption} ${
|
|
24549
|
+
if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure2);
|
|
24301
24550
|
else
|
|
24302
24551
|
measures2.forEach(
|
|
24303
|
-
(one2, m) => subtotal(`${caption} ${
|
|
24552
|
+
(one2, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one2.field}`, fn, m)
|
|
24304
24553
|
);
|
|
24305
24554
|
});
|
|
24306
24555
|
};
|
|
@@ -24311,12 +24560,12 @@ function nestedPivotGrid(pivot) {
|
|
|
24311
24560
|
]);
|
|
24312
24561
|
const build2 = () => {
|
|
24313
24562
|
walk2(0, root, void 0, { labels: [], indices: [], firsts: [] });
|
|
24314
|
-
if (onRows) measures2.forEach((one2, m) => grand(
|
|
24315
|
-
else grand(
|
|
24563
|
+
if (onRows) measures2.forEach((one2, m) => grand(fillCaption(caps.measureTotal, one2.caption), m));
|
|
24564
|
+
else grand(caps.grandTotal);
|
|
24316
24565
|
};
|
|
24317
24566
|
build2();
|
|
24318
24567
|
counting = false;
|
|
24319
|
-
values2 = pivotColumnHeaders(pivot, columns, compact3 ? [
|
|
24568
|
+
values2 = pivotColumnHeaders(pivot, columns, compact3 ? [caps.rowLabels] : rowTitles, onRows);
|
|
24320
24569
|
const firstDataRow = values2.length;
|
|
24321
24570
|
indents = values2.map(() => 0);
|
|
24322
24571
|
build2();
|
|
@@ -24349,14 +24598,14 @@ function pivotTableAt(sheet, at2) {
|
|
|
24349
24598
|
var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
24350
24599
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
24351
24600
|
var TABLE = {
|
|
24352
|
-
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",
|
|
24601
|
+
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",
|
|
24353
24602
|
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
24354
24603
|
pageFields: "count",
|
|
24355
24604
|
pageField: "fld item hier",
|
|
24356
24605
|
pivotFields: "count",
|
|
24357
24606
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal numFmtId sumSubtotal countASubtotal avgSubtotal maxSubtotal minSubtotal productSubtotal countSubtotal stdDevSubtotal stdDevPSubtotal varSubtotal varPSubtotal",
|
|
24358
24607
|
items: "count",
|
|
24359
|
-
item: "x t h",
|
|
24608
|
+
item: "x t h n",
|
|
24360
24609
|
rowFields: "count",
|
|
24361
24610
|
colFields: "count",
|
|
24362
24611
|
field: "x",
|
|
@@ -24457,8 +24706,8 @@ function inspect(node3, profile, cache3) {
|
|
|
24457
24706
|
}
|
|
24458
24707
|
for (const child7 of elements(node3)) inspect(child7, profile, cache3);
|
|
24459
24708
|
}
|
|
24460
|
-
function assertPivotAdmission(
|
|
24461
|
-
inspect(
|
|
24709
|
+
function assertPivotAdmission(table4, cache3) {
|
|
24710
|
+
inspect(table4, TABLE, false);
|
|
24462
24711
|
inspect(cache3, CACHE, true);
|
|
24463
24712
|
}
|
|
24464
24713
|
function assertPivotRecords(records) {
|
|
@@ -24469,6 +24718,121 @@ function assertPivotRecords(records) {
|
|
|
24469
24718
|
);
|
|
24470
24719
|
}
|
|
24471
24720
|
|
|
24721
|
+
// xlsx/pivot/captions-read.ts
|
|
24722
|
+
var ATTRIBUTES2 = {
|
|
24723
|
+
rowHeaderCaption: "rowLabels",
|
|
24724
|
+
colHeaderCaption: "columnLabels",
|
|
24725
|
+
grandTotalCaption: "grandTotal",
|
|
24726
|
+
dataCaption: "values"
|
|
24727
|
+
};
|
|
24728
|
+
function readPivotCaptionAttributes(root) {
|
|
24729
|
+
const out = {};
|
|
24730
|
+
for (const [attribute4, key2] of Object.entries(ATTRIBUTES2)) {
|
|
24731
|
+
const text8 = att(root, attribute4);
|
|
24732
|
+
if (text8 !== void 0)
|
|
24733
|
+
out[key2] = decodeEscapes(text8);
|
|
24734
|
+
}
|
|
24735
|
+
return out;
|
|
24736
|
+
}
|
|
24737
|
+
function aggregateCaptionsOf(pivot) {
|
|
24738
|
+
const out = {};
|
|
24739
|
+
for (const measure2 of [
|
|
24740
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
24741
|
+
...pivot.additionalValues ?? []
|
|
24742
|
+
]) {
|
|
24743
|
+
const at2 = measure2.caption.indexOf(measure2.field);
|
|
24744
|
+
if (at2 < 0 || measure2.caption === measure2.field) continue;
|
|
24745
|
+
const template = `${measure2.caption.slice(0, at2)}{0}${measure2.caption.slice(at2 + measure2.field.length)}`;
|
|
24746
|
+
if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure2.aggregate])
|
|
24747
|
+
out[measure2.aggregate] = template;
|
|
24748
|
+
}
|
|
24749
|
+
return Object.keys(out).length ? out : void 0;
|
|
24750
|
+
}
|
|
24751
|
+
var MARK = "";
|
|
24752
|
+
var SENTINELS = {
|
|
24753
|
+
rowLabels: `${MARK}R`,
|
|
24754
|
+
columnLabels: `${MARK}C`,
|
|
24755
|
+
grandTotal: `${MARK}G`,
|
|
24756
|
+
values: `${MARK}V`,
|
|
24757
|
+
all: `${MARK}A`,
|
|
24758
|
+
blank: `${MARK}B`,
|
|
24759
|
+
subtotal: `{0}${MARK}S`,
|
|
24760
|
+
measureTotal: `${MARK}M{0}`,
|
|
24761
|
+
functions: Object.fromEntries(
|
|
24762
|
+
Object.keys(ENGLISH_PIVOT_CAPTIONS.functions).map((fn) => [fn, `${MARK}F${fn}`])
|
|
24763
|
+
),
|
|
24764
|
+
aggregates: ENGLISH_PIVOT_CAPTIONS.aggregates
|
|
24765
|
+
};
|
|
24766
|
+
function templateOf(cached6, arg) {
|
|
24767
|
+
if (!arg || !cached6.includes(arg)) return void 0;
|
|
24768
|
+
if (cached6.startsWith(arg)) return `{0}${cached6.slice(arg.length)}`;
|
|
24769
|
+
if (cached6.endsWith(arg)) return `${cached6.slice(0, -arg.length)}{0}`;
|
|
24770
|
+
const at2 = cached6.indexOf(arg);
|
|
24771
|
+
return `${cached6.slice(0, at2)}{0}${cached6.slice(at2 + arg.length)}`;
|
|
24772
|
+
}
|
|
24773
|
+
function inferPivotCaptions(pivot, sheet, named3) {
|
|
24774
|
+
const known = pivotCaptions({ captions: named3 });
|
|
24775
|
+
const probe = { ...SENTINELS };
|
|
24776
|
+
for (const key2 of Object.keys(named3))
|
|
24777
|
+
if (typeof named3[key2] === "string")
|
|
24778
|
+
probe[key2] = known[key2];
|
|
24779
|
+
const grid = pivotGrid({ ...pivot, captions: probe });
|
|
24780
|
+
const found = /* @__PURE__ */ new Map();
|
|
24781
|
+
const set = (key2, value2) => {
|
|
24782
|
+
if (value2 === void 0) return;
|
|
24783
|
+
const before = found.get(key2);
|
|
24784
|
+
found.set(key2, before === void 0 || before === value2 ? value2 : null);
|
|
24785
|
+
};
|
|
24786
|
+
grid.values.forEach(
|
|
24787
|
+
(line3, r) => line3.forEach((expected, c2) => {
|
|
24788
|
+
if (typeof expected !== "string" || !expected.includes(MARK)) return;
|
|
24789
|
+
const cached6 = getCell(
|
|
24790
|
+
sheet,
|
|
24791
|
+
pivot.location.start.row + r,
|
|
24792
|
+
pivot.location.start.col + c2
|
|
24793
|
+
)?.value;
|
|
24794
|
+
if (typeof cached6 !== "string") return;
|
|
24795
|
+
const kind = /\u0001([RCGVASMFB])(\w*)/.exec(expected);
|
|
24796
|
+
if (!kind) return;
|
|
24797
|
+
const at2 = kind.index;
|
|
24798
|
+
switch (kind[1]) {
|
|
24799
|
+
case "R":
|
|
24800
|
+
return set("rowLabels", cached6);
|
|
24801
|
+
case "C":
|
|
24802
|
+
return set("columnLabels", cached6);
|
|
24803
|
+
case "G":
|
|
24804
|
+
return set("grandTotal", cached6);
|
|
24805
|
+
case "V":
|
|
24806
|
+
return set("values", cached6);
|
|
24807
|
+
case "A":
|
|
24808
|
+
return set("all", cached6);
|
|
24809
|
+
case "B":
|
|
24810
|
+
return set("blank", cached6);
|
|
24811
|
+
case "S":
|
|
24812
|
+
return set("subtotal", templateOf(cached6, expected.slice(0, at2)));
|
|
24813
|
+
case "M":
|
|
24814
|
+
return set("measureTotal", templateOf(cached6, expected.slice(at2 + 2)));
|
|
24815
|
+
case "F": {
|
|
24816
|
+
const item = expected.slice(0, at2 - 1);
|
|
24817
|
+
const of = / of (.*)$/.exec(expected.slice(at2));
|
|
24818
|
+
const word = cached6.slice(item.length + 1, of ? cached6.length - of[0].length : void 0);
|
|
24819
|
+
if (cached6.startsWith(`${item} `) && (!of || cached6.endsWith(of[0])))
|
|
24820
|
+
set(`function:${kind[2]}`, word);
|
|
24821
|
+
}
|
|
24822
|
+
}
|
|
24823
|
+
})
|
|
24824
|
+
);
|
|
24825
|
+
const out = pivotCaptions({ captions: named3 });
|
|
24826
|
+
const functions = { ...out.functions };
|
|
24827
|
+
for (const [key2, value2] of found) {
|
|
24828
|
+
if (value2 === null) continue;
|
|
24829
|
+
if (key2.startsWith("function:")) functions[key2.slice(9)] = value2;
|
|
24830
|
+
else out[key2] = value2;
|
|
24831
|
+
}
|
|
24832
|
+
out.functions = functions;
|
|
24833
|
+
return trimmedCaptions(out);
|
|
24834
|
+
}
|
|
24835
|
+
|
|
24472
24836
|
// xlsx/slicer/read-slicers.ts
|
|
24473
24837
|
var TABLE_SLICER_URI = "{2F2917AC-EB37-4324-AD4E-5DD8C200BD13}";
|
|
24474
24838
|
var X152 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
@@ -24544,12 +24908,12 @@ function parseSlicerCache(xml, partName) {
|
|
|
24544
24908
|
if (data) return void 0;
|
|
24545
24909
|
const list2 = byLocal(root, "extLst");
|
|
24546
24910
|
const ext = list2 ? elements(list2).find((node3) => node3.getAttribute("uri") === TABLE_SLICER_URI) : void 0;
|
|
24547
|
-
const
|
|
24548
|
-
const tableId = numAttr(
|
|
24549
|
-
const column2 = numAttr(
|
|
24550
|
-
if (!
|
|
24911
|
+
const table4 = ext ? first(ext, "tableSlicerCache", X152) : void 0;
|
|
24912
|
+
const tableId = numAttr(table4, "tableId");
|
|
24913
|
+
const column2 = numAttr(table4, "column");
|
|
24914
|
+
if (!table4 || tableId === void 0 || column2 === void 0) return void 0;
|
|
24551
24915
|
const cache3 = { ...common, source: { kind: "table", tableId, column: column2 } };
|
|
24552
|
-
if (att(
|
|
24916
|
+
if (att(table4, "sortOrder") === "descending") cache3.sortOrder = "descending";
|
|
24553
24917
|
if (elements(root).some((node3) => node3.localName === "pivotTables")) return void 0;
|
|
24554
24918
|
return cache3;
|
|
24555
24919
|
}
|
|
@@ -24634,14 +24998,14 @@ function parseTimelineCache(xml, partName) {
|
|
|
24634
24998
|
}
|
|
24635
24999
|
|
|
24636
25000
|
// xlsx/slicer/table-filter.ts
|
|
24637
|
-
function tableFilterBounds(
|
|
25001
|
+
function tableFilterBounds(table4) {
|
|
24638
25002
|
return {
|
|
24639
|
-
start:
|
|
24640
|
-
end: { ...
|
|
25003
|
+
start: table4.range.start,
|
|
25004
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
24641
25005
|
};
|
|
24642
25006
|
}
|
|
24643
|
-
function tableAutoFilter(
|
|
24644
|
-
const columns =
|
|
25007
|
+
function tableAutoFilter(table4) {
|
|
25008
|
+
const columns = table4.columns.flatMap(
|
|
24645
25009
|
(column2, offset2) => column2.filter ? [
|
|
24646
25010
|
{
|
|
24647
25011
|
offset: offset2,
|
|
@@ -24651,12 +25015,12 @@ function tableAutoFilter(table3) {
|
|
|
24651
25015
|
] : []
|
|
24652
25016
|
);
|
|
24653
25017
|
if (!columns.length) return void 0;
|
|
24654
|
-
return { range: tableFilterBounds(
|
|
25018
|
+
return { range: tableFilterBounds(table4), columns };
|
|
24655
25019
|
}
|
|
24656
|
-
function applyTableFilter(workbook, sheet,
|
|
24657
|
-
if (!
|
|
24658
|
-
const bounds2 = tableFilterBounds(
|
|
24659
|
-
const filter2 = tableAutoFilter(
|
|
25020
|
+
function applyTableFilter(workbook, sheet, table4) {
|
|
25021
|
+
if (!table4.headerRow) return;
|
|
25022
|
+
const bounds2 = tableFilterBounds(table4);
|
|
25023
|
+
const filter2 = tableAutoFilter(table4);
|
|
24660
25024
|
for (let row3 = bounds2.start.row + 1; row3 <= bounds2.end.row; row3++) {
|
|
24661
25025
|
const visible = !filter2 || rowMatchesFilter(workbook, sheet, row3, filter2);
|
|
24662
25026
|
setRowFiltered(sheet, row3, !visible, !!filter2);
|
|
@@ -24664,8 +25028,8 @@ function applyTableFilter(workbook, sheet, table3) {
|
|
|
24664
25028
|
}
|
|
24665
25029
|
function readTableFilteredRows(workbook) {
|
|
24666
25030
|
for (const sheet of workbook.sheets)
|
|
24667
|
-
for (const
|
|
24668
|
-
const filter2 = tableAutoFilter(
|
|
25031
|
+
for (const table4 of sheet.tables) {
|
|
25032
|
+
const filter2 = tableAutoFilter(table4);
|
|
24669
25033
|
if (!filter2) continue;
|
|
24670
25034
|
for (let row3 = filter2.range.start.row + 1; row3 <= filter2.range.end.row; row3++) {
|
|
24671
25035
|
const info = sheet.rowInfo.get(row3);
|
|
@@ -24784,9 +25148,9 @@ function settleSlicers(workbook, warn) {
|
|
|
24784
25148
|
if (cache3.source.kind === "table") {
|
|
24785
25149
|
const { tableId, column: column2 } = cache3.source;
|
|
24786
25150
|
for (const sheet of workbook.sheets) {
|
|
24787
|
-
const
|
|
24788
|
-
if (
|
|
24789
|
-
return
|
|
25151
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === tableId);
|
|
25152
|
+
if (table4)
|
|
25153
|
+
return table4.headerRow && !table4.filterNotModeled && table4.columns.some((entry3) => entry3.sourceId === column2);
|
|
24790
25154
|
}
|
|
24791
25155
|
return false;
|
|
24792
25156
|
}
|
|
@@ -24964,7 +25328,7 @@ function readFieldGroups(fields, names) {
|
|
|
24964
25328
|
throw new Error("Unsupported pivot field group");
|
|
24965
25329
|
const labels = children(list2, "s", NS.x).map((node3) => decodeEscapes(att(node3, "v") ?? ""));
|
|
24966
25330
|
const expected = numberGroupLabels({ start, end, by });
|
|
24967
|
-
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((
|
|
25331
|
+
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((label2, i2) => label2 !== expected[i2]))
|
|
24968
25332
|
throw new Error("Unsupported pivot group items");
|
|
24969
25333
|
groups.push({ field: names[index3] ?? "", start, end, by });
|
|
24970
25334
|
});
|
|
@@ -25048,7 +25412,7 @@ function readDateGroups(fields, count2, names, dateFields, records, date1904) {
|
|
|
25048
25412
|
const node3 = first(first(entry3.node, "fieldGroup", NS.x), "groupItems", NS.x);
|
|
25049
25413
|
const actual = children(node3, "s", NS.x).map((item) => decodeEscapes(att(item, "v") ?? ""));
|
|
25050
25414
|
const name3 = decodeEscapes(att(entry3.node, "name") ?? "");
|
|
25051
|
-
if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((
|
|
25415
|
+
if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((label2) => !label2) || new Set(actual).size !== actual.length)
|
|
25052
25416
|
throw unsupported("group items");
|
|
25053
25417
|
if (name3 !== dateGroupFieldName(entry3.unit, field2) || actual.some((l, i2) => l !== labels[i2]))
|
|
25054
25418
|
localized[entry3.unit] = { name: name3, labels: actual };
|
|
@@ -25106,6 +25470,25 @@ function readItemFilters(fields, names, shared) {
|
|
|
25106
25470
|
return filters.length ? filters : void 0;
|
|
25107
25471
|
}
|
|
25108
25472
|
|
|
25473
|
+
// xlsx/pivot/item-names-read.ts
|
|
25474
|
+
function readItemNames(tableFields, names, shared) {
|
|
25475
|
+
const out = [];
|
|
25476
|
+
tableFields.forEach((field2, index3) => {
|
|
25477
|
+
const list2 = first(field2, "items", NS.x);
|
|
25478
|
+
if (!list2 || index3 >= names.length) return;
|
|
25479
|
+
for (const item of children(list2, "item", NS.x)) {
|
|
25480
|
+
const name3 = att(item, "n");
|
|
25481
|
+
if (name3 === void 0) continue;
|
|
25482
|
+
const at2 = Number(att(item, "x"));
|
|
25483
|
+
const value2 = shared[index3]?.[at2];
|
|
25484
|
+
if (att(item, "t") !== void 0 || !Number.isInteger(at2) || value2 === void 0)
|
|
25485
|
+
throw new Error("Unsupported pivot item name");
|
|
25486
|
+
out.push({ field: names[index3], item: value2, name: decodeEscapes(name3) });
|
|
25487
|
+
}
|
|
25488
|
+
});
|
|
25489
|
+
return out;
|
|
25490
|
+
}
|
|
25491
|
+
|
|
25109
25492
|
// xlsx/pivot/values-axis.ts
|
|
25110
25493
|
function remapPivotRowEntries(entries, axes2) {
|
|
25111
25494
|
return entries.map(
|
|
@@ -25228,7 +25611,10 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25228
25611
|
};
|
|
25229
25612
|
const rowAxes = pivotRowFields(pivot).map((name3) => axisValues(name3, "axisRow")), rowItems = read("rowItems");
|
|
25230
25613
|
const grid = pivotGrid(pivot);
|
|
25231
|
-
const
|
|
25614
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
25615
|
+
const levelAxes = [...rowAxes];
|
|
25616
|
+
if (valuesAt >= 0) levelAxes.splice(valuesAt, 0, null);
|
|
25617
|
+
const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, levelAxes) : [
|
|
25232
25618
|
...rowAxes[0].map((index3) => ({ indices: [index3] })),
|
|
25233
25619
|
{ indices: [0], type: "grand" }
|
|
25234
25620
|
];
|
|
@@ -25238,11 +25624,11 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25238
25624
|
const expected2 = entries[i2];
|
|
25239
25625
|
const xs = children(item, "x", NS.x).map((x) => integer3(x.getAttribute("v"), 0)), prefix3 = integer3(item.getAttribute("r"), 0);
|
|
25240
25626
|
const type = expected2.type === void 0 || expected2.type === "default" || expected2.type === "grand" ? expected2.type : PIVOT_SUBTOTALS[expected2.type].item;
|
|
25241
|
-
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))
|
|
25627
|
+
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))
|
|
25242
25628
|
throw new Error("Unmodeled page row item");
|
|
25243
25629
|
previousRow = expected2.type === "grand" ? [] : expected2.indices;
|
|
25244
25630
|
});
|
|
25245
|
-
const measures2 = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25631
|
+
const measures2 = valuesAt >= 0 ? 1 : 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25246
25632
|
if (columns)
|
|
25247
25633
|
for (const col of columns)
|
|
25248
25634
|
for (let m = 0; m < measures2; m++) expected.push(measures2 > 1 ? [col, m] : [col]);
|
|
@@ -25284,6 +25670,10 @@ function value(node3, date1904 = false) {
|
|
|
25284
25670
|
if (node3.localName === "e" && isErrorCode(v)) return { error: v };
|
|
25285
25671
|
throw new Error("Unsupported pivot cache item");
|
|
25286
25672
|
}
|
|
25673
|
+
var namedAggregates = (pivot) => {
|
|
25674
|
+
const aggregates = aggregateCaptionsOf(pivot);
|
|
25675
|
+
return aggregates ? { aggregates } : {};
|
|
25676
|
+
};
|
|
25287
25677
|
function readOne(workbook, source2, part) {
|
|
25288
25678
|
const xml = source2.text(part);
|
|
25289
25679
|
const root = parseXml(xml).documentElement;
|
|
@@ -25430,6 +25820,7 @@ function readOne(workbook, source2, part) {
|
|
|
25430
25820
|
location.start.row -= 2;
|
|
25431
25821
|
}
|
|
25432
25822
|
const itemFilters = readItemFilters(tableFields, names, shared);
|
|
25823
|
+
const itemNames = readItemNames(tableFields, names, shared);
|
|
25433
25824
|
const slicerCacheId = readSlicerCacheId(cache3);
|
|
25434
25825
|
const fieldGroups = readFieldGroups(fields, names);
|
|
25435
25826
|
const dateFields = readDateFields(fields, names);
|
|
@@ -25468,6 +25859,7 @@ function readOne(workbook, source2, part) {
|
|
|
25468
25859
|
const pivot = {
|
|
25469
25860
|
...pageFilter ? { pageFilter } : {},
|
|
25470
25861
|
...itemFilters ? { itemFilters } : {},
|
|
25862
|
+
...itemNames.length ? { itemNames } : {},
|
|
25471
25863
|
...fieldGroups.length ? { fieldGroups } : {},
|
|
25472
25864
|
...dateFields.length ? { dateFields } : {},
|
|
25473
25865
|
...dateGroups.length ? { dateGroups } : {},
|
|
@@ -25510,6 +25902,12 @@ function readOne(workbook, source2, part) {
|
|
|
25510
25902
|
...col ? { columnField: col } : {},
|
|
25511
25903
|
...moreColumns.length ? { moreColumnFields: moreColumns } : {}
|
|
25512
25904
|
};
|
|
25905
|
+
const captions = trimmedCaptions(
|
|
25906
|
+
pivotCaptions({
|
|
25907
|
+
captions: { ...readPivotCaptionAttributes(root), ...namedAggregates(pivot) }
|
|
25908
|
+
})
|
|
25909
|
+
);
|
|
25910
|
+
if (captions) pivot.captions = captions;
|
|
25513
25911
|
if (pageFilter && moreColumns.length) throw new Error("Report filters support one column field");
|
|
25514
25912
|
assertPageAxisItems(root, pivot, shared, cache3, recordRoot);
|
|
25515
25913
|
return pivot;
|
|
@@ -25537,6 +25935,12 @@ function readPivotTables(workbook, source2, warn, slicers) {
|
|
|
25537
25935
|
if (slicers.blocked.has(pivotKey(sheet.sheetId, name3)) || cache3 && (caches2.get(cache3) ?? 0) > 1)
|
|
25538
25936
|
throw new Error("Shared pivot cache or unsupported slicer connection");
|
|
25539
25937
|
const pivot = readOne(workbook, source2, part);
|
|
25938
|
+
const inferred = inferPivotCaptions(pivot, sheet, {
|
|
25939
|
+
...readPivotCaptionAttributes(parseXml(pivot.sourceXml).documentElement),
|
|
25940
|
+
...namedAggregates(pivot)
|
|
25941
|
+
});
|
|
25942
|
+
if (inferred) pivot.captions = inferred;
|
|
25943
|
+
else delete pivot.captions;
|
|
25540
25944
|
const grid = pivotGrid(pivot);
|
|
25541
25945
|
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(
|
|
25542
25946
|
(line3, r) => line3.some(
|
|
@@ -26176,7 +26580,7 @@ function mergeSpacedAreas(tokens3) {
|
|
|
26176
26580
|
}
|
|
26177
26581
|
return out;
|
|
26178
26582
|
}
|
|
26179
|
-
function
|
|
26583
|
+
function templateOf2(formula) {
|
|
26180
26584
|
const cached6 = templates.get(formula);
|
|
26181
26585
|
if (cached6 !== void 0) return cached6;
|
|
26182
26586
|
const raw2 = safeTokens(formula);
|
|
@@ -26206,7 +26610,7 @@ function templateOf(formula) {
|
|
|
26206
26610
|
return template;
|
|
26207
26611
|
}
|
|
26208
26612
|
function rewriteTemplate(formula, rewrite2) {
|
|
26209
|
-
const template =
|
|
26613
|
+
const template = templateOf2(formula);
|
|
26210
26614
|
if (!template) return formula;
|
|
26211
26615
|
let next;
|
|
26212
26616
|
for (let i2 = 0; i2 < template.length; i2++) {
|
|
@@ -27507,14 +27911,14 @@ function readDataTable(f6) {
|
|
|
27507
27911
|
const ref = parseRange(att(f6, "ref") ?? "");
|
|
27508
27912
|
const r1 = att(f6, "r1");
|
|
27509
27913
|
if (!ref || !r1) return void 0;
|
|
27510
|
-
const
|
|
27914
|
+
const table4 = { ref, r1 };
|
|
27511
27915
|
const r2 = att(f6, "r2");
|
|
27512
|
-
if (r2)
|
|
27513
|
-
if (boolAttr(f6, "dt2D"))
|
|
27514
|
-
if (boolAttr(f6, "dtr"))
|
|
27515
|
-
if (boolAttr(f6, "del1"))
|
|
27516
|
-
if (boolAttr(f6, "del2"))
|
|
27517
|
-
return
|
|
27916
|
+
if (r2) table4.r2 = r2;
|
|
27917
|
+
if (boolAttr(f6, "dt2D")) table4.dt2D = true;
|
|
27918
|
+
if (boolAttr(f6, "dtr")) table4.dtr = true;
|
|
27919
|
+
if (boolAttr(f6, "del1")) table4.del1 = true;
|
|
27920
|
+
if (boolAttr(f6, "del2")) table4.del2 = true;
|
|
27921
|
+
return table4;
|
|
27518
27922
|
}
|
|
27519
27923
|
function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet) {
|
|
27520
27924
|
const kind = att(f6, "t") ?? "normal";
|
|
@@ -27538,8 +27942,8 @@ function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet
|
|
|
27538
27942
|
}
|
|
27539
27943
|
if (kind === "dataTable") {
|
|
27540
27944
|
delete cell.legacyFormula;
|
|
27541
|
-
const
|
|
27542
|
-
if (
|
|
27945
|
+
const table4 = readDataTable(f6);
|
|
27946
|
+
if (table4) (sheet.dataTables ??= []).push(table4);
|
|
27543
27947
|
else ctx.warn("A what-if data table formula could not be read; its cached values were kept.");
|
|
27544
27948
|
return;
|
|
27545
27949
|
}
|
|
@@ -27731,14 +28135,14 @@ function parseTable3(xml, partName) {
|
|
|
27731
28135
|
if (id3 !== void 0 && Number.isInteger(id3) && id3 >= 0) column2.sourceId = id3;
|
|
27732
28136
|
const fn = att(node3, "totalsRowFunction");
|
|
27733
28137
|
if (fn && fn !== "none") column2.totalsRowFunction = fn;
|
|
27734
|
-
const
|
|
27735
|
-
if (
|
|
28138
|
+
const label2 = att(node3, "totalsRowLabel");
|
|
28139
|
+
if (label2 !== void 0) column2.totalsRowLabel = label2;
|
|
27736
28140
|
const calculated = xFirst(node3, "calculatedColumnFormula");
|
|
27737
28141
|
if (calculated) column2.calculatedColumnFormula = stripFuturePrefixes(xText(calculated));
|
|
27738
28142
|
return column2;
|
|
27739
28143
|
}
|
|
27740
28144
|
);
|
|
27741
|
-
const
|
|
28145
|
+
const table4 = {
|
|
27742
28146
|
id: numAttr(root, "id") ?? 1,
|
|
27743
28147
|
name: name3,
|
|
27744
28148
|
displayName: att(root, "displayName") ?? name3,
|
|
@@ -27748,26 +28152,26 @@ function parseTable3(xml, partName) {
|
|
|
27748
28152
|
columns,
|
|
27749
28153
|
partName
|
|
27750
28154
|
};
|
|
27751
|
-
readColumnFilters(root,
|
|
28155
|
+
readColumnFilters(root, table4);
|
|
27752
28156
|
const info = xFirst(root, "tableStyleInfo");
|
|
27753
28157
|
if (info) {
|
|
27754
28158
|
const style3 = att(info, "name");
|
|
27755
|
-
if (style3)
|
|
27756
|
-
|
|
27757
|
-
|
|
27758
|
-
|
|
27759
|
-
|
|
28159
|
+
if (style3) table4.styleName = style3;
|
|
28160
|
+
table4.showRowStripes = boolAttr(info, "showRowStripes", false);
|
|
28161
|
+
table4.showColumnStripes = boolAttr(info, "showColumnStripes", false);
|
|
28162
|
+
table4.showFirstColumn = boolAttr(info, "showFirstColumn", false);
|
|
28163
|
+
table4.showLastColumn = boolAttr(info, "showLastColumn", false);
|
|
27760
28164
|
}
|
|
27761
|
-
return
|
|
28165
|
+
return table4;
|
|
27762
28166
|
}
|
|
27763
|
-
function readColumnFilters(root,
|
|
28167
|
+
function readColumnFilters(root, table4) {
|
|
27764
28168
|
const filter2 = xFirst(root, "autoFilter");
|
|
27765
28169
|
for (const node3 of filter2 ? xChildren(filter2, "filterColumn") : []) {
|
|
27766
|
-
const column2 =
|
|
28170
|
+
const column2 = table4.columns[numAttr(node3, "colId") ?? -1];
|
|
27767
28171
|
const filters = xChildren(node3, "filters");
|
|
27768
28172
|
const simple = column2 && isValueListFilterColumn(node3);
|
|
27769
28173
|
if (!simple) {
|
|
27770
|
-
|
|
28174
|
+
table4.filterNotModeled = true;
|
|
27771
28175
|
continue;
|
|
27772
28176
|
}
|
|
27773
28177
|
const values2 = xChildren(filters[0], "filter").map((child7) => att(child7, "val") ?? "");
|
|
@@ -27846,8 +28250,8 @@ function readTables(ctx, partName, node3, sheet) {
|
|
|
27846
28250
|
const rel = rels.get(relAttr(part, "id") ?? "");
|
|
27847
28251
|
const target2 = rel ? ctx.source.target(partName, rel) : void 0;
|
|
27848
28252
|
const xml = target2 ? ctx.source.text(target2) : void 0;
|
|
27849
|
-
const
|
|
27850
|
-
if (
|
|
28253
|
+
const table4 = target2 && xml ? parseTable3(xml, target2) : void 0;
|
|
28254
|
+
if (table4) sheet.tables.push(table4);
|
|
27851
28255
|
else ctx.warn("A table part could not be read and was dropped.");
|
|
27852
28256
|
}
|
|
27853
28257
|
}
|
|
@@ -30317,14 +30721,14 @@ function unique(args, ctx) {
|
|
|
30317
30721
|
const byCol = args.length > 1 && args[1] !== null && toBool(ctx.toScalar(args[1] ?? null));
|
|
30318
30722
|
const once = args.length > 2 && args[2] !== null && toBool(ctx.toScalar(args[2] ?? null));
|
|
30319
30723
|
if (byCol) m = transpose(m);
|
|
30320
|
-
const
|
|
30724
|
+
const keyOf3 = (row3) => JSON.stringify(
|
|
30321
30725
|
row3.map(
|
|
30322
30726
|
(v) => isError(v) ? `#${v.error}` : typeof v === "string" ? `s${v.toLowerCase()}` : v
|
|
30323
30727
|
)
|
|
30324
30728
|
);
|
|
30325
30729
|
const counts = /* @__PURE__ */ new Map();
|
|
30326
30730
|
for (const row3 of m.data) {
|
|
30327
|
-
const key2 =
|
|
30731
|
+
const key2 = keyOf3(row3);
|
|
30328
30732
|
const entry3 = counts.get(key2);
|
|
30329
30733
|
if (entry3) entry3.count++;
|
|
30330
30734
|
else counts.set(key2, { row: row3, count: 1 });
|
|
@@ -30609,30 +31013,30 @@ function gammaLn(z) {
|
|
|
30609
31013
|
|
|
30610
31014
|
// xlsx/formula/functions/database.ts
|
|
30611
31015
|
var C3 = "Database";
|
|
30612
|
-
var
|
|
31016
|
+
var label = (value2) => value2 === null ? "" : typeof value2 === "string" ? value2 : String(value2);
|
|
30613
31017
|
function tableOf(ctx, value2) {
|
|
30614
31018
|
const [head, ...records] = ctx.toMatrix(value2 ?? null).data;
|
|
30615
31019
|
if (!head || records.length === 0) fail(ERR.VALUE);
|
|
30616
|
-
return { headers: head.map((v) =>
|
|
31020
|
+
return { headers: head.map((v) => label(v).toLowerCase()), records };
|
|
30617
31021
|
}
|
|
30618
|
-
function fieldIndex(
|
|
31022
|
+
function fieldIndex(table4, field2) {
|
|
30619
31023
|
const value2 = scalar2(field2);
|
|
30620
31024
|
if (isError(value2)) fail(value2);
|
|
30621
31025
|
if (typeof value2 === "number") {
|
|
30622
31026
|
const index4 = Math.trunc(value2) - 1;
|
|
30623
|
-
if (index4 < 0 || index4 >=
|
|
31027
|
+
if (index4 < 0 || index4 >= table4.headers.length) fail(ERR.VALUE);
|
|
30624
31028
|
return index4;
|
|
30625
31029
|
}
|
|
30626
|
-
const index3 =
|
|
31030
|
+
const index3 = table4.headers.indexOf(label(value2).toLowerCase());
|
|
30627
31031
|
if (index3 < 0) fail(ERR.VALUE);
|
|
30628
31032
|
return index3;
|
|
30629
31033
|
}
|
|
30630
|
-
function recordFilter(
|
|
31034
|
+
function recordFilter(table4, criteria) {
|
|
30631
31035
|
const [head, ...rows] = criteria;
|
|
30632
31036
|
if (!head || rows.length === 0) fail(ERR.VALUE);
|
|
30633
31037
|
const columns = head.map((name3) => {
|
|
30634
31038
|
if (name3 === null || name3 === "") return -1;
|
|
30635
|
-
return
|
|
31039
|
+
return table4.headers.indexOf(label(name3).toLowerCase());
|
|
30636
31040
|
});
|
|
30637
31041
|
const alternatives = rows.map(
|
|
30638
31042
|
(row3) => row3.flatMap((cell, c2) => {
|
|
@@ -30646,10 +31050,10 @@ function recordFilter(table3, criteria) {
|
|
|
30646
31050
|
return (record2) => alternatives.some((tests) => tests.every((test) => test(record2)));
|
|
30647
31051
|
}
|
|
30648
31052
|
function selected(ctx, args) {
|
|
30649
|
-
const
|
|
30650
|
-
const column2 = fieldIndex(
|
|
30651
|
-
const matches2 = recordFilter(
|
|
30652
|
-
return
|
|
31053
|
+
const table4 = tableOf(ctx, args[0]);
|
|
31054
|
+
const column2 = fieldIndex(table4, args[1]);
|
|
31055
|
+
const matches2 = recordFilter(table4, ctx.toMatrix(args[2] ?? null).data);
|
|
31056
|
+
return table4.records.filter(matches2).map((record2) => record2[column2] ?? null);
|
|
30653
31057
|
}
|
|
30654
31058
|
var numbers = (values2) => {
|
|
30655
31059
|
for (const v of values2) if (isError(v)) fail(v);
|
|
@@ -31477,9 +31881,9 @@ var BESSEL_FUNCTIONS = [
|
|
|
31477
31881
|
];
|
|
31478
31882
|
|
|
31479
31883
|
// xlsx/formula/functions/convert.ts
|
|
31480
|
-
var
|
|
31884
|
+
var table2 = /* @__PURE__ */ new Map();
|
|
31481
31885
|
var add3 = (dimension3, names, factor, extra = {}) => {
|
|
31482
|
-
for (const name3 of names)
|
|
31886
|
+
for (const name3 of names) table2.set(name3, { dimension: dimension3, factor, ...extra });
|
|
31483
31887
|
};
|
|
31484
31888
|
add3("mass", ["g"], 1, { prefix: "metric" });
|
|
31485
31889
|
add3("mass", ["sg"], 14593.9029372064);
|
|
@@ -31610,10 +32014,10 @@ var BINARY2 = {
|
|
|
31610
32014
|
ki: 2 ** 10
|
|
31611
32015
|
};
|
|
31612
32016
|
function resolve(name3) {
|
|
31613
|
-
const direct =
|
|
32017
|
+
const direct = table2.get(name3);
|
|
31614
32018
|
if (direct) return { dimension: direct.dimension, factor: direct.factor };
|
|
31615
32019
|
for (const length of [2, 1]) {
|
|
31616
|
-
const unit3 =
|
|
32020
|
+
const unit3 = table2.get(name3.slice(length));
|
|
31617
32021
|
const prefix3 = name3.slice(0, length);
|
|
31618
32022
|
if (!unit3?.prefix) continue;
|
|
31619
32023
|
const scale2 = (unit3.prefix === "binary" ? BINARY2[prefix3] : void 0) ?? METRIC[prefix3];
|
|
@@ -32948,30 +33352,30 @@ function findTable(host, name3, sheet, row3, col) {
|
|
|
32948
33352
|
if (name3) {
|
|
32949
33353
|
const lower3 = name3.toLowerCase();
|
|
32950
33354
|
for (let s = 0; s < sheets.length; s++) {
|
|
32951
|
-
const
|
|
33355
|
+
const table5 = sheets[s]?.tables.find(
|
|
32952
33356
|
(t) => t.displayName.toLowerCase() === lower3 || t.name.toLowerCase() === lower3
|
|
32953
33357
|
);
|
|
32954
|
-
if (
|
|
33358
|
+
if (table5) return { table: table5, sheet: s };
|
|
32955
33359
|
}
|
|
32956
33360
|
return void 0;
|
|
32957
33361
|
}
|
|
32958
|
-
const
|
|
33362
|
+
const table4 = sheets[sheet]?.tables.find(
|
|
32959
33363
|
(t) => row3 >= t.range.start.row && row3 <= t.range.end.row && col >= t.range.start.col && col <= t.range.end.col
|
|
32960
33364
|
);
|
|
32961
|
-
return
|
|
33365
|
+
return table4 ? { table: table4, sheet } : void 0;
|
|
32962
33366
|
}
|
|
32963
33367
|
function resolveStructured(ref, frame2) {
|
|
32964
33368
|
const found = findTable(frame2.host, ref.table, frame2.sheet, frame2.row, frame2.col);
|
|
32965
33369
|
if (!found) return ref.table ? ERR.NAME : ERR.REF;
|
|
32966
|
-
const { table:
|
|
32967
|
-
const range2 = normalizeRange(
|
|
32968
|
-
const headerRow =
|
|
32969
|
-
const dataStart = range2.start.row + (
|
|
32970
|
-
const dataEnd = range2.end.row - (
|
|
32971
|
-
const totalsRow =
|
|
33370
|
+
const { table: table4, sheet } = found;
|
|
33371
|
+
const range2 = normalizeRange(table4.range);
|
|
33372
|
+
const headerRow = table4.headerRow ? range2.start.row : -1;
|
|
33373
|
+
const dataStart = range2.start.row + (table4.headerRow ? 1 : 0);
|
|
33374
|
+
const dataEnd = range2.end.row - (table4.totalsRow ? 1 : 0);
|
|
33375
|
+
const totalsRow = table4.totalsRow ? range2.end.row : -1;
|
|
32972
33376
|
const columnOf = (name3) => {
|
|
32973
33377
|
const lower3 = name3.toLowerCase();
|
|
32974
|
-
const index3 =
|
|
33378
|
+
const index3 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === lower3);
|
|
32975
33379
|
return index3 < 0 ? -1 : range2.start.col + index3;
|
|
32976
33380
|
};
|
|
32977
33381
|
let c1 = range2.start.col;
|
|
@@ -34283,16 +34687,16 @@ function lookupArray(value2) {
|
|
|
34283
34687
|
}
|
|
34284
34688
|
function vhlookup(args, ctx, vertical2) {
|
|
34285
34689
|
const lookup2 = blankAsZero(args);
|
|
34286
|
-
const
|
|
34690
|
+
const table4 = lookupArray(args[1] ?? null);
|
|
34287
34691
|
const index3 = int3(args[2]);
|
|
34288
34692
|
const approximate2 = args.length < 4 ? true : bool(args[3]);
|
|
34289
|
-
const { rows, cols } = shape(
|
|
34693
|
+
const { rows, cols } = shape(table4);
|
|
34290
34694
|
if (index3 < 1) fail(ERR.VALUE);
|
|
34291
34695
|
if (index3 > (vertical2 ? cols : rows)) fail(ERR.REF);
|
|
34292
|
-
const keys = line2(ctx,
|
|
34696
|
+
const keys = line2(ctx, table4, vertical2 ? "col" : "row", 0);
|
|
34293
34697
|
const at2 = approximate2 ? findAscending(keys, lookup2) : findExact(keys, lookup2, true);
|
|
34294
34698
|
if (at2 < 0) fail(ERR.NA);
|
|
34295
|
-
return vertical2 ? cellOf(
|
|
34699
|
+
return vertical2 ? cellOf(table4, at2, index3 - 1) : cellOf(table4, index3 - 1, at2);
|
|
34296
34700
|
}
|
|
34297
34701
|
function match(args, ctx) {
|
|
34298
34702
|
const lookup2 = blankAsZero(args);
|
|
@@ -35736,10 +36140,10 @@ var REGRESSION_FUNCTIONS = [
|
|
|
35736
36140
|
const lay = logs(layout2(ctx, args));
|
|
35737
36141
|
const fit3 = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
|
|
35738
36142
|
const stats = !omitted(args, 3) && bool(args[3]);
|
|
35739
|
-
const
|
|
35740
|
-
if (!stats) return
|
|
36143
|
+
const table4 = coefficientTable(fit3, stats, Math.exp);
|
|
36144
|
+
if (!stats) return table4;
|
|
35741
36145
|
const plain5 = coefficientTable(fit3, true, (v) => v).data;
|
|
35742
|
-
return new Matrix([
|
|
36146
|
+
return new Matrix([table4.data[0] ?? [], ...plain5.slice(1)]);
|
|
35743
36147
|
},
|
|
35744
36148
|
ARGS
|
|
35745
36149
|
),
|
|
@@ -38125,7 +38529,7 @@ function headerMode(args, i2, ctx, firstRow) {
|
|
|
38125
38529
|
if (mode === 1 || mode === 3) return true;
|
|
38126
38530
|
return fail(ERR.VALUE);
|
|
38127
38531
|
}
|
|
38128
|
-
var
|
|
38532
|
+
var keyOf2 = (values2) => JSON.stringify(values2);
|
|
38129
38533
|
var plain2 = (v) => v === void 0 || isError(v) ? null : v;
|
|
38130
38534
|
function compareBy(keys, rows) {
|
|
38131
38535
|
return (a2, b) => {
|
|
@@ -38165,12 +38569,12 @@ function groupby(args, ctx) {
|
|
|
38165
38569
|
if (rows.length === 0) fail(ERR.CALC);
|
|
38166
38570
|
const groups = /* @__PURE__ */ new Map();
|
|
38167
38571
|
for (const r of rows) {
|
|
38168
|
-
const key2 =
|
|
38572
|
+
const key2 = keyOf2(keysM.data[r]);
|
|
38169
38573
|
const found = groups.get(key2);
|
|
38170
38574
|
if (found) found.push(r);
|
|
38171
38575
|
else groups.set(key2, [r]);
|
|
38172
38576
|
}
|
|
38173
|
-
const
|
|
38577
|
+
const table4 = [...groups.values()].map((members3) => {
|
|
38174
38578
|
const key2 = keysM.data[members3[0]];
|
|
38175
38579
|
const cells3 = Array.from(
|
|
38176
38580
|
{ length: vCols },
|
|
@@ -38182,8 +38586,8 @@ function groupby(args, ctx) {
|
|
|
38182
38586
|
return [...key2, ...cells3];
|
|
38183
38587
|
});
|
|
38184
38588
|
for (const key2 of sort2) if (Math.abs(key2) > kCols + vCols) fail(ERR.VALUE);
|
|
38185
|
-
const order =
|
|
38186
|
-
const out = order.map((i2) =>
|
|
38589
|
+
const order = table4.map((_, i2) => i2).sort(compareBy(sort2, table4));
|
|
38590
|
+
const out = order.map((i2) => table4[i2]);
|
|
38187
38591
|
if (depth !== 0) {
|
|
38188
38592
|
const total2 = [
|
|
38189
38593
|
"Total",
|
|
@@ -38232,8 +38636,8 @@ function pivotby(args, ctx) {
|
|
|
38232
38636
|
const colKeys = /* @__PURE__ */ new Map();
|
|
38233
38637
|
for (const r of used) {
|
|
38234
38638
|
for (const [map, key2] of [
|
|
38235
|
-
[rowKeys,
|
|
38236
|
-
[colKeys,
|
|
38639
|
+
[rowKeys, keyOf2(rowsM.data[r])],
|
|
38640
|
+
[colKeys, keyOf2(colsM.data[r])]
|
|
38237
38641
|
]) {
|
|
38238
38642
|
const found = map.get(key2);
|
|
38239
38643
|
if (found) found.push(r);
|
|
@@ -38966,8 +39370,8 @@ function resolveName(node3, frame2) {
|
|
|
38966
39370
|
const value2 = evaluateDefinedName(node3.name, sheet, node3.prefix !== void 0, frame2);
|
|
38967
39371
|
if (value2 !== void 0) return value2;
|
|
38968
39372
|
if (!node3.prefix) {
|
|
38969
|
-
const
|
|
38970
|
-
if (!(isError(
|
|
39373
|
+
const table4 = resolveStructured({ table: node3.name, specials: [] }, frame2);
|
|
39374
|
+
if (!(isError(table4) && table4.error === "#NAME?")) return table4;
|
|
38971
39375
|
}
|
|
38972
39376
|
return ERR.NAME;
|
|
38973
39377
|
}
|
|
@@ -40617,8 +41021,8 @@ function deleteSheetInFormula(formula, sheetName, tableNames = []) {
|
|
|
40617
41021
|
for (const token of tokens3) {
|
|
40618
41022
|
const prefix3 = token.prefix;
|
|
40619
41023
|
const onSheet = prefix3 !== void 0 && prefix3.book === void 0 && prefix3.sheet2 === void 0 && same5(prefix3.sheet, sheetName);
|
|
40620
|
-
const
|
|
40621
|
-
if ((token.kind === "ref" || token.kind === "name") && onSheet ||
|
|
41024
|
+
const table4 = typeof token.value === "string" && tables.has(token.value.toLowerCase()) && (token.kind === "structured" || token.kind === "name" && !prefix3);
|
|
41025
|
+
if ((token.kind === "ref" || token.kind === "name") && onSheet || table4) {
|
|
40622
41026
|
token.text = "#REF!";
|
|
40623
41027
|
changed = true;
|
|
40624
41028
|
}
|
|
@@ -40681,11 +41085,11 @@ function renameTableColumnInFormula(formula, tableName, oldName, newName, inside
|
|
|
40681
41085
|
// xlsx/formula/structured-to-a1.ts
|
|
40682
41086
|
var abs = (row3, col, rowAbs = true) => `$${columnLabel(col)}${rowAbs ? "$" : ""}${row3 + 1}`;
|
|
40683
41087
|
function a1For(ref, t) {
|
|
40684
|
-
const { table:
|
|
40685
|
-
const { start, end } =
|
|
41088
|
+
const { table: table4 } = t;
|
|
41089
|
+
const { start, end } = table4.range;
|
|
40686
41090
|
const index3 = (name3) => {
|
|
40687
41091
|
if (name3 === void 0) return void 0;
|
|
40688
|
-
const i2 =
|
|
41092
|
+
const i2 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === name3.toLowerCase());
|
|
40689
41093
|
return i2 < 0 ? -1 : start.col + i2;
|
|
40690
41094
|
};
|
|
40691
41095
|
const c1 = index3(ref.column);
|
|
@@ -40693,10 +41097,10 @@ function a1For(ref, t) {
|
|
|
40693
41097
|
if (c1 === -1 || c2 === -1) return "#REF!";
|
|
40694
41098
|
const colLo = c1 ?? start.col;
|
|
40695
41099
|
const colHi = c2 ?? end.col;
|
|
40696
|
-
const headerRow =
|
|
40697
|
-
const totalsRow =
|
|
40698
|
-
const dataLo = start.row + (
|
|
40699
|
-
const dataHi = end.row - (
|
|
41100
|
+
const headerRow = table4.headerRow ? start.row : void 0;
|
|
41101
|
+
const totalsRow = table4.totalsRow ? end.row : void 0;
|
|
41102
|
+
const dataLo = start.row + (table4.headerRow ? 1 : 0);
|
|
41103
|
+
const dataHi = end.row - (table4.totalsRow ? 1 : 0);
|
|
40700
41104
|
const specials = new Set(ref.specials);
|
|
40701
41105
|
let rowLo;
|
|
40702
41106
|
let rowHi;
|
|
@@ -42129,8 +42533,8 @@ function sheetDataXml(ctx, sheet) {
|
|
|
42129
42533
|
].sort((a2, b) => a2 - b);
|
|
42130
42534
|
const spills = new SpillPlan(sheet);
|
|
42131
42535
|
const tables = /* @__PURE__ */ new Map();
|
|
42132
|
-
for (const
|
|
42133
|
-
tables.set(`${
|
|
42536
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
42537
|
+
tables.set(`${table4.ref.start.row}:${table4.ref.start.col}`, table4);
|
|
42134
42538
|
let out = "";
|
|
42135
42539
|
for (const row3 of rows) {
|
|
42136
42540
|
const cells3 = sheet.rows.get(row3);
|
|
@@ -42612,29 +43016,29 @@ function setChildText(doc, parent, local, text8, before) {
|
|
|
42612
43016
|
node3.textContent = text8;
|
|
42613
43017
|
if (!existing) insertBefore(parent, node3, before);
|
|
42614
43018
|
}
|
|
42615
|
-
function tableFilterRange(
|
|
43019
|
+
function tableFilterRange(table4) {
|
|
42616
43020
|
return {
|
|
42617
|
-
start:
|
|
42618
|
-
end: { ...
|
|
43021
|
+
start: table4.range.start,
|
|
43022
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
42619
43023
|
};
|
|
42620
43024
|
}
|
|
42621
|
-
function sourceColumnsForPatch(root,
|
|
43025
|
+
function sourceColumnsForPatch(root, table4, names) {
|
|
42622
43026
|
const list2 = xKid(root, "tableColumns");
|
|
42623
43027
|
const source2 = list2 ? xKids(list2, "tableColumn") : [];
|
|
42624
43028
|
const byId2 = new Map(source2.map((c2) => [Number(c2.getAttribute("id")), c2]));
|
|
42625
43029
|
const byName2 = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
42626
|
-
const tracked =
|
|
43030
|
+
const tracked = table4.partName !== void 0 || table4.columns.some((c2) => c2.sourceId !== void 0);
|
|
42627
43031
|
const used = /* @__PURE__ */ new Set();
|
|
42628
43032
|
return names.map((name3, index3) => {
|
|
42629
|
-
const id3 =
|
|
43033
|
+
const id3 = table4.columns[index3]?.sourceId;
|
|
42630
43034
|
const match2 = id3 !== void 0 ? byId2.get(id3) : tracked ? void 0 : source2.length === names.length ? source2[index3] : byName2.get(name3.toLowerCase());
|
|
42631
43035
|
if (!match2 || used.has(match2)) return void 0;
|
|
42632
43036
|
used.add(match2);
|
|
42633
43037
|
return match2;
|
|
42634
43038
|
});
|
|
42635
43039
|
}
|
|
42636
|
-
function syncColumnFilters(doc, filter2,
|
|
42637
|
-
|
|
43040
|
+
function syncColumnFilters(doc, filter2, table4) {
|
|
43041
|
+
table4.columns.forEach((column2, index3) => {
|
|
42638
43042
|
const node3 = xKids(filter2, "filterColumn").find(
|
|
42639
43043
|
(n) => Number(n.getAttribute("colId")) === index3
|
|
42640
43044
|
);
|
|
@@ -42656,29 +43060,29 @@ function syncColumnFilters(doc, filter2, table3) {
|
|
|
42656
43060
|
}
|
|
42657
43061
|
});
|
|
42658
43062
|
}
|
|
42659
|
-
function patchAutoFilter(doc, root,
|
|
43063
|
+
function patchAutoFilter(doc, root, table4, before, names) {
|
|
42660
43064
|
const existing = xKid(root, "autoFilter");
|
|
42661
|
-
if (!
|
|
43065
|
+
if (!table4.headerRow) {
|
|
42662
43066
|
if (existing) root.removeChild(existing);
|
|
42663
43067
|
return;
|
|
42664
43068
|
}
|
|
42665
43069
|
const filter2 = existing ?? doc.createElementNS(NS.x, "autoFilter");
|
|
42666
|
-
const range2 = tableFilterRange(
|
|
43070
|
+
const range2 = tableFilterRange(table4);
|
|
42667
43071
|
filter2.setAttribute("ref", formatRange(range2));
|
|
42668
43072
|
const list2 = xKid(root, "tableColumns");
|
|
42669
43073
|
const original = list2 ? xKids(list2, "tableColumn") : [];
|
|
42670
|
-
const current = new Map(sourceColumnsForPatch(root,
|
|
43074
|
+
const current = new Map(sourceColumnsForPatch(root, table4, names).map((c2, index3) => [c2, index3]));
|
|
42671
43075
|
for (const column2 of xKids(filter2, "filterColumn")) {
|
|
42672
43076
|
const old = original[Number(column2.getAttribute("colId") ?? "0")];
|
|
42673
43077
|
const index3 = old ? current.get(old) : void 0;
|
|
42674
43078
|
if (index3 === void 0) filter2.removeChild(column2);
|
|
42675
43079
|
else column2.setAttribute("colId", num(index3));
|
|
42676
43080
|
}
|
|
42677
|
-
syncColumnFilters(doc, filter2,
|
|
43081
|
+
syncColumnFilters(doc, filter2, table4);
|
|
42678
43082
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
42679
43083
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
42680
43084
|
if (!sort2) return;
|
|
42681
|
-
const moved = before.start.row !==
|
|
43085
|
+
const moved = before.start.row !== table4.range.start.row || before.start.col !== table4.range.start.col || before.end.col !== table4.range.end.col;
|
|
42682
43086
|
if (moved) {
|
|
42683
43087
|
sort2.parentNode?.removeChild(sort2);
|
|
42684
43088
|
return;
|
|
@@ -42700,7 +43104,7 @@ function patchAutoFilter(doc, root, table3, before, names) {
|
|
|
42700
43104
|
}
|
|
42701
43105
|
}
|
|
42702
43106
|
var COLUMN_CHILD_ORDER = ["calculatedColumnFormula", "totalsRowFormula", "xmlColumnPr", "extLst"];
|
|
42703
|
-
function patchColumns(doc, root, sheet,
|
|
43107
|
+
function patchColumns(doc, root, sheet, table4, names) {
|
|
42704
43108
|
let list2 = xKid(root, "tableColumns");
|
|
42705
43109
|
if (!list2) {
|
|
42706
43110
|
list2 = doc.createElementNS(NS.x, "tableColumns");
|
|
@@ -42708,7 +43112,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42708
43112
|
}
|
|
42709
43113
|
const sourceColumns = xKids(list2, "tableColumn");
|
|
42710
43114
|
const ids = /* @__PURE__ */ new Set();
|
|
42711
|
-
const picked = sourceColumnsForPatch(root,
|
|
43115
|
+
const picked = sourceColumnsForPatch(root, table4, names).map((match2) => {
|
|
42712
43116
|
if (!match2) return void 0;
|
|
42713
43117
|
const id3 = Number(match2.getAttribute("id"));
|
|
42714
43118
|
if (Number.isInteger(id3) && id3 >= 0 && !ids.has(id3)) ids.add(id3);
|
|
@@ -42717,15 +43121,15 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42717
43121
|
});
|
|
42718
43122
|
for (const column2 of sourceColumns) list2.removeChild(column2);
|
|
42719
43123
|
let nextId3 = Math.max(0, ...ids) + 1;
|
|
42720
|
-
const totalsRow =
|
|
43124
|
+
const totalsRow = table4.range.end.row;
|
|
42721
43125
|
names.forEach((name3, index3) => {
|
|
42722
43126
|
const column2 = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
42723
43127
|
if (!column2.getAttribute("id")) column2.setAttribute("id", num(nextId3++));
|
|
42724
43128
|
column2.setAttribute("name", name3);
|
|
42725
|
-
const model =
|
|
42726
|
-
const fn =
|
|
43129
|
+
const model = table4.columns[index3];
|
|
43130
|
+
const fn = table4.totalsRow ? model?.totalsRowFunction : void 0;
|
|
42727
43131
|
setOrRemove(column2, "totalsRowFunction", fn);
|
|
42728
|
-
setOrRemove(column2, "totalsRowLabel",
|
|
43132
|
+
setOrRemove(column2, "totalsRowLabel", table4.totalsRow ? model?.totalsRowLabel : void 0);
|
|
42729
43133
|
const calculated = model?.calculatedColumnFormula;
|
|
42730
43134
|
setChildText(
|
|
42731
43135
|
doc,
|
|
@@ -42736,7 +43140,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42736
43140
|
);
|
|
42737
43141
|
if (fn !== "custom") setChildText(doc, column2, "totalsRowFormula", void 0, []);
|
|
42738
43142
|
else {
|
|
42739
|
-
const cellFormula = sheet.rows.get(totalsRow)?.get(
|
|
43143
|
+
const cellFormula = sheet.rows.get(totalsRow)?.get(table4.range.start.col + index3)?.formula;
|
|
42740
43144
|
if (cellFormula)
|
|
42741
43145
|
setChildText(
|
|
42742
43146
|
doc,
|
|
@@ -42750,19 +43154,19 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42750
43154
|
});
|
|
42751
43155
|
list2.setAttribute("count", num(names.length));
|
|
42752
43156
|
}
|
|
42753
|
-
function patchStyleInfo(doc, root,
|
|
43157
|
+
function patchStyleInfo(doc, root, table4) {
|
|
42754
43158
|
let info = xKid(root, "tableStyleInfo");
|
|
42755
43159
|
if (!info) {
|
|
42756
43160
|
info = doc.createElementNS(NS.x, "tableStyleInfo");
|
|
42757
43161
|
insertBefore(root, info, ["extLst"]);
|
|
42758
43162
|
}
|
|
42759
|
-
setOrRemove(info, "name",
|
|
42760
|
-
info.setAttribute("showFirstColumn", flag2(
|
|
42761
|
-
info.setAttribute("showLastColumn", flag2(
|
|
42762
|
-
info.setAttribute("showRowStripes", flag2(
|
|
42763
|
-
info.setAttribute("showColumnStripes", flag2(
|
|
43163
|
+
setOrRemove(info, "name", table4.styleName);
|
|
43164
|
+
info.setAttribute("showFirstColumn", flag2(table4.showFirstColumn, false));
|
|
43165
|
+
info.setAttribute("showLastColumn", flag2(table4.showLastColumn, false));
|
|
43166
|
+
info.setAttribute("showRowStripes", flag2(table4.showRowStripes, true));
|
|
43167
|
+
info.setAttribute("showColumnStripes", flag2(table4.showColumnStripes, false));
|
|
42764
43168
|
}
|
|
42765
|
-
function patchTableXml(sourceXml, sheet,
|
|
43169
|
+
function patchTableXml(sourceXml, sheet, table4, id3, names) {
|
|
42766
43170
|
let doc;
|
|
42767
43171
|
try {
|
|
42768
43172
|
doc = parseXml(sourceXml, { label: "XLSX table" });
|
|
@@ -42771,80 +43175,80 @@ function patchTableXml(sourceXml, sheet, table3, id3, names) {
|
|
|
42771
43175
|
}
|
|
42772
43176
|
const root = doc.documentElement;
|
|
42773
43177
|
if (root.localName !== "table") return void 0;
|
|
42774
|
-
const before = parseRange(root.getAttribute("ref") ?? "") ??
|
|
43178
|
+
const before = parseRange(root.getAttribute("ref") ?? "") ?? table4.range;
|
|
42775
43179
|
root.setAttribute("id", num(id3));
|
|
42776
|
-
root.setAttribute("name",
|
|
42777
|
-
root.setAttribute("displayName",
|
|
42778
|
-
root.setAttribute("ref", formatRange(
|
|
42779
|
-
setOrRemove(root, "headerRowCount",
|
|
42780
|
-
if (
|
|
43180
|
+
root.setAttribute("name", table4.name);
|
|
43181
|
+
root.setAttribute("displayName", table4.displayName || table4.name);
|
|
43182
|
+
root.setAttribute("ref", formatRange(table4.range));
|
|
43183
|
+
setOrRemove(root, "headerRowCount", table4.headerRow ? void 0 : "0");
|
|
43184
|
+
if (table4.totalsRow) {
|
|
42781
43185
|
root.setAttribute("totalsRowCount", "1");
|
|
42782
43186
|
root.removeAttribute("totalsRowShown");
|
|
42783
43187
|
} else {
|
|
42784
43188
|
root.removeAttribute("totalsRowCount");
|
|
42785
43189
|
if (!root.hasAttribute("totalsRowShown")) root.setAttribute("totalsRowShown", "0");
|
|
42786
43190
|
}
|
|
42787
|
-
patchAutoFilter(doc, root,
|
|
42788
|
-
patchColumns(doc, root, sheet,
|
|
42789
|
-
patchStyleInfo(doc, root,
|
|
43191
|
+
patchAutoFilter(doc, root, table4, before, names);
|
|
43192
|
+
patchColumns(doc, root, sheet, table4, names);
|
|
43193
|
+
patchStyleInfo(doc, root, table4);
|
|
42790
43194
|
return buildXml(doc);
|
|
42791
43195
|
}
|
|
42792
43196
|
|
|
42793
43197
|
// xlsx/write/tables.ts
|
|
42794
43198
|
var headerTextOf = (value2) => typeof value2 === "string" ? value2 : typeof value2 === "number" || typeof value2 === "boolean" ? String(value2).toUpperCase() : void 0;
|
|
42795
|
-
function resolveTableColumns(sheet,
|
|
43199
|
+
function resolveTableColumns(sheet, table4) {
|
|
42796
43200
|
const headerText = /* @__PURE__ */ new Map();
|
|
42797
43201
|
const used = /* @__PURE__ */ new Set();
|
|
42798
|
-
const width =
|
|
43202
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
42799
43203
|
const names = [];
|
|
42800
43204
|
for (let i2 = 0; i2 < width; i2++) {
|
|
42801
|
-
const col =
|
|
42802
|
-
const row3 =
|
|
42803
|
-
const fromCell =
|
|
42804
|
-
let name3 = (fromCell?.trim() ? fromCell : void 0) ??
|
|
43205
|
+
const col = table4.range.start.col + i2;
|
|
43206
|
+
const row3 = table4.range.start.row;
|
|
43207
|
+
const fromCell = table4.headerRow ? headerTextOf(sheet.rows.get(row3)?.get(col)?.value) : void 0;
|
|
43208
|
+
let name3 = (fromCell?.trim() ? fromCell : void 0) ?? table4.columns[i2]?.name ?? `Column${i2 + 1}`;
|
|
42805
43209
|
if (!name3.trim()) name3 = `Column${i2 + 1}`;
|
|
42806
43210
|
let unique4 = name3;
|
|
42807
43211
|
for (let n = 2; used.has(unique4.toLowerCase()); n++) unique4 = `${name3}${n}`;
|
|
42808
43212
|
used.add(unique4.toLowerCase());
|
|
42809
43213
|
names.push(unique4);
|
|
42810
43214
|
const cell = sheet.rows.get(row3)?.get(col);
|
|
42811
|
-
if (
|
|
43215
|
+
if (table4.headerRow && (typeof cell?.value !== "string" || cell.value !== unique4))
|
|
42812
43216
|
headerText.set(`${row3}:${col}`, unique4);
|
|
42813
43217
|
}
|
|
42814
43218
|
return { names, headerText };
|
|
42815
43219
|
}
|
|
42816
|
-
function tableXml(
|
|
42817
|
-
const range2 = formatRange(
|
|
42818
|
-
const filterEnd = { ...
|
|
42819
|
-
const criteria =
|
|
42820
|
-
const filterRef = formatRange({ start:
|
|
42821
|
-
const filter2 =
|
|
43220
|
+
function tableXml(table4, id3, names) {
|
|
43221
|
+
const range2 = formatRange(table4.range);
|
|
43222
|
+
const filterEnd = { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) };
|
|
43223
|
+
const criteria = table4.columns.map((column2, index3) => column2.filter ? filterColumnXml(index3, column2.filter) : "").join("");
|
|
43224
|
+
const filterRef = formatRange({ start: table4.range.start, end: filterEnd });
|
|
43225
|
+
const filter2 = table4.headerRow ? criteria ? `<autoFilter ref="${filterRef}">${criteria}</autoFilter>` : `<autoFilter ref="${filterRef}"/>` : "";
|
|
42822
43226
|
const columns = names.map((name3, index3) => {
|
|
42823
|
-
const column2 =
|
|
43227
|
+
const column2 = table4.columns[index3];
|
|
42824
43228
|
const calculated = column2?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText3(addFuturePrefixes(column2.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
42825
43229
|
const values2 = attrs2({
|
|
42826
43230
|
id: index3 + 1,
|
|
42827
43231
|
name: name3,
|
|
42828
|
-
totalsRowFunction:
|
|
42829
|
-
totalsRowLabel:
|
|
43232
|
+
totalsRowFunction: table4.totalsRow ? column2?.totalsRowFunction : void 0,
|
|
43233
|
+
totalsRowLabel: table4.totalsRow ? column2?.totalsRowLabel : void 0
|
|
42830
43234
|
});
|
|
42831
43235
|
return calculated ? `<tableColumn${values2}>${calculated}</tableColumn>` : `<tableColumn${values2}/>`;
|
|
42832
43236
|
}).join("");
|
|
42833
43237
|
const style3 = attrs2({
|
|
42834
|
-
name:
|
|
42835
|
-
showFirstColumn:
|
|
42836
|
-
showLastColumn:
|
|
42837
|
-
showRowStripes:
|
|
42838
|
-
showColumnStripes:
|
|
43238
|
+
name: table4.styleName,
|
|
43239
|
+
showFirstColumn: table4.showFirstColumn ?? false,
|
|
43240
|
+
showLastColumn: table4.showLastColumn ?? false,
|
|
43241
|
+
showRowStripes: table4.showRowStripes ?? true,
|
|
43242
|
+
showColumnStripes: table4.showColumnStripes ?? false
|
|
42839
43243
|
});
|
|
42840
43244
|
const head = attrs2({
|
|
42841
43245
|
id: id3,
|
|
42842
|
-
name:
|
|
42843
|
-
displayName:
|
|
43246
|
+
name: table4.name,
|
|
43247
|
+
displayName: table4.displayName || table4.name,
|
|
42844
43248
|
ref: range2,
|
|
42845
|
-
headerRowCount:
|
|
42846
|
-
totalsRowCount:
|
|
42847
|
-
totalsRowShown:
|
|
43249
|
+
headerRowCount: table4.headerRow ? void 0 : 0,
|
|
43250
|
+
totalsRowCount: table4.totalsRow ? 1 : void 0,
|
|
43251
|
+
totalsRowShown: table4.totalsRow ? void 0 : false
|
|
42848
43252
|
});
|
|
42849
43253
|
return `${XML_HEADER}<table xmlns="${NS.x}"${head}>${filter2}<tableColumns count="${names.length}">${columns}</tableColumns><tableStyleInfo${style3}/></table>`;
|
|
42850
43254
|
}
|
|
@@ -42858,24 +43262,24 @@ var SUBTOTAL_CODES = {
|
|
|
42858
43262
|
sum: 109,
|
|
42859
43263
|
var: 110
|
|
42860
43264
|
};
|
|
42861
|
-
function totalsRowFormulas(sheet,
|
|
43265
|
+
function totalsRowFormulas(sheet, table4, names) {
|
|
42862
43266
|
const out = /* @__PURE__ */ new Map();
|
|
42863
|
-
if (!
|
|
42864
|
-
const row3 =
|
|
43267
|
+
if (!table4.totalsRow) return out;
|
|
43268
|
+
const row3 = table4.range.end.row;
|
|
42865
43269
|
names.forEach((name3, index3) => {
|
|
42866
|
-
const code = SUBTOTAL_CODES[
|
|
43270
|
+
const code = SUBTOTAL_CODES[table4.columns[index3]?.totalsRowFunction ?? ""];
|
|
42867
43271
|
if (code === void 0) return;
|
|
42868
|
-
const col =
|
|
43272
|
+
const col = table4.range.start.col + index3;
|
|
42869
43273
|
const escaped = name3.replace(/['#[\]]/g, "'$&");
|
|
42870
|
-
const formula = `SUBTOTAL(${code},${
|
|
43274
|
+
const formula = `SUBTOTAL(${code},${table4.displayName || table4.name}[${escaped}])`;
|
|
42871
43275
|
if (sheet.rows.get(row3)?.get(col)?.formula !== formula) out.set(`${row3}:${col}`, formula);
|
|
42872
43276
|
});
|
|
42873
43277
|
return out;
|
|
42874
43278
|
}
|
|
42875
|
-
function resolveTableNames(
|
|
42876
|
-
const display =
|
|
43279
|
+
function resolveTableNames(table4, before, index3) {
|
|
43280
|
+
const display = table4.displayName || table4.name;
|
|
42877
43281
|
const displayName = before && before.displayName === display ? display : safeTableName(display, index3);
|
|
42878
|
-
const name3 = before && before.name ===
|
|
43282
|
+
const name3 = before && before.name === table4.name ? table4.name : table4.name === display ? displayName : safeTableName(table4.name, index3);
|
|
42879
43283
|
return { name: name3, displayName };
|
|
42880
43284
|
}
|
|
42881
43285
|
function safeTableName(name3, index3) {
|
|
@@ -42968,21 +43372,21 @@ function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
|
42968
43372
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
42969
43373
|
const before = sourceXml && original.partName ? parseTable3(sourceXml, original.partName) : void 0;
|
|
42970
43374
|
const { name: name3, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
42971
|
-
const
|
|
42972
|
-
const { names, headerText: forced } = resolveTableColumns(sheet,
|
|
43375
|
+
const table4 = name3 === original.name && displayName === original.displayName ? original : { ...original, name: name3, displayName };
|
|
43376
|
+
const { names, headerText: forced } = resolveTableColumns(sheet, table4);
|
|
42973
43377
|
for (const [key2, text8] of forced) headerText.set(key2, text8);
|
|
42974
|
-
const totals = totalsRowFormulas(sheet,
|
|
43378
|
+
const totals = totalsRowFormulas(sheet, table4, names);
|
|
42975
43379
|
for (const [key2, formula] of totals) formulas.set(key2, formula);
|
|
42976
|
-
let id3 =
|
|
42977
|
-
const unchanged =
|
|
43380
|
+
let id3 = table4.id;
|
|
43381
|
+
const unchanged = table4.partName && sourceXml && !writer.has(table4.partName) && !ctx.tableIds.has(id3) && forced.size === 0 && totals.size === 0 && table4 === original && sameModel(before, table4);
|
|
42978
43382
|
let part;
|
|
42979
|
-
if (unchanged &&
|
|
42980
|
-
part =
|
|
43383
|
+
if (unchanged && table4.partName) {
|
|
43384
|
+
part = table4.partName;
|
|
42981
43385
|
writer.carry(part);
|
|
42982
43386
|
} else {
|
|
42983
43387
|
while (ctx.tableIds.has(id3) || id3 < 1) id3++;
|
|
42984
|
-
part =
|
|
42985
|
-
const xml = (sourceXml && patchTableXml(sourceXml, sheet,
|
|
43388
|
+
part = table4.partName && !writer.has(table4.partName) ? table4.partName : writer.uniqueName((n) => `xl/tables/table${n}.xml`, ctx.reserved);
|
|
43389
|
+
const xml = (sourceXml && patchTableXml(sourceXml, sheet, table4, id3, names)) ?? tableXml(table4, id3, names);
|
|
42986
43390
|
writer.add(part, xml, CONTENT_TYPES.table);
|
|
42987
43391
|
}
|
|
42988
43392
|
ctx.tableIds.add(id3);
|
|
@@ -43427,13 +43831,13 @@ function derivedFieldXml(pivot, entry3, date1904) {
|
|
|
43427
43831
|
const days = dateGroupDays(entry3.group);
|
|
43428
43832
|
const labels = dateUnitLabels(entry3.unit, range2, days, date1904, entry3.group);
|
|
43429
43833
|
const base2 = pivot.fields.indexOf(entry3.group.field);
|
|
43430
|
-
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((
|
|
43834
|
+
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>`;
|
|
43431
43835
|
}
|
|
43432
43836
|
function groupXml2(pivot, name3, index3) {
|
|
43433
43837
|
const group = groupOf(pivot, name3);
|
|
43434
43838
|
if (!group) return "";
|
|
43435
43839
|
const labels = numberGroupLabels(group);
|
|
43436
|
-
return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((
|
|
43840
|
+
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>`;
|
|
43437
43841
|
}
|
|
43438
43842
|
function slicerExt(pivot) {
|
|
43439
43843
|
if (pivot.slicerCacheId === void 0) return "";
|
|
@@ -43493,6 +43897,10 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43493
43897
|
const compact3 = pivot.layout === "compact";
|
|
43494
43898
|
const outline2 = pivot.layout === "compact" || pivot.layout === "outline";
|
|
43495
43899
|
const top = (pivot.subtotalPosition ?? (outline2 ? "top" : "bottom")) === "top";
|
|
43900
|
+
const named3 = (field2, item) => {
|
|
43901
|
+
const text8 = pivotItemName(pivot, field2, item);
|
|
43902
|
+
return text8 === void 0 ? "" : attrs2({ n: encodeEscapes(text8) });
|
|
43903
|
+
};
|
|
43496
43904
|
const fields = pivot.fields.map((name3, index3) => {
|
|
43497
43905
|
const isDate = pivot.dateFields?.includes(name3) ?? false;
|
|
43498
43906
|
const at2 = rowIdx.indexOf(index3);
|
|
@@ -43507,7 +43915,7 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43507
43915
|
custom.map((fn) => [PIVOT_SUBTOTALS[fn].attr, true])
|
|
43508
43916
|
);
|
|
43509
43917
|
const entries = automatic ? '<item t="default"/>' : custom.map((fn) => `<item t="${PIVOT_SUBTOTALS[fn].item}"/>`).join("");
|
|
43510
|
-
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>`;
|
|
43918
|
+
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>`;
|
|
43511
43919
|
}).join("");
|
|
43512
43920
|
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
43513
43921
|
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
@@ -43537,6 +43945,15 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43537
43945
|
const root = doc.documentElement;
|
|
43538
43946
|
root.setAttribute("name", pivot.name);
|
|
43539
43947
|
root.setAttribute("cacheId", String(cacheId));
|
|
43948
|
+
const caps = pivotCaptions(pivot);
|
|
43949
|
+
root.setAttribute("dataCaption", caps.values);
|
|
43950
|
+
for (const [attribute4, key2] of [
|
|
43951
|
+
["rowHeaderCaption", "rowLabels"],
|
|
43952
|
+
["colHeaderCaption", "columnLabels"],
|
|
43953
|
+
["grandTotalCaption", "grandTotal"]
|
|
43954
|
+
])
|
|
43955
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2] || root.hasAttribute(attribute4))
|
|
43956
|
+
root.setAttribute(attribute4, caps[key2]);
|
|
43540
43957
|
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
43541
43958
|
if (rowsAxis && valuesAt < rowIdx.length) root.setAttribute("dataPosition", String(valuesAt));
|
|
43542
43959
|
else root.removeAttribute("dataPosition");
|
|
@@ -43604,7 +44021,9 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43604
44021
|
}
|
|
43605
44022
|
function dateFilterXml(pivot, filter2) {
|
|
43606
44023
|
const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
43607
|
-
const id3 = Number(
|
|
44024
|
+
const id3 = Number(
|
|
44025
|
+
/\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
|
|
44026
|
+
);
|
|
43608
44027
|
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>`;
|
|
43609
44028
|
}
|
|
43610
44029
|
|
|
@@ -43660,7 +44079,7 @@ var PivotWritePlan = class {
|
|
|
43660
44079
|
this.tableParts.set(pivot, pivot.partName);
|
|
43661
44080
|
continue;
|
|
43662
44081
|
}
|
|
43663
|
-
const
|
|
44082
|
+
const table4 = pivot.partName ?? writer.uniqueName((n) => `xl/pivotTables/pivotTable${n}.xml`, reserved);
|
|
43664
44083
|
const definition = writer.uniqueName(
|
|
43665
44084
|
(n) => `xl/pivotCache/pivotCacheDefinition${n}.xml`,
|
|
43666
44085
|
reserved
|
|
@@ -43682,24 +44101,24 @@ var PivotWritePlan = class {
|
|
|
43682
44101
|
TYPES2.definition
|
|
43683
44102
|
);
|
|
43684
44103
|
writer.rels(definition, cacheRels);
|
|
43685
|
-
writer.add(
|
|
44104
|
+
writer.add(table4, pivotTableXml(pivot, cacheId, cache3), TYPES2.table);
|
|
43686
44105
|
const tableRels = new RelationshipSet();
|
|
43687
|
-
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(
|
|
43688
|
-
writer.rels(
|
|
44106
|
+
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(table4, definition));
|
|
44107
|
+
writer.rels(table4, tableRels);
|
|
43689
44108
|
const rid2 = bookRels.add(
|
|
43690
44109
|
RELATIONSHIP_TYPES.pivotCacheDefinition,
|
|
43691
44110
|
relativeTarget(bookPart, definition)
|
|
43692
44111
|
);
|
|
43693
44112
|
entries.push(`<pivotCache cacheId="${cacheId++}" r:id="${rid2}"/>`);
|
|
43694
|
-
this.tableParts.set(pivot,
|
|
44113
|
+
this.tableParts.set(pivot, table4);
|
|
43695
44114
|
}
|
|
43696
44115
|
this.cachesXml = owns ? entries.length ? `<pivotCaches>${entries.join("")}</pivotCaches>` : "" : void 0;
|
|
43697
44116
|
}
|
|
43698
44117
|
writeSheet(writer, sheet, part, rels) {
|
|
43699
44118
|
for (const pivot of sheet.pivotTables ?? []) {
|
|
43700
|
-
const
|
|
43701
|
-
writer.carry(
|
|
43702
|
-
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part,
|
|
44119
|
+
const table4 = this.tableParts.get(pivot);
|
|
44120
|
+
writer.carry(table4);
|
|
44121
|
+
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part, table4));
|
|
43703
44122
|
}
|
|
43704
44123
|
}
|
|
43705
44124
|
};
|
|
@@ -43869,9 +44288,9 @@ function slicerTarget(workbook, cache3) {
|
|
|
43869
44288
|
const source2 = cache3.source;
|
|
43870
44289
|
for (const [sheetIndex2, sheet] of workbook.sheets.entries()) {
|
|
43871
44290
|
if (source2.kind === "table") {
|
|
43872
|
-
const
|
|
43873
|
-
const offset2 =
|
|
43874
|
-
if (
|
|
44291
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === source2.tableId);
|
|
44292
|
+
const offset2 = table4?.columns.findIndex((column2) => column2.sourceId === source2.column) ?? -1;
|
|
44293
|
+
if (table4 && offset2 >= 0) return { kind: "table", sheet, sheetIndex: sheetIndex2, table: table4, offset: offset2 };
|
|
43875
44294
|
} else {
|
|
43876
44295
|
const first3 = source2.pivots[0];
|
|
43877
44296
|
const pivot = first3 && sheet.sheetId === first3.tabId ? sheet.pivotTables?.find((entry3) => entry3.name === first3.name) : void 0;
|
|
@@ -44060,12 +44479,12 @@ function slicerCacheXml(cache3, facts) {
|
|
|
44060
44479
|
ext.setAttribute("xmlns:x15", X153);
|
|
44061
44480
|
list2.appendChild(ext);
|
|
44062
44481
|
}
|
|
44063
|
-
let
|
|
44064
|
-
if (!
|
|
44065
|
-
|
|
44066
|
-
|
|
44067
|
-
if (cache3.sortOrder === "descending")
|
|
44068
|
-
else
|
|
44482
|
+
let table4 = first(ext, "tableSlicerCache", X153);
|
|
44483
|
+
if (!table4) table4 = ext.appendChild(make2(X153, "x15:tableSlicerCache"));
|
|
44484
|
+
table4.setAttribute("tableId", String(source2.tableId));
|
|
44485
|
+
table4.setAttribute("column", String(source2.column));
|
|
44486
|
+
if (cache3.sortOrder === "descending") table4.setAttribute("sortOrder", "descending");
|
|
44487
|
+
else table4.removeAttribute("sortOrder");
|
|
44069
44488
|
return XML_HEADER + buildXml(root);
|
|
44070
44489
|
}
|
|
44071
44490
|
|
|
@@ -44618,12 +45037,12 @@ function rewriteSheetFormulas(sheet, rewrite2, formulaCells) {
|
|
|
44618
45037
|
}
|
|
44619
45038
|
{
|
|
44620
45039
|
const name3 = sheet.name;
|
|
44621
|
-
for (const
|
|
44622
|
-
for (const [index3, column2] of
|
|
45040
|
+
for (const table4 of sheet.tables)
|
|
45041
|
+
for (const [index3, column2] of table4.columns.entries())
|
|
44623
45042
|
if (column2.calculatedColumnFormula !== void 0)
|
|
44624
45043
|
column2.calculatedColumnFormula = safe(rewrite2, column2.calculatedColumnFormula, name3, {
|
|
44625
|
-
row:
|
|
44626
|
-
col:
|
|
45044
|
+
row: table4.range.start.row + (table4.headerRow ? 1 : 0),
|
|
45045
|
+
col: table4.range.start.col + index3
|
|
44627
45046
|
});
|
|
44628
45047
|
if (formulaCells) {
|
|
44629
45048
|
for (const at2 of formulaCells) {
|
|
@@ -44688,14 +45107,14 @@ function tableHeaderAt(sheet, row3, col) {
|
|
|
44688
45107
|
);
|
|
44689
45108
|
}
|
|
44690
45109
|
function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
44691
|
-
const
|
|
44692
|
-
if (!
|
|
44693
|
-
const column2 =
|
|
45110
|
+
const table4 = tableHeaderAt(sheet, row3, col);
|
|
45111
|
+
if (!table4) return;
|
|
45112
|
+
const column2 = table4.columns[col - table4.range.start.col];
|
|
44694
45113
|
if (!column2) return;
|
|
44695
45114
|
const text8 = displayText(ctx.workbook, getCell(sheet, row3, col)).trim();
|
|
44696
45115
|
if (!text8 || column2.name === text8) return;
|
|
44697
45116
|
const oldName = column2.name;
|
|
44698
|
-
const others =
|
|
45117
|
+
const others = table4.columns.filter((entry3) => entry3 !== column2).map((entry3) => entry3.name);
|
|
44699
45118
|
const newName = uniqueHeaders([...others, text8]).at(-1);
|
|
44700
45119
|
column2.name = newName;
|
|
44701
45120
|
if (newName !== text8) writeValue(sheet, row3, col, newName);
|
|
@@ -44705,10 +45124,10 @@ function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
|
44705
45124
|
ctx.workbook,
|
|
44706
45125
|
(formula, formulaSheet, at2) => renameTableColumnInFormula(
|
|
44707
45126
|
formula,
|
|
44708
|
-
|
|
45127
|
+
table4.name,
|
|
44709
45128
|
oldName,
|
|
44710
45129
|
newName,
|
|
44711
|
-
formulaSheet === sheet.name && !!at2 && rangeContains(
|
|
45130
|
+
formulaSheet === sheet.name && !!at2 && rangeContains(table4.range, at2)
|
|
44712
45131
|
),
|
|
44713
45132
|
cells3
|
|
44714
45133
|
);
|
|
@@ -45832,11 +46251,11 @@ function uniqueColumnName(columns) {
|
|
|
45832
46251
|
const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
|
|
45833
46252
|
for (let n = 1; ; n++) if (!taken.has(`column${n}`)) return `Column${n}`;
|
|
45834
46253
|
}
|
|
45835
|
-
function shiftTable(sheet,
|
|
45836
|
-
const old =
|
|
46254
|
+
function shiftTable(sheet, table4, shift2, moveRange) {
|
|
46255
|
+
const old = table4.range;
|
|
45837
46256
|
const range2 = moveRange(old);
|
|
45838
46257
|
if (!range2) return [];
|
|
45839
|
-
const next = { ...
|
|
46258
|
+
const next = { ...table4, range: range2, columns: [...table4.columns] };
|
|
45840
46259
|
const widened = range2.end.col - range2.start.col !== old.end.col - old.start.col;
|
|
45841
46260
|
if (shift2.axis === "col" && widened) {
|
|
45842
46261
|
if (shift2.count > 0) {
|
|
@@ -46312,8 +46731,8 @@ function cellText(inner2) {
|
|
|
46312
46731
|
).replace(/ /g, " ").trim();
|
|
46313
46732
|
}
|
|
46314
46733
|
function parseHtmlTable(html, base2) {
|
|
46315
|
-
const
|
|
46316
|
-
if (
|
|
46734
|
+
const table4 = /<table\b[^>]*>([\s\S]*?)<\/table>/i.exec(html)?.[1];
|
|
46735
|
+
if (table4 === void 0) return void 0;
|
|
46317
46736
|
const classes = /* @__PURE__ */ new Map();
|
|
46318
46737
|
for (const block of html.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi))
|
|
46319
46738
|
for (const rule2 of removeAll(block[1] ?? "", ["<!--", "-->"]).matchAll(
|
|
@@ -46326,7 +46745,7 @@ function parseHtmlTable(html, base2) {
|
|
|
46326
46745
|
const hyperlinks = [];
|
|
46327
46746
|
let r = 0;
|
|
46328
46747
|
let spanned = 0;
|
|
46329
|
-
for (const tr of
|
|
46748
|
+
for (const tr of table4.matchAll(/<tr\b[^>]*>([\s\S]*?)(?=<tr\b|<\/tbody|<\/table|$)/gi)) {
|
|
46330
46749
|
const row3 = grid[r] ??= [];
|
|
46331
46750
|
let c2 = 0;
|
|
46332
46751
|
for (const td of (tr[1] ?? "").matchAll(
|
|
@@ -47178,9 +47597,9 @@ function filterColumn(ctx, s, col, values2) {
|
|
|
47178
47597
|
}
|
|
47179
47598
|
function sortByColumn(ctx, s, col, descending) {
|
|
47180
47599
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47181
|
-
const
|
|
47600
|
+
const table4 = sheet.tables.find((t) => col >= t.range.start.col && col <= t.range.end.col);
|
|
47182
47601
|
const filter2 = sheet.autoFilter;
|
|
47183
|
-
const target2 =
|
|
47602
|
+
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;
|
|
47184
47603
|
if (!target2) throw new Error("The column is not inside a table or an auto-filter range.");
|
|
47185
47604
|
const range2 = target2.totals ? { start: target2.range.start, end: { ...target2.range.end, row: target2.range.end.row - 1 } } : target2.range;
|
|
47186
47605
|
ctx.run(
|
|
@@ -47240,12 +47659,12 @@ function restore(sheet, saved) {
|
|
|
47240
47659
|
Object.assign(cell, saved.fields);
|
|
47241
47660
|
}
|
|
47242
47661
|
var valueAt = (sheet, row3, col) => getCell(sheet, row3, col)?.value ?? null;
|
|
47243
|
-
function computeDataTable(workbook, calc, sheetIndex2,
|
|
47662
|
+
function computeDataTable(workbook, calc, sheetIndex2, table4) {
|
|
47244
47663
|
const sheet = sheetAt(workbook, sheetIndex2);
|
|
47245
|
-
const { ref } =
|
|
47246
|
-
const first3 = parseInputCell(sheet,
|
|
47247
|
-
const second =
|
|
47248
|
-
if (!first3 ||
|
|
47664
|
+
const { ref } = table4;
|
|
47665
|
+
const first3 = parseInputCell(sheet, table4.r1);
|
|
47666
|
+
const second = table4.dt2D && table4.r2 ? parseInputCell(sheet, table4.r2) : void 0;
|
|
47667
|
+
if (!first3 || table4.dt2D && !second || table4.del1 || table4.del2) return [];
|
|
47249
47668
|
const inputs = [first3, ...second ? [second] : []];
|
|
47250
47669
|
const saved = inputs.map((p) => save(sheet, p.row, p.col));
|
|
47251
47670
|
const top = ref.start.row - 1;
|
|
@@ -47264,11 +47683,11 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47264
47683
|
for (let row3 = ref.start.row; row3 <= ref.end.row; row3++) {
|
|
47265
47684
|
for (let col = ref.start.col; col <= ref.end.col; col++) {
|
|
47266
47685
|
let formulaAt;
|
|
47267
|
-
if (
|
|
47686
|
+
if (table4.dt2D) {
|
|
47268
47687
|
set(first3, valueAt(sheet, top, col));
|
|
47269
47688
|
if (second) set(second, valueAt(sheet, row3, left2));
|
|
47270
47689
|
formulaAt = { row: top, col: left2 };
|
|
47271
|
-
} else if (
|
|
47690
|
+
} else if (table4.dtr) {
|
|
47272
47691
|
set(first3, valueAt(sheet, top, col));
|
|
47273
47692
|
formulaAt = { row: row3, col: left2 };
|
|
47274
47693
|
} else {
|
|
@@ -47293,8 +47712,8 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47293
47712
|
function refreshDataTables(workbook, calc) {
|
|
47294
47713
|
const changed = [];
|
|
47295
47714
|
workbook.sheets.forEach((sheet, index3) => {
|
|
47296
|
-
for (const
|
|
47297
|
-
changed.push(...computeDataTable(workbook, calc, index3,
|
|
47715
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
47716
|
+
changed.push(...computeDataTable(workbook, calc, index3, table4));
|
|
47298
47717
|
});
|
|
47299
47718
|
if (changed.length) calc.recalculateFrom(changed);
|
|
47300
47719
|
}
|
|
@@ -47317,23 +47736,23 @@ function resolve2(sheet, request) {
|
|
|
47317
47736
|
const ref = cellRange(range2.start.row + 1, range2.start.col + 1, range2.end.row, range2.end.col);
|
|
47318
47737
|
if ([row3, col].some((p) => p && rangeContains(ref, p))) return { problem: "input-inside" };
|
|
47319
47738
|
const name3 = (p) => formatAddress(p);
|
|
47320
|
-
const
|
|
47739
|
+
const table4 = { ref, r1: "" };
|
|
47321
47740
|
if (row3 && col) {
|
|
47322
|
-
|
|
47323
|
-
|
|
47324
|
-
|
|
47325
|
-
|
|
47741
|
+
table4.dt2D = true;
|
|
47742
|
+
table4.dtr = true;
|
|
47743
|
+
table4.r1 = name3(row3);
|
|
47744
|
+
table4.r2 = name3(col);
|
|
47326
47745
|
} else if (row3) {
|
|
47327
|
-
|
|
47328
|
-
|
|
47329
|
-
} else if (col)
|
|
47330
|
-
return { table:
|
|
47746
|
+
table4.dtr = true;
|
|
47747
|
+
table4.r1 = name3(row3);
|
|
47748
|
+
} else if (col) table4.r1 = name3(col);
|
|
47749
|
+
return { table: table4 };
|
|
47331
47750
|
}
|
|
47332
47751
|
function createDataTable(ctx, s, request) {
|
|
47333
47752
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47334
47753
|
const result2 = resolve2(sheet, request);
|
|
47335
47754
|
if ("problem" in result2) throw new Error(MESSAGES[result2.problem]);
|
|
47336
|
-
const { table:
|
|
47755
|
+
const { table: table4 } = result2;
|
|
47337
47756
|
const range2 = normalizeRange(request.range);
|
|
47338
47757
|
ctx.run(
|
|
47339
47758
|
"Data Table",
|
|
@@ -47344,16 +47763,16 @@ function createDataTable(ctx, s, request) {
|
|
|
47344
47763
|
],
|
|
47345
47764
|
() => {
|
|
47346
47765
|
sheet.dataTables = (sheet.dataTables ?? []).filter((t) => !rangesIntersect(t.ref, range2));
|
|
47347
|
-
sheet.dataTables.push(
|
|
47348
|
-
for (let row3 =
|
|
47349
|
-
for (let col =
|
|
47766
|
+
sheet.dataTables.push(table4);
|
|
47767
|
+
for (let row3 = table4.ref.start.row; row3 <= table4.ref.end.row; row3++)
|
|
47768
|
+
for (let col = table4.ref.start.col; col <= table4.ref.end.col; col++) {
|
|
47350
47769
|
const cell = ensureCell(sheet, row3, col);
|
|
47351
47770
|
delete cell.formula;
|
|
47352
47771
|
delete cell.arrayRange;
|
|
47353
47772
|
delete cell.legacyFormula;
|
|
47354
47773
|
delete cell.dynamicArray;
|
|
47355
47774
|
}
|
|
47356
|
-
computeDataTable(ctx.workbook, ctx.calc, s,
|
|
47775
|
+
computeDataTable(ctx.workbook, ctx.calc, s, table4);
|
|
47357
47776
|
},
|
|
47358
47777
|
{ sheet: s, ranges: [range2] }
|
|
47359
47778
|
);
|
|
@@ -48222,7 +48641,7 @@ function addScenario(ctx, s, draft) {
|
|
|
48222
48641
|
}
|
|
48223
48642
|
function editScenario(ctx, s, index3, draft) {
|
|
48224
48643
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48225
|
-
const existing = scenariosOf(sheet)[index3];
|
|
48644
|
+
const existing = Number.isInteger(index3) ? scenariosOf(sheet)[index3] : void 0;
|
|
48226
48645
|
if (!existing) throw new ScenarioError("missing");
|
|
48227
48646
|
if (existing.locked && sheet.protection) throw new ScenarioError("locked");
|
|
48228
48647
|
const name3 = checkName(sheet, draft.name, index3);
|
|
@@ -48233,7 +48652,7 @@ function editScenario(ctx, s, index3, draft) {
|
|
|
48233
48652
|
}
|
|
48234
48653
|
function deleteScenario(ctx, s, index3) {
|
|
48235
48654
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48236
|
-
const existing = scenariosOf(sheet)[index3];
|
|
48655
|
+
const existing = Number.isInteger(index3) ? scenariosOf(sheet)[index3] : void 0;
|
|
48237
48656
|
if (!existing) throw new ScenarioError("missing");
|
|
48238
48657
|
if (existing.locked && sheet.protection) throw new ScenarioError("locked");
|
|
48239
48658
|
ctx.run("Delete scenario", "view", PARTS2(s), () => {
|
|
@@ -48670,7 +49089,7 @@ function plan(ctx, s, pivot, old) {
|
|
|
48670
49089
|
if (![start.row, start.col].every(Number.isInteger) || start.row < 0 || start.col < 0 || location.end.row > MAX_ROW || location.end.col > MAX_COL)
|
|
48671
49090
|
throw new Error("The PivotTable result does not fit on the worksheet.");
|
|
48672
49091
|
const source2 = sparklineDataRange(ctx.workbook, s, pivot.source);
|
|
48673
|
-
if (source2.sheet === s && rangesIntersect(source2.range, location) || sheet.merges.some((range2) => rangesIntersect(range2, location)) || sheet.tables.some((
|
|
49092
|
+
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)))
|
|
48674
49093
|
throw new Error("The PivotTable would overlap source data, another table or merged cells.");
|
|
48675
49094
|
let occupied = false;
|
|
48676
49095
|
forEachCellInRange(sheet, location, (cell, row3, col) => {
|
|
@@ -48680,12 +49099,12 @@ function plan(ctx, s, pivot, old) {
|
|
|
48680
49099
|
if (occupied) throw new Error("The PivotTable would overwrite existing cell content.");
|
|
48681
49100
|
return { grid, location };
|
|
48682
49101
|
}
|
|
48683
|
-
function writePivot(ctx, s, pivot, old,
|
|
49102
|
+
function writePivot(ctx, s, pivot, old, label2, inside2) {
|
|
48684
49103
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48685
49104
|
const { grid, location } = plan(ctx, s, pivot, old);
|
|
48686
49105
|
const ranges = [...old ? [old.location] : [], location];
|
|
48687
49106
|
ctx.run(
|
|
48688
|
-
|
|
49107
|
+
label2 ?? (old ? "Refresh PivotTable" : "Create PivotTable"),
|
|
48689
49108
|
"annotations",
|
|
48690
49109
|
[
|
|
48691
49110
|
{ kind: "parts", sheet: s, parts: ["pivotTables"] },
|
|
@@ -48742,8 +49161,10 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
48742
49161
|
const name3 = options.name ?? uniqueName(ctx);
|
|
48743
49162
|
checkName2(ctx, name3);
|
|
48744
49163
|
const aggregate2 = options.aggregate ?? "sum";
|
|
49164
|
+
const captions = authoredCaptions(options);
|
|
48745
49165
|
const pivot = {
|
|
48746
49166
|
...data,
|
|
49167
|
+
...captions ? { captions } : {},
|
|
48747
49168
|
name: name3,
|
|
48748
49169
|
rowField: options.rowField,
|
|
48749
49170
|
layout: options.layout ?? "tabular",
|
|
@@ -48757,12 +49178,12 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
48757
49178
|
...options.repeatLabels !== void 0 ? { repeatLabels: options.repeatLabels } : {},
|
|
48758
49179
|
valueField: options.valueField,
|
|
48759
49180
|
aggregate: aggregate2,
|
|
48760
|
-
valueCaption: pivotCaption(aggregate2, options.valueField),
|
|
49181
|
+
valueCaption: pivotCaption(aggregate2, options.valueField, { captions }),
|
|
48761
49182
|
...options.pageFilter !== void 0 ? { pageFilter: structuredClone(options.pageFilter) } : {},
|
|
48762
49183
|
...options.fieldGroups?.length ? { fieldGroups: structuredClone(options.fieldGroups) } : {},
|
|
48763
49184
|
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
48764
49185
|
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
48765
|
-
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
49186
|
+
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues, { captions }) } : {},
|
|
48766
49187
|
location: { start: { ...destination }, end: { ...destination } },
|
|
48767
49188
|
...options.columnField ? { columnField: options.columnField } : {},
|
|
48768
49189
|
...options.columnField && options.moreColumnFields?.length ? { moreColumnFields: [...options.moreColumnFields] } : {}
|
|
@@ -48785,7 +49206,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
48785
49206
|
rowField: patch2.rowField ?? old.rowField,
|
|
48786
49207
|
valueField,
|
|
48787
49208
|
aggregate: aggregate2,
|
|
48788
|
-
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField)
|
|
49209
|
+
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField, old)
|
|
48789
49210
|
};
|
|
48790
49211
|
if (patch2.columnField !== void 0) {
|
|
48791
49212
|
if (patch2.columnField) next.columnField = patch2.columnField;
|
|
@@ -48835,7 +49256,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
48835
49256
|
else if (patch2.valuesAxis === "columns" || patch2.secondRowField === "")
|
|
48836
49257
|
delete next.valuesPosition;
|
|
48837
49258
|
if (patch2.additionalValues !== void 0) {
|
|
48838
|
-
const measures2 = normalizedPivotMeasures(patch2.additionalValues);
|
|
49259
|
+
const measures2 = normalizedPivotMeasures(patch2.additionalValues, old);
|
|
48839
49260
|
if (measures2.length) next.additionalValues = measures2;
|
|
48840
49261
|
else delete next.additionalValues;
|
|
48841
49262
|
}
|
|
@@ -49009,7 +49430,10 @@ function insertTimeline(ctx, s, ref) {
|
|
|
49009
49430
|
const id3 = Math.max(
|
|
49010
49431
|
1,
|
|
49011
49432
|
...sheet.drawings.flatMap(
|
|
49012
|
-
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(
|
|
49433
|
+
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(/<[\w:]*cNvPr\b[^>]*>/g)].flatMap((m) => {
|
|
49434
|
+
const id4 = /\sid="(\d+)"/.exec(m[0])?.[1];
|
|
49435
|
+
return id4 ? [Number(id4)] : [];
|
|
49436
|
+
}) : []
|
|
49013
49437
|
)
|
|
49014
49438
|
) + 1;
|
|
49015
49439
|
ctx.run(
|
|
@@ -49305,10 +49729,10 @@ function validatePatch(group, patch2) {
|
|
|
49305
49729
|
delete next.manualMax;
|
|
49306
49730
|
validateSettings(next);
|
|
49307
49731
|
}
|
|
49308
|
-
function save2(ctx, s, next,
|
|
49732
|
+
function save2(ctx, s, next, label2, ranges) {
|
|
49309
49733
|
const sheet = sheetAt(ctx.workbook, s);
|
|
49310
49734
|
ctx.run(
|
|
49311
|
-
|
|
49735
|
+
label2,
|
|
49312
49736
|
"annotations",
|
|
49313
49737
|
[{ kind: "parts", sheet: s, parts: ["preserved"] }],
|
|
49314
49738
|
() => sheet.preserved.set("extLst", next),
|
|
@@ -49426,20 +49850,20 @@ function setSlicerSelection(ctx, cacheName, keys) {
|
|
|
49426
49850
|
const target2 = slicerTarget(ctx.workbook, cache3);
|
|
49427
49851
|
if (!target2) throw new Error("The slicer has no data source.");
|
|
49428
49852
|
if (target2.kind === "table") {
|
|
49429
|
-
const { sheet, table:
|
|
49853
|
+
const { sheet, table: table4, offset: offset2 } = target2;
|
|
49430
49854
|
ctx.run(
|
|
49431
49855
|
keys === null ? "Clear slicer filter" : "Filter slicer",
|
|
49432
49856
|
"view",
|
|
49433
49857
|
[{ kind: "sheet", sheet: target2.sheetIndex }],
|
|
49434
49858
|
() => {
|
|
49435
|
-
const column2 =
|
|
49859
|
+
const column2 = table4.columns[offset2];
|
|
49436
49860
|
if (keys === null) delete column2.filter;
|
|
49437
49861
|
else
|
|
49438
49862
|
column2.filter = {
|
|
49439
49863
|
values: keys.filter((key2) => key2 !== ""),
|
|
49440
49864
|
...keys.includes("") ? { blank: true } : {}
|
|
49441
49865
|
};
|
|
49442
|
-
applyTableFilter(ctx.workbook, sheet,
|
|
49866
|
+
applyTableFilter(ctx.workbook, sheet, table4);
|
|
49443
49867
|
},
|
|
49444
49868
|
{ sheet: target2.sheetIndex, structural: true }
|
|
49445
49869
|
);
|
|
@@ -49510,17 +49934,17 @@ function unique2(base2, taken) {
|
|
|
49510
49934
|
function insertSlicer(ctx, s, ref) {
|
|
49511
49935
|
const { workbook } = ctx;
|
|
49512
49936
|
const sheet = sheetAt(workbook, s);
|
|
49513
|
-
let
|
|
49937
|
+
let table4;
|
|
49514
49938
|
let pivot;
|
|
49515
49939
|
let field2;
|
|
49516
49940
|
if (ref.kind === "table") {
|
|
49517
|
-
|
|
49941
|
+
table4 = sheet.tables.find(
|
|
49518
49942
|
(entry3) => entry3.name === ref.table || entry3.displayName === ref.table
|
|
49519
49943
|
);
|
|
49520
|
-
if (!
|
|
49944
|
+
if (!table4?.headerRow || table4.filterNotModeled)
|
|
49521
49945
|
throw new Error("Choose a table with a header row and value filters.");
|
|
49522
49946
|
field2 = ref.column;
|
|
49523
|
-
if (!
|
|
49947
|
+
if (!table4.columns.some((column2) => column2.name === field2))
|
|
49524
49948
|
throw new Error("Choose a column of the table.");
|
|
49525
49949
|
} else {
|
|
49526
49950
|
pivot = sheet.pivotTables?.find((entry3) => entry3.name === ref.pivot);
|
|
@@ -49540,14 +49964,17 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49540
49964
|
(c2) => names.has(c2.toLowerCase())
|
|
49541
49965
|
).replace(/ /g, "_");
|
|
49542
49966
|
const metrics = createGridMetrics(sheet, { zoom: 100 });
|
|
49543
|
-
const anchorCell =
|
|
49967
|
+
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 };
|
|
49544
49968
|
const x = Math.max(metrics.colLeft(anchorCell.col), frameBounds(sheet) + 10);
|
|
49545
49969
|
const box5 = { x, y: metrics.rowTop(anchorCell.row), ...SLICER_BOX };
|
|
49546
49970
|
const anchor = pixelBoxToAnchor(sheet, box5, metrics, "twoCell");
|
|
49547
49971
|
const id3 = Math.max(
|
|
49548
49972
|
1,
|
|
49549
49973
|
...sheet.drawings.flatMap(
|
|
49550
|
-
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(
|
|
49974
|
+
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(/<[\w:]*cNvPr\b[^>]*>/g)].flatMap((m) => {
|
|
49975
|
+
const id4 = /\sid="(\d+)"/.exec(m[0])?.[1];
|
|
49976
|
+
return id4 ? [Number(id4)] : [];
|
|
49977
|
+
}) : []
|
|
49551
49978
|
)
|
|
49552
49979
|
) + 1;
|
|
49553
49980
|
ctx.run(
|
|
@@ -49557,13 +49984,13 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49557
49984
|
() => {
|
|
49558
49985
|
const book = cloneBook(workbook);
|
|
49559
49986
|
let source2;
|
|
49560
|
-
if (
|
|
49561
|
-
if (
|
|
49562
|
-
|
|
49987
|
+
if (table4) {
|
|
49988
|
+
if (table4.columns.some((column2) => column2.sourceId === void 0))
|
|
49989
|
+
table4.columns.forEach((column2, index3) => column2.sourceId ??= index3 + 1);
|
|
49563
49990
|
source2 = {
|
|
49564
49991
|
kind: "table",
|
|
49565
|
-
tableId:
|
|
49566
|
-
column:
|
|
49992
|
+
tableId: table4.id,
|
|
49993
|
+
column: table4.columns.find((column2) => column2.name === field2).sourceId
|
|
49567
49994
|
};
|
|
49568
49995
|
} else {
|
|
49569
49996
|
const target2 = pivot;
|
|
@@ -50049,9 +50476,9 @@ var SUBTOTAL = {
|
|
|
50049
50476
|
var: 110
|
|
50050
50477
|
};
|
|
50051
50478
|
var escapeColumn = (name3) => name3.replace(/['#[\]]/g, "'$&");
|
|
50052
|
-
function applyTotalsRow(sheet,
|
|
50053
|
-
const row3 =
|
|
50054
|
-
const { columns } =
|
|
50479
|
+
function applyTotalsRow(sheet, table4) {
|
|
50480
|
+
const row3 = table4.range.end.row;
|
|
50481
|
+
const { columns } = table4;
|
|
50055
50482
|
if (!columns.some((c2) => c2.totalsRowFunction || c2.totalsRowLabel)) {
|
|
50056
50483
|
const first3 = columns[0];
|
|
50057
50484
|
const last = columns[columns.length - 1];
|
|
@@ -50059,12 +50486,12 @@ function applyTotalsRow(sheet, table3) {
|
|
|
50059
50486
|
if (last) last.totalsRowFunction = "sum";
|
|
50060
50487
|
}
|
|
50061
50488
|
columns.forEach((column2, i2) => {
|
|
50062
|
-
const col =
|
|
50489
|
+
const col = table4.range.start.col + i2;
|
|
50063
50490
|
const code = SUBTOTAL[column2.totalsRowFunction ?? ""];
|
|
50064
50491
|
if (code !== void 0) {
|
|
50065
50492
|
const cell = ensureCell(sheet, row3, col);
|
|
50066
50493
|
clearContents(cell);
|
|
50067
|
-
cell.formula = `SUBTOTAL(${code},${
|
|
50494
|
+
cell.formula = `SUBTOTAL(${code},${table4.name}[${escapeColumn(column2.name)}])`;
|
|
50068
50495
|
} else if (column2.totalsRowLabel && column2.totalsRowFunction !== "custom")
|
|
50069
50496
|
writeValue(sheet, row3, col, column2.totalsRowLabel);
|
|
50070
50497
|
});
|
|
@@ -50088,8 +50515,8 @@ function validateTableName(workbook, name3, self) {
|
|
|
50088
50515
|
) || workbook.definedNames.some((n) => n.name.toLowerCase() === lower3);
|
|
50089
50516
|
return taken ? "That name is already used by another table or name." : void 0;
|
|
50090
50517
|
}
|
|
50091
|
-
function renameTableIn(workbook,
|
|
50092
|
-
const old =
|
|
50518
|
+
function renameTableIn(workbook, table4, name3) {
|
|
50519
|
+
const old = table4.name;
|
|
50093
50520
|
if (old === name3) return;
|
|
50094
50521
|
const rename = (f6) => renameTableInFormula(f6, old, name3);
|
|
50095
50522
|
rewriteFormulas(workbook, rename);
|
|
@@ -50098,73 +50525,73 @@ function renameTableIn(workbook, table3, name3) {
|
|
|
50098
50525
|
for (const column2 of t.columns)
|
|
50099
50526
|
if (column2.calculatedColumnFormula)
|
|
50100
50527
|
column2.calculatedColumnFormula = rename(column2.calculatedColumnFormula);
|
|
50101
|
-
|
|
50102
|
-
|
|
50528
|
+
table4.name = name3;
|
|
50529
|
+
table4.displayName = name3;
|
|
50103
50530
|
}
|
|
50104
50531
|
var byId = (sheet, id3) => {
|
|
50105
|
-
const
|
|
50106
|
-
if (!
|
|
50107
|
-
return
|
|
50532
|
+
const table4 = sheet.tables.find((t) => t.id === id3);
|
|
50533
|
+
if (!table4) throw new Error("The table disappeared during the edit.");
|
|
50534
|
+
return table4;
|
|
50108
50535
|
};
|
|
50109
|
-
function insertBandRow(workbook, sheet,
|
|
50536
|
+
function insertBandRow(workbook, sheet, table4, row3) {
|
|
50110
50537
|
const shift2 = { axis: "row", at: row3, count: 1 };
|
|
50111
|
-
const band2 = { lo:
|
|
50538
|
+
const band2 = { lo: table4.range.start.col, hi: table4.range.end.col };
|
|
50112
50539
|
assertInsertFits(sheet, shift2, band2);
|
|
50113
50540
|
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band2));
|
|
50114
50541
|
shiftSheetContent(sheet, shift2, band2);
|
|
50115
50542
|
}
|
|
50116
50543
|
function setHeaderRow(workbook, sheet, id3, on) {
|
|
50117
|
-
let
|
|
50118
|
-
if (
|
|
50119
|
-
const { start, end } =
|
|
50544
|
+
let table4 = byId(sheet, id3);
|
|
50545
|
+
if (table4.headerRow === on) return;
|
|
50546
|
+
const { start, end } = table4.range;
|
|
50120
50547
|
if (!on) {
|
|
50121
50548
|
if (start.row === end.row) throw new Error("A table needs at least one row.");
|
|
50122
50549
|
clearRow(sheet, start.row, start.col, end.col);
|
|
50123
|
-
|
|
50124
|
-
|
|
50550
|
+
table4.range = { start: { row: start.row + 1, col: start.col }, end };
|
|
50551
|
+
table4.headerRow = false;
|
|
50125
50552
|
return;
|
|
50126
50553
|
}
|
|
50127
50554
|
if (start.row === 0 || !rowIsEmpty(sheet, start.row - 1, start.col, end.col)) {
|
|
50128
|
-
insertBandRow(workbook, sheet,
|
|
50129
|
-
|
|
50130
|
-
}
|
|
50131
|
-
const top =
|
|
50132
|
-
const left2 =
|
|
50133
|
-
|
|
50134
|
-
|
|
50135
|
-
uniqueHeaders(
|
|
50136
|
-
const column2 =
|
|
50555
|
+
insertBandRow(workbook, sheet, table4, start.row);
|
|
50556
|
+
table4 = byId(sheet, id3);
|
|
50557
|
+
}
|
|
50558
|
+
const top = table4.range.start.row - 1;
|
|
50559
|
+
const left2 = table4.range.start.col;
|
|
50560
|
+
table4.range = { start: { row: top, col: left2 }, end: table4.range.end };
|
|
50561
|
+
table4.headerRow = true;
|
|
50562
|
+
uniqueHeaders(table4.columns.map((c2) => c2.name)).forEach((name3, i2) => {
|
|
50563
|
+
const column2 = table4.columns[i2];
|
|
50137
50564
|
if (column2) column2.name = name3;
|
|
50138
50565
|
writeValue(sheet, top, left2 + i2, name3);
|
|
50139
50566
|
});
|
|
50140
50567
|
}
|
|
50141
50568
|
function setTotalsRow(workbook, sheet, id3, on) {
|
|
50142
|
-
let
|
|
50143
|
-
if (
|
|
50144
|
-
const { start, end } =
|
|
50569
|
+
let table4 = byId(sheet, id3);
|
|
50570
|
+
if (table4.totalsRow === on) return;
|
|
50571
|
+
const { start, end } = table4.range;
|
|
50145
50572
|
if (!on) {
|
|
50146
50573
|
clearRow(sheet, end.row, start.col, end.col);
|
|
50147
|
-
|
|
50148
|
-
|
|
50574
|
+
table4.range = { start, end: { row: end.row - 1, col: end.col } };
|
|
50575
|
+
table4.totalsRow = false;
|
|
50149
50576
|
return;
|
|
50150
50577
|
}
|
|
50151
50578
|
if (end.row === MAX_ROW) throw new RangeError("The insert area extends beyond the sheet.");
|
|
50152
50579
|
if (!rowIsEmpty(sheet, end.row + 1, start.col, end.col)) {
|
|
50153
|
-
insertBandRow(workbook, sheet,
|
|
50154
|
-
|
|
50580
|
+
insertBandRow(workbook, sheet, table4, end.row + 1);
|
|
50581
|
+
table4 = byId(sheet, id3);
|
|
50155
50582
|
}
|
|
50156
|
-
|
|
50157
|
-
|
|
50158
|
-
applyTotalsRow(sheet,
|
|
50583
|
+
table4.range = { start: table4.range.start, end: { row: table4.range.end.row + 1, col: end.col } };
|
|
50584
|
+
table4.totalsRow = true;
|
|
50585
|
+
applyTotalsRow(sheet, table4);
|
|
50159
50586
|
}
|
|
50160
|
-
function resizedColumns(workbook, sheet,
|
|
50587
|
+
function resizedColumns(workbook, sheet, table4, range2) {
|
|
50161
50588
|
const width = range2.end.col - range2.start.col + 1;
|
|
50162
|
-
const oldAt = (col) => col >=
|
|
50589
|
+
const oldAt = (col) => col >= table4.range.start.col && col <= table4.range.end.col ? table4.columns[col - table4.range.start.col] : void 0;
|
|
50163
50590
|
const texts = Array.from({ length: width }, (_v, i2) => {
|
|
50164
50591
|
const col = range2.start.col + i2;
|
|
50165
50592
|
const old = oldAt(col);
|
|
50166
50593
|
if (old) return old.name;
|
|
50167
|
-
return
|
|
50594
|
+
return table4.headerRow ? displayText(workbook, getCell(sheet, range2.start.row, col)) : "";
|
|
50168
50595
|
});
|
|
50169
50596
|
return uniqueHeaders(texts).map((name3, i2) => {
|
|
50170
50597
|
const old = oldAt(range2.start.col + i2);
|
|
@@ -50172,30 +50599,30 @@ function resizedColumns(workbook, sheet, table3, range2) {
|
|
|
50172
50599
|
});
|
|
50173
50600
|
}
|
|
50174
50601
|
function resizeTableIn(workbook, sheet, id3, range2) {
|
|
50175
|
-
const
|
|
50602
|
+
const table4 = byId(sheet, id3);
|
|
50176
50603
|
const r = normalizeRange(range2);
|
|
50177
|
-
if (
|
|
50604
|
+
if (table4.headerRow && r.start.row !== table4.range.start.row)
|
|
50178
50605
|
throw new Error("The table headers must remain in the same row.");
|
|
50179
|
-
if (!rangesIntersect(r,
|
|
50180
|
-
if (r.end.row - r.start.row + 1 < (
|
|
50606
|
+
if (!rangesIntersect(r, table4.range)) throw new Error("The new range must overlap the table.");
|
|
50607
|
+
if (r.end.row - r.start.row + 1 < (table4.headerRow ? 2 : 1) + (table4.totalsRow ? 1 : 0))
|
|
50181
50608
|
throw new Error("The table range is too small.");
|
|
50182
|
-
if (sheet.tables.some((t) => t !==
|
|
50609
|
+
if (sheet.tables.some((t) => t !== table4 && rangesIntersect(t.range, r)))
|
|
50183
50610
|
throw new Error("A table cannot overlap another table.");
|
|
50184
50611
|
if (sheet.pivotTables?.some((pivot) => rangesIntersect(pivot.location, r)))
|
|
50185
50612
|
throw new Error("A table cannot overlap a PivotTable.");
|
|
50186
50613
|
if (sheet.merges.some((m) => rangesIntersect(m, r)))
|
|
50187
50614
|
throw new Error("A table cannot contain merged cells.");
|
|
50188
|
-
const oldEnd =
|
|
50189
|
-
|
|
50190
|
-
|
|
50191
|
-
if (
|
|
50192
|
-
|
|
50615
|
+
const oldEnd = table4.range.end.row;
|
|
50616
|
+
table4.columns = resizedColumns(workbook, sheet, table4, r);
|
|
50617
|
+
table4.range = r;
|
|
50618
|
+
if (table4.headerRow)
|
|
50619
|
+
table4.columns.forEach((column2, i2) => {
|
|
50193
50620
|
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
50194
50621
|
if (cell?.value !== column2.name) writeValue(sheet, r.start.row, r.start.col + i2, column2.name);
|
|
50195
50622
|
});
|
|
50196
|
-
if (
|
|
50623
|
+
if (table4.totalsRow) {
|
|
50197
50624
|
if (oldEnd !== r.end.row) clearRow(sheet, oldEnd, r.start.col, r.end.col);
|
|
50198
|
-
applyTotalsRow(sheet,
|
|
50625
|
+
applyTotalsRow(sheet, table4);
|
|
50199
50626
|
}
|
|
50200
50627
|
}
|
|
50201
50628
|
var STYLE_KEYS = [
|
|
@@ -50223,20 +50650,20 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50223
50650
|
"structure",
|
|
50224
50651
|
[scope],
|
|
50225
50652
|
() => {
|
|
50226
|
-
const
|
|
50227
|
-
if (renaming) renameTableIn(workbook,
|
|
50653
|
+
const table4 = byId(sheet, id3);
|
|
50654
|
+
if (renaming) renameTableIn(workbook, table4, name3);
|
|
50228
50655
|
for (const key2 of STYLE_KEYS) {
|
|
50229
50656
|
if (!(key2 in patch2)) continue;
|
|
50230
50657
|
const value2 = patch2[key2];
|
|
50231
|
-
if (value2 === void 0) delete
|
|
50232
|
-
else
|
|
50658
|
+
if (value2 === void 0) delete table4[key2];
|
|
50659
|
+
else table4[key2] = value2;
|
|
50233
50660
|
}
|
|
50234
50661
|
if (patch2.columns) {
|
|
50235
|
-
const width =
|
|
50662
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
50236
50663
|
if (patch2.columns.length !== width) throw new Error("Give one column per table column.");
|
|
50237
|
-
const before =
|
|
50238
|
-
|
|
50239
|
-
for (const [index3, column2] of
|
|
50664
|
+
const before = table4.columns;
|
|
50665
|
+
table4.columns = structuredClone(patch2.columns);
|
|
50666
|
+
for (const [index3, column2] of table4.columns.entries()) {
|
|
50240
50667
|
const sourceId = before[index3]?.sourceId;
|
|
50241
50668
|
if (column2.sourceId === void 0 && sourceId !== void 0) column2.sourceId = sourceId;
|
|
50242
50669
|
const filter2 = before[index3]?.filter;
|
|
@@ -50245,7 +50672,7 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50245
50672
|
}
|
|
50246
50673
|
if (patch2.headerRow !== void 0) setHeaderRow(workbook, sheet, id3, patch2.headerRow);
|
|
50247
50674
|
if (patch2.totalsRow !== void 0) setTotalsRow(workbook, sheet, id3, patch2.totalsRow);
|
|
50248
|
-
else if (patch2.columns &&
|
|
50675
|
+
else if (patch2.columns && table4.totalsRow) applyTotalsRow(sheet, byId(sheet, id3));
|
|
50249
50676
|
if (patch2.range) resizeTableIn(workbook, sheet, id3, patch2.range);
|
|
50250
50677
|
},
|
|
50251
50678
|
{ sheet: s, ranges: [current.range], structural: true }
|
|
@@ -50265,13 +50692,13 @@ function resizeTable(ctx, s, ref, range2) {
|
|
|
50265
50692
|
function convertTableToRange(ctx, s, ref) {
|
|
50266
50693
|
const { workbook } = ctx;
|
|
50267
50694
|
const sheet = sheetAt(workbook, s);
|
|
50268
|
-
const
|
|
50695
|
+
const table4 = sheet.tables[tableIndex(sheet, ref)];
|
|
50269
50696
|
ctx.run(
|
|
50270
50697
|
"Convert to range",
|
|
50271
50698
|
"structure",
|
|
50272
50699
|
[{ kind: "workbook" }],
|
|
50273
50700
|
() => {
|
|
50274
|
-
const live2 = byId(sheet,
|
|
50701
|
+
const live2 = byId(sheet, table4.id);
|
|
50275
50702
|
const base2 = { table: live2, tableSheet: sheet.name };
|
|
50276
50703
|
const { start, end } = live2.range;
|
|
50277
50704
|
for (const ws of workbook.sheets)
|
|
@@ -50296,7 +50723,7 @@ function convertTableToRange(ctx, s, ref) {
|
|
|
50296
50723
|
});
|
|
50297
50724
|
sheet.tables = sheet.tables.filter((t) => t.id !== live2.id);
|
|
50298
50725
|
},
|
|
50299
|
-
{ sheet: s, ranges: [
|
|
50726
|
+
{ sheet: s, ranges: [table4.range], structural: true }
|
|
50300
50727
|
);
|
|
50301
50728
|
}
|
|
50302
50729
|
|
|
@@ -53202,7 +53629,7 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53202
53629
|
});
|
|
53203
53630
|
const name3 = nextTableName(workbook);
|
|
53204
53631
|
const id3 = Math.max(0, ...workbook.sheets.flatMap((ws) => ws.tables.map((t) => t.id))) + 1;
|
|
53205
|
-
const
|
|
53632
|
+
const table4 = {
|
|
53206
53633
|
id: id3,
|
|
53207
53634
|
name: name3,
|
|
53208
53635
|
displayName: name3,
|
|
@@ -53216,8 +53643,8 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53216
53643
|
showFirstColumn: false,
|
|
53217
53644
|
showLastColumn: false
|
|
53218
53645
|
};
|
|
53219
|
-
sheet.tables.push(
|
|
53220
|
-
return
|
|
53646
|
+
sheet.tables.push(table4);
|
|
53647
|
+
return table4;
|
|
53221
53648
|
},
|
|
53222
53649
|
{ sheet: s, ranges: [r], structural: !hasHeader }
|
|
53223
53650
|
);
|
|
@@ -53421,8 +53848,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
53421
53848
|
if (!workbook.warnings.includes(message)) workbook.warnings.push(message);
|
|
53422
53849
|
}
|
|
53423
53850
|
};
|
|
53424
|
-
const begin = (
|
|
53425
|
-
const step2 = { label:
|
|
53851
|
+
const begin = (label2, kind, info) => {
|
|
53852
|
+
const step2 = { label: label2, entries: [], structural: info.structural ?? false };
|
|
53426
53853
|
if (info.calc) step2.calc = info.calc;
|
|
53427
53854
|
return { step: step2, kind, sheet: info.sheet, ranges: [...info.ranges ?? []] };
|
|
53428
53855
|
};
|
|
@@ -53446,7 +53873,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53446
53873
|
}
|
|
53447
53874
|
current.step.entries.length = from;
|
|
53448
53875
|
};
|
|
53449
|
-
const run2 = (
|
|
53876
|
+
const run2 = (label2, kind, scopes, fn, info = {}) => {
|
|
53450
53877
|
if (kind === "cells") {
|
|
53451
53878
|
for (const scope of scopes)
|
|
53452
53879
|
if (scope.kind === "cells" && workbook.sheets[scope.sheet]?.pivotTables?.some(
|
|
@@ -53463,7 +53890,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53463
53890
|
}))
|
|
53464
53891
|
throw new Error(DATA_TABLE_PART_ERROR);
|
|
53465
53892
|
const outer = !open;
|
|
53466
|
-
const current = open ?? begin(
|
|
53893
|
+
const current = open ?? begin(label2, kind, info);
|
|
53467
53894
|
if (!outer) {
|
|
53468
53895
|
delete current.step.calc;
|
|
53469
53896
|
if (info.structural) current.step.structural = true;
|
|
@@ -53594,9 +54021,9 @@ function createEditSession(workbook, options = {}) {
|
|
|
53594
54021
|
removeConditionalFormat: (s, index3) => removeConditionalFormat(ctx, s, index3),
|
|
53595
54022
|
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
53596
54023
|
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
53597
|
-
updateTable: (s,
|
|
53598
|
-
resizeTable: (s,
|
|
53599
|
-
convertTableToRange: (s,
|
|
54024
|
+
updateTable: (s, table4, patch2) => updateTable(ctx, s, table4, patch2),
|
|
54025
|
+
resizeTable: (s, table4, range2) => resizeTable(ctx, s, table4, range2),
|
|
54026
|
+
convertTableToRange: (s, table4) => convertTableToRange(ctx, s, table4),
|
|
53600
54027
|
applyCellStyle: (s, ranges, name3) => applyCellStyle(ctx, s, ranges, name3),
|
|
53601
54028
|
setPageSetup: (s, patch2) => setPageSetup(ctx, s, patch2),
|
|
53602
54029
|
setPageBreak: (s, axis, before, present) => setPageBreak(ctx, s, axis, before, present),
|
|
@@ -53633,12 +54060,12 @@ function createEditSession(workbook, options = {}) {
|
|
|
53633
54060
|
validate: (s, r, c2, value2) => validateCellInput(workbook, s, r, c2, value2, {
|
|
53634
54061
|
evaluate: (formula, at2) => calc.evaluate(formula, at2)
|
|
53635
54062
|
}),
|
|
53636
|
-
batch(
|
|
54063
|
+
batch(label2, fn) {
|
|
53637
54064
|
if (open) {
|
|
53638
54065
|
fn();
|
|
53639
54066
|
return;
|
|
53640
54067
|
}
|
|
53641
|
-
const current = begin(
|
|
54068
|
+
const current = begin(label2, "batch", {});
|
|
53642
54069
|
open = current;
|
|
53643
54070
|
try {
|
|
53644
54071
|
fn();
|
|
@@ -54318,9 +54745,9 @@ var VisioPackage = class _VisioPackage {
|
|
|
54318
54745
|
};
|
|
54319
54746
|
|
|
54320
54747
|
// visio/metadata.ts
|
|
54321
|
-
function metadata(value2, max,
|
|
54748
|
+
function metadata(value2, max, label2) {
|
|
54322
54749
|
if (value2.length > max)
|
|
54323
|
-
throw new VisioPackageError("METADATA_LIMIT", `${
|
|
54750
|
+
throw new VisioPackageError("METADATA_LIMIT", `${label2} exceeds its metadata length limit.`);
|
|
54324
54751
|
return value2;
|
|
54325
54752
|
}
|
|
54326
54753
|
function metadataAttributes(node3) {
|
|
@@ -58272,15 +58699,15 @@ function legacyFillGradient(cells3, width, height, resolve3) {
|
|
|
58272
58699
|
|
|
58273
58700
|
// ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/utils/png-encoder.js
|
|
58274
58701
|
var CRC_TABLE = (() => {
|
|
58275
|
-
const
|
|
58702
|
+
const table4 = new Uint32Array(256);
|
|
58276
58703
|
for (let n = 0; n < 256; n++) {
|
|
58277
58704
|
let c2 = n;
|
|
58278
58705
|
for (let k = 0; k < 8; k++) {
|
|
58279
58706
|
c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
|
|
58280
58707
|
}
|
|
58281
|
-
|
|
58708
|
+
table4[n] = c2 >>> 0;
|
|
58282
58709
|
}
|
|
58283
|
-
return
|
|
58710
|
+
return table4;
|
|
58284
58711
|
})();
|
|
58285
58712
|
function crc322(bytes) {
|
|
58286
58713
|
let crc = 4294967295;
|
|
@@ -60954,7 +61381,7 @@ function property(row3, budget, report) {
|
|
|
60954
61381
|
"Shape data has no supported current cached typed value; original cached text is retained."
|
|
60955
61382
|
);
|
|
60956
61383
|
}
|
|
60957
|
-
const
|
|
61384
|
+
const label2 = get("Label"), format5 = get("Format"), prompt = get("Prompt"), sortKey = get("SortKey");
|
|
60958
61385
|
const invisible = boolean(row3.cells, "Invisible", budget, report);
|
|
60959
61386
|
const dataLinked = row3.cells.has("DataLinked") ? boolean(row3.cells, "DataLinked", budget, report) : void 0;
|
|
60960
61387
|
const unit3 = row3.cells.get("Value")?.unit, error = row3.cells.get("Value")?.error;
|
|
@@ -60966,7 +61393,7 @@ function property(row3, budget, report) {
|
|
|
60966
61393
|
...rawType === void 0 ? {} : { rawType },
|
|
60967
61394
|
...rawValue === void 0 ? {} : { rawValue },
|
|
60968
61395
|
...value2 === void 0 ? {} : { value: value2 },
|
|
60969
|
-
...
|
|
61396
|
+
...label2 === void 0 ? {} : { label: label2 },
|
|
60970
61397
|
...format5 === void 0 ? {} : { format: format5 },
|
|
60971
61398
|
...prompt === void 0 ? {} : { prompt },
|
|
60972
61399
|
...sortKey === void 0 ? {} : { sortKey },
|
|
@@ -61199,9 +61626,9 @@ async function readDataRecordsets(pkg, documentPart, check3) {
|
|
|
61199
61626
|
const declared = children3(children3(set, "DataColumns")[0], "DataColumn");
|
|
61200
61627
|
const columns = (declared.length ? declared : []).map((node3) => {
|
|
61201
61628
|
const name4 = attribute3(node3, "ColumnNameID") ?? attribute3(node3, "Name") ?? "";
|
|
61202
|
-
const
|
|
61203
|
-
if (!name4 || name4.length > 255 ||
|
|
61204
|
-
return { name: name4, label:
|
|
61629
|
+
const label2 = attribute3(node3, "Label") ?? attribute3(node3, "Name") ?? name4;
|
|
61630
|
+
if (!name4 || name4.length > 255 || label2.length > 255) invalid2("Invalid data column.");
|
|
61631
|
+
return { name: name4, label: label2, type: typeFromCode(attribute3(node3, "DataType")) };
|
|
61205
61632
|
});
|
|
61206
61633
|
if (!columns.length)
|
|
61207
61634
|
for (const column2 of ado.columns)
|
|
@@ -67864,18 +68291,18 @@ function advances(family, bold) {
|
|
|
67864
68291
|
const key2 = `${name3}|${bold ? "b" : "r"}`;
|
|
67865
68292
|
const known = decoded.get(key2);
|
|
67866
68293
|
if (known) return known;
|
|
67867
|
-
const
|
|
67868
|
-
if (!
|
|
67869
|
-
const values2 = (bold ?
|
|
68294
|
+
const table4 = Object.hasOwn(DESIGN_ADVANCES, name3) ? DESIGN_ADVANCES[name3] : void 0;
|
|
68295
|
+
if (!table4) return void 0;
|
|
68296
|
+
const values2 = (bold ? table4.bold : table4.regular).split(" ").map(Number);
|
|
67870
68297
|
decoded.set(key2, values2);
|
|
67871
68298
|
return values2;
|
|
67872
68299
|
}
|
|
67873
68300
|
function designTextWidthEm(text8, family, bold = false) {
|
|
67874
|
-
const
|
|
67875
|
-
if (!
|
|
68301
|
+
const table4 = advances(family, bold);
|
|
68302
|
+
if (!table4) return void 0;
|
|
67876
68303
|
let units2 = 0;
|
|
67877
68304
|
for (let index3 = 0; index3 < text8.length; ++index3) {
|
|
67878
|
-
const advance =
|
|
68305
|
+
const advance = table4[text8.charCodeAt(index3) - FIRST];
|
|
67879
68306
|
if (advance === void 0 || Number.isNaN(advance)) return void 0;
|
|
67880
68307
|
units2 += advance;
|
|
67881
68308
|
}
|
|
@@ -71086,9 +71513,9 @@ function visioBorderShapes(style3, width, height, title = VISIO_DEFAULT_TITLE) {
|
|
|
71086
71513
|
// visio/edit-page-setup-commands.ts
|
|
71087
71514
|
var VISIO_SCALE_UNITS = Object.freeze(["IN", "FT", "MM", "CM", "M"]);
|
|
71088
71515
|
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";
|
|
71089
|
-
var pageId = (value2,
|
|
71516
|
+
var pageId = (value2, label2) => {
|
|
71090
71517
|
if (typeof value2 !== "string" || !value2 || value2.length > 256)
|
|
71091
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71518
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71092
71519
|
return value2;
|
|
71093
71520
|
};
|
|
71094
71521
|
var newPageId = (value2) => {
|
|
@@ -71195,11 +71622,11 @@ var VISIO_SHAPE_DATA_TYPES = [
|
|
|
71195
71622
|
"date"
|
|
71196
71623
|
];
|
|
71197
71624
|
var invalidText2 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71198
|
-
function shapeDataText(value2,
|
|
71625
|
+
function shapeDataText(value2, label2) {
|
|
71199
71626
|
if (typeof value2 !== "string" || value2.length > VISIO_METADATA_TEXT_LIMIT)
|
|
71200
|
-
fail2("INVALID_EDIT", `${
|
|
71627
|
+
fail2("INVALID_EDIT", `${label2} must be a string within the length limit.`);
|
|
71201
71628
|
if (invalidText2.test(value2) || /[\r\n\t]/.test(value2))
|
|
71202
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71629
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid characters.`);
|
|
71203
71630
|
return value2;
|
|
71204
71631
|
}
|
|
71205
71632
|
function shapeDataRowName(value2) {
|
|
@@ -71207,9 +71634,9 @@ function shapeDataRowName(value2) {
|
|
|
71207
71634
|
fail2("INVALID_EDIT", "Shape Data row names use letters, digits and underscores.");
|
|
71208
71635
|
return value2;
|
|
71209
71636
|
}
|
|
71210
|
-
function visioShapeDataRowName(
|
|
71637
|
+
function visioShapeDataRowName(label2, taken = []) {
|
|
71211
71638
|
const used = new Set([...taken].map((name4) => name4.toLowerCase()));
|
|
71212
|
-
let base2 =
|
|
71639
|
+
let base2 = label2.normalize("NFKD").replace(/[^\w]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 48);
|
|
71213
71640
|
if (!base2) base2 = "Property";
|
|
71214
71641
|
if (/^\d/.test(base2)) base2 = `_${base2}`;
|
|
71215
71642
|
let name3 = base2;
|
|
@@ -71281,18 +71708,18 @@ var TYPES3 = [
|
|
|
71281
71708
|
"unlink-data-rows"
|
|
71282
71709
|
];
|
|
71283
71710
|
var isVisioDataEdit = (edit) => TYPES3.includes(edit.type);
|
|
71284
|
-
var id = (value2,
|
|
71711
|
+
var id = (value2, label2) => {
|
|
71285
71712
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71286
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71713
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71287
71714
|
return value2;
|
|
71288
71715
|
};
|
|
71289
|
-
var name = (value2,
|
|
71290
|
-
const text8 = shapeDataText(value2,
|
|
71716
|
+
var name = (value2, label2) => {
|
|
71717
|
+
const text8 = shapeDataText(value2, label2);
|
|
71291
71718
|
if (!text8.trim() || text8.length > 255)
|
|
71292
|
-
fail2("INVALID_EDIT", `${
|
|
71719
|
+
fail2("INVALID_EDIT", `${label2} must be 1 to 255 characters.`);
|
|
71293
71720
|
return text8;
|
|
71294
71721
|
};
|
|
71295
|
-
function
|
|
71722
|
+
function table3(columns, rows) {
|
|
71296
71723
|
if (!Array.isArray(columns) || !columns.length || columns.length > VISIO_DATA_LIMITS.maxColumns)
|
|
71297
71724
|
fail2("INVALID_EDIT", `A recordset needs 1 to ${VISIO_DATA_LIMITS.maxColumns} columns.`);
|
|
71298
71725
|
if (!Array.isArray(rows) || rows.length > VISIO_DATA_LIMITS.maxRows)
|
|
@@ -71338,14 +71765,14 @@ function snapshotDataEdit(edit) {
|
|
|
71338
71765
|
type: edit.type,
|
|
71339
71766
|
pageId: pageId2,
|
|
71340
71767
|
name: name(edit.name, "The recordset name"),
|
|
71341
|
-
...
|
|
71768
|
+
...table3(edit.columns, edit.rows)
|
|
71342
71769
|
};
|
|
71343
71770
|
case "refresh-data-recordset":
|
|
71344
71771
|
return {
|
|
71345
71772
|
type: edit.type,
|
|
71346
71773
|
pageId: pageId2,
|
|
71347
71774
|
recordsetId: id(edit.recordsetId, "recordset"),
|
|
71348
|
-
...
|
|
71775
|
+
...table3(edit.columns, edit.rows)
|
|
71349
71776
|
};
|
|
71350
71777
|
case "delete-data-recordset":
|
|
71351
71778
|
return { type: edit.type, pageId: pageId2, recordsetId: id(edit.recordsetId, "recordset") };
|
|
@@ -71404,16 +71831,16 @@ function snapshotPageTheme(edit) {
|
|
|
71404
71831
|
var isVisioCommentEdit = (edit) => edit.type === "add-comment" || edit.type === "edit-comment" || edit.type === "delete-comment";
|
|
71405
71832
|
var invalidText3 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71406
71833
|
var dateTime = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?(?:Z|[+-]\d{2}:\d{2})?$/;
|
|
71407
|
-
function string(value2, limit3,
|
|
71834
|
+
function string(value2, limit3, label2, required = true) {
|
|
71408
71835
|
if (typeof value2 !== "string" || value2.length > limit3 || required && !value2.trim())
|
|
71409
|
-
fail2("INVALID_EDIT", `${
|
|
71836
|
+
fail2("INVALID_EDIT", `${label2} must be a non-empty string within its length limit.`);
|
|
71410
71837
|
if (invalidText3.test(value2))
|
|
71411
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71838
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid XML characters.`);
|
|
71412
71839
|
return value2;
|
|
71413
71840
|
}
|
|
71414
|
-
var id2 = (value2,
|
|
71841
|
+
var id2 = (value2, label2) => {
|
|
71415
71842
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71416
|
-
fail2("INVALID_EDIT", `${
|
|
71843
|
+
fail2("INVALID_EDIT", `${label2} must be a canonical unsigned integer.`);
|
|
71417
71844
|
return value2;
|
|
71418
71845
|
};
|
|
71419
71846
|
var date = (value2) => {
|
|
@@ -71936,7 +72363,7 @@ async function editVsdxMasterInstance(pkg, parts, pages, edit, limits, maxOutput
|
|
|
71936
72363
|
|
|
71937
72364
|
// visio/paper-sizes.ts
|
|
71938
72365
|
var mm = (value2) => value2 / 25.4;
|
|
71939
|
-
var size = (id3,
|
|
72366
|
+
var size = (id3, label2, width, height, paperKind) => Object.freeze({ id: id3, label: label2, width, height, ...paperKind === void 0 ? {} : { paperKind } });
|
|
71940
72367
|
var VISIO_PAPER_SIZES = Object.freeze([
|
|
71941
72368
|
size("letter", "Letter", 8.5, 11, 1),
|
|
71942
72369
|
size("tabloid", "Tabloid", 11, 17, 3),
|
|
@@ -73306,7 +73733,7 @@ function snapshotFormatting(edit) {
|
|
|
73306
73733
|
if (!Number.isInteger(value2)) fail2("INVALID_EDIT", "Paint patterns require integers.");
|
|
73307
73734
|
result2[name3] = value2;
|
|
73308
73735
|
}
|
|
73309
|
-
for (const [name3, maximum,
|
|
73736
|
+
for (const [name3, maximum, label2] of [
|
|
73310
73737
|
["beginArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73311
73738
|
["endArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73312
73739
|
["beginArrowSize", 6, "Arrowhead sizes are numbered 0 to 6."],
|
|
@@ -73320,7 +73747,7 @@ function snapshotFormatting(edit) {
|
|
|
73320
73747
|
const value2 = edit[name3];
|
|
73321
73748
|
if (value2 === void 0) continue;
|
|
73322
73749
|
if (typeof value2 !== "number" || !Number.isInteger(value2) || value2 < 0 || value2 > maximum)
|
|
73323
|
-
fail2("INVALID_EDIT",
|
|
73750
|
+
fail2("INVALID_EDIT", label2);
|
|
73324
73751
|
result2[name3] = value2;
|
|
73325
73752
|
}
|
|
73326
73753
|
if (edit.rounding !== void 0) result2.rounding = points(edit.rounding, 0, 720);
|