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
|
@@ -74,30 +74,49 @@ var DEFAULT_XML_LIMITS = {
|
|
|
74
74
|
maxDepth: 512,
|
|
75
75
|
maxNodes: 5e6
|
|
76
76
|
};
|
|
77
|
-
var
|
|
78
|
-
|
|
77
|
+
var TAG_RE = /<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/y;
|
|
78
|
+
var MARKUP_SKIPS = [
|
|
79
|
+
["<!--", "-->"],
|
|
80
|
+
["<![CDATA[", "]]>"],
|
|
81
|
+
["<?", "?>"]
|
|
82
|
+
];
|
|
83
|
+
function checkXmlLimits(xml, label2, limits = {}) {
|
|
79
84
|
const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
80
85
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
81
86
|
let depth = 0;
|
|
82
87
|
let nodes = 0;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
let at2 = xml.indexOf("<");
|
|
89
|
+
while (at2 !== -1) {
|
|
90
|
+
const skip = MARKUP_SKIPS.find(([open]) => xml.startsWith(open, at2));
|
|
91
|
+
if (skip) {
|
|
92
|
+
const end = xml.indexOf(skip[1], at2 + skip[0].length);
|
|
93
|
+
if (end === -1) return;
|
|
94
|
+
at2 = xml.indexOf("<", end + skip[1].length);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
TAG_RE.lastIndex = at2;
|
|
98
|
+
const match2 = TAG_RE.exec(xml);
|
|
99
|
+
if (!match2) {
|
|
100
|
+
at2 = xml.indexOf("<", at2 + 1);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const [, closing, , selfClosing] = match2;
|
|
104
|
+
at2 = xml.indexOf("<", at2 + match2[0].length);
|
|
86
105
|
if (closing) {
|
|
87
106
|
depth--;
|
|
88
107
|
continue;
|
|
89
108
|
}
|
|
90
109
|
nodes++;
|
|
91
|
-
if (nodes > maxNodes) throw new Error(`${
|
|
110
|
+
if (nodes > maxNodes) throw new Error(`${label2} XML exceeds the limit of ${maxNodes} elements`);
|
|
92
111
|
if (!selfClosing && ++depth > maxDepth)
|
|
93
|
-
throw new Error(`${
|
|
112
|
+
throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
94
113
|
}
|
|
95
114
|
}
|
|
96
115
|
function parseXml(xml, options = {}) {
|
|
97
|
-
const
|
|
116
|
+
const label2 = options.label ?? "OOXML";
|
|
98
117
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
99
|
-
throw new Error(`${
|
|
100
|
-
checkXmlLimits(xml,
|
|
118
|
+
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
119
|
+
checkXmlLimits(xml, label2, options.limits);
|
|
101
120
|
let parseError = "";
|
|
102
121
|
let parsed;
|
|
103
122
|
try {
|
|
@@ -108,12 +127,12 @@ function parseXml(xml, options = {}) {
|
|
|
108
127
|
}).parseFromString(xml, "application/xml");
|
|
109
128
|
} catch (error) {
|
|
110
129
|
throw new Error(
|
|
111
|
-
`Invalid ${
|
|
130
|
+
`Invalid ${label2} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
112
131
|
{ cause: error }
|
|
113
132
|
);
|
|
114
133
|
}
|
|
115
134
|
if (parseError || !parsed.documentElement)
|
|
116
|
-
throw new Error(`Invalid ${
|
|
135
|
+
throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
|
|
117
136
|
return parsed;
|
|
118
137
|
}
|
|
119
138
|
var buildXml = (node3) => new XMLSerializer().serializeToString(node3);
|
|
@@ -400,10 +419,10 @@ function withParseWarnings(warnings, fn) {
|
|
|
400
419
|
function reportParseWarning(message) {
|
|
401
420
|
if (sink && !sink.includes(message)) sink.push(message);
|
|
402
421
|
}
|
|
403
|
-
function enumValue(guard2, raw2,
|
|
422
|
+
function enumValue(guard2, raw2, label2) {
|
|
404
423
|
if (raw2 === null || raw2 === void 0 || raw2 === "") return void 0;
|
|
405
424
|
if (guard2(raw2)) return raw2;
|
|
406
|
-
reportParseWarning(`Ignored invalid ${
|
|
425
|
+
reportParseWarning(`Ignored invalid ${label2} value \u201C${raw2}\u201D; it is not allowed by the schema.`);
|
|
407
426
|
return void 0;
|
|
408
427
|
}
|
|
409
428
|
|
|
@@ -2292,7 +2311,7 @@ function flatChildren(parent, names, level = "block", enclosing, controls3 = /*
|
|
|
2292
2311
|
return found;
|
|
2293
2312
|
}
|
|
2294
2313
|
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
2295
|
-
var flatRows = (
|
|
2314
|
+
var flatRows = (table4) => flatChildren(table4, ["tr"], "row");
|
|
2296
2315
|
var flatCells = (row3) => flatChildren(row3, ["tc"], "cell");
|
|
2297
2316
|
var flatCellParagraphs = (cell) => flatChildren(cell, ["p"]);
|
|
2298
2317
|
|
|
@@ -3005,42 +3024,42 @@ function buildMargins(doc, margins, tag) {
|
|
|
3005
3024
|
}
|
|
3006
3025
|
return element2.childNodes.length ? element2 : void 0;
|
|
3007
3026
|
}
|
|
3008
|
-
function tableJustification(
|
|
3009
|
-
const { alignment, justification } =
|
|
3027
|
+
function tableJustification(table4) {
|
|
3028
|
+
const { alignment, justification } = table4;
|
|
3010
3029
|
const implied = justification === "start" ? "left" : justification === "end" ? "right" : justification;
|
|
3011
3030
|
return justification && implied === alignment ? justification : alignment;
|
|
3012
3031
|
}
|
|
3013
|
-
function tableColumnCount(
|
|
3032
|
+
function tableColumnCount(table4) {
|
|
3014
3033
|
return Math.max(
|
|
3015
3034
|
1,
|
|
3016
|
-
...
|
|
3035
|
+
...table4.rows.map((row3) => row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0))
|
|
3017
3036
|
);
|
|
3018
3037
|
}
|
|
3019
|
-
function buildNewTableProperties(doc,
|
|
3038
|
+
function buildNewTableProperties(doc, table4, contentWidthTwips) {
|
|
3020
3039
|
const tblPr = makeW(doc, "tblPr");
|
|
3021
|
-
if (
|
|
3040
|
+
if (table4.style) {
|
|
3022
3041
|
const style3 = makeW(doc, "tblStyle");
|
|
3023
|
-
setW2(style3, "val",
|
|
3042
|
+
setW2(style3, "val", table4.style);
|
|
3024
3043
|
tblPr.appendChild(style3);
|
|
3025
3044
|
}
|
|
3026
3045
|
const width = makeW(doc, "tblW");
|
|
3027
|
-
setW2(width, "w", String(
|
|
3028
|
-
setW2(width, "type",
|
|
3046
|
+
setW2(width, "w", String(table4.widthTwips ?? 0));
|
|
3047
|
+
setW2(width, "type", table4.widthTwips ? "dxa" : "auto");
|
|
3029
3048
|
tblPr.appendChild(width);
|
|
3030
|
-
const jcValue = tableJustification(
|
|
3049
|
+
const jcValue = tableJustification(table4);
|
|
3031
3050
|
if (jcValue) {
|
|
3032
3051
|
const jc = makeW(doc, "jc");
|
|
3033
3052
|
setW2(jc, "val", jcValue);
|
|
3034
3053
|
tblPr.appendChild(jc);
|
|
3035
3054
|
}
|
|
3036
|
-
if (
|
|
3055
|
+
if (table4.indentTwips !== void 0) {
|
|
3037
3056
|
const indent = makeW(doc, "tblInd");
|
|
3038
|
-
setW2(indent, "w", String(
|
|
3057
|
+
setW2(indent, "w", String(table4.indentTwips));
|
|
3039
3058
|
setW2(indent, "type", "dxa");
|
|
3040
3059
|
tblPr.appendChild(indent);
|
|
3041
3060
|
}
|
|
3042
|
-
if (
|
|
3043
|
-
const margins =
|
|
3061
|
+
if (table4.borders) tblPr.appendChild(buildBorders(doc, table4.borders, "tblBorders"));
|
|
3062
|
+
const margins = table4.cellMargins && buildMargins(doc, table4.cellMargins, "tblCellMar");
|
|
3044
3063
|
if (margins) tblPr.appendChild(margins);
|
|
3045
3064
|
const look = makeW(doc, "tblLook");
|
|
3046
3065
|
const lookAttributes = [
|
|
@@ -3055,8 +3074,8 @@ function buildNewTableProperties(doc, table3, contentWidthTwips) {
|
|
|
3055
3074
|
for (const [name3, value2] of lookAttributes) setW2(look, name3, value2);
|
|
3056
3075
|
tblPr.appendChild(look);
|
|
3057
3076
|
const tblGrid = makeW(doc, "tblGrid");
|
|
3058
|
-
const columns = tableColumnCount(
|
|
3059
|
-
const widths =
|
|
3077
|
+
const columns = tableColumnCount(table4);
|
|
3078
|
+
const widths = table4.grid?.length === columns ? table4.grid : Array.from({ length: columns }, () => Math.max(1, Math.floor(contentWidthTwips / columns)));
|
|
3060
3079
|
for (const value2 of widths) {
|
|
3061
3080
|
const column2 = makeW(doc, "gridCol");
|
|
3062
3081
|
setW2(column2, "w", String(value2));
|
|
@@ -3304,14 +3323,14 @@ function patchRowProperties(doc, tr, next, base2) {
|
|
|
3304
3323
|
}
|
|
3305
3324
|
orderChildren(props, ROW_ORDER);
|
|
3306
3325
|
}
|
|
3307
|
-
function patchTableMargins(doc,
|
|
3326
|
+
function patchTableMargins(doc, table4, node3, base2) {
|
|
3308
3327
|
patchMarginProperties(
|
|
3309
3328
|
doc,
|
|
3310
3329
|
node3,
|
|
3311
3330
|
"tblPr",
|
|
3312
3331
|
"tblCellMar",
|
|
3313
3332
|
TABLE_ORDER,
|
|
3314
|
-
|
|
3333
|
+
table4.cellMargins,
|
|
3315
3334
|
base2?.cellMargins
|
|
3316
3335
|
);
|
|
3317
3336
|
}
|
|
@@ -3406,12 +3425,12 @@ function patchCellShading(doc, tc, next, base2) {
|
|
|
3406
3425
|
}
|
|
3407
3426
|
|
|
3408
3427
|
// docx/write-table.ts
|
|
3409
|
-
function canEditTableStructure(
|
|
3428
|
+
function canEditTableStructure(table4) {
|
|
3410
3429
|
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node3) => allowed.some((name3) => named2(node3, name3)));
|
|
3411
|
-
if (!only(
|
|
3412
|
-
const grid = first2(
|
|
3430
|
+
if (!only(table4, ["tblPr", "tblGrid", "tr"])) return false;
|
|
3431
|
+
const grid = first2(table4, "tblGrid");
|
|
3413
3432
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
3414
|
-
const rows = children2(
|
|
3433
|
+
const rows = children2(table4, "tr");
|
|
3415
3434
|
if (!rows.length) return false;
|
|
3416
3435
|
const [firstRow] = rows;
|
|
3417
3436
|
if (!firstRow) return false;
|
|
@@ -3437,7 +3456,7 @@ function canEditTableStructure(table3) {
|
|
|
3437
3456
|
}
|
|
3438
3457
|
return true;
|
|
3439
3458
|
}
|
|
3440
|
-
var layout = (
|
|
3459
|
+
var layout = (table4) => table4.rows.map((row3) => row3.map((cell) => cell.paragraphs.map((p) => p.id)));
|
|
3441
3460
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
3442
3461
|
"grid",
|
|
3443
3462
|
"widthTwips",
|
|
@@ -3454,9 +3473,9 @@ function pick(source2, keys) {
|
|
|
3454
3473
|
for (const key2 of keys) if (record2[key2] !== void 0) result2[key2] = record2[key2];
|
|
3455
3474
|
return result2;
|
|
3456
3475
|
}
|
|
3457
|
-
function assertNoDescriptorEdits(
|
|
3476
|
+
function assertNoDescriptorEdits(table4, base2) {
|
|
3458
3477
|
if (!base2) return;
|
|
3459
|
-
if (JSON.stringify(pick(
|
|
3478
|
+
if (JSON.stringify(pick(table4, TABLE_DESCRIPTOR_KEYS)) !== JSON.stringify(pick(base2, TABLE_DESCRIPTOR_KEYS)))
|
|
3460
3479
|
throw new Error(
|
|
3461
3480
|
"Cannot edit table grid widths, width, alignment, indent, borders, or style; only cell text and row/column structure changes are supported. The original DOCX package remains unchanged."
|
|
3462
3481
|
);
|
|
@@ -3466,7 +3485,7 @@ function assertNoDescriptorEdits(table3, base2) {
|
|
|
3466
3485
|
const id3 = cell.paragraphs[0]?.id;
|
|
3467
3486
|
if (id3) baseCellById.set(id3, cell);
|
|
3468
3487
|
}
|
|
3469
|
-
for (const row3 of
|
|
3488
|
+
for (const row3 of table4.rows)
|
|
3470
3489
|
for (const cell of row3) {
|
|
3471
3490
|
const id3 = cell.paragraphs[0]?.id;
|
|
3472
3491
|
const source2 = id3 ? baseCellById.get(id3) : void 0;
|
|
@@ -3482,23 +3501,23 @@ function writeNestedTables(doc, tc, cell, base2, writeParagraph, replaceSlots2)
|
|
|
3482
3501
|
const next = tables(cell.sourceBlocks);
|
|
3483
3502
|
const before = tables(base2?.sourceBlocks);
|
|
3484
3503
|
const nodes = children2(tc, "tbl");
|
|
3485
|
-
next.forEach((
|
|
3504
|
+
next.forEach((table4, index3) => {
|
|
3486
3505
|
const node3 = nodes[index3];
|
|
3487
3506
|
if (node3 && before[index3])
|
|
3488
|
-
writeTable(doc,
|
|
3507
|
+
writeTable(doc, table4, node3, before[index3], writeParagraph, replaceSlots2);
|
|
3489
3508
|
});
|
|
3490
3509
|
}
|
|
3491
|
-
function writeTable(doc,
|
|
3492
|
-
if (base2 && JSON.stringify(
|
|
3493
|
-
assertNoDescriptorEdits(
|
|
3494
|
-
patchTableMargins(doc,
|
|
3495
|
-
const structural = base2 && JSON.stringify(layout(
|
|
3510
|
+
function writeTable(doc, table4, node3, base2, writeParagraph, replaceSlots2) {
|
|
3511
|
+
if (base2 && JSON.stringify(table4) === JSON.stringify(base2)) return node3;
|
|
3512
|
+
assertNoDescriptorEdits(table4, base2);
|
|
3513
|
+
patchTableMargins(doc, table4, node3, base2);
|
|
3514
|
+
const structural = base2 && JSON.stringify(layout(table4)) !== JSON.stringify(layout(base2));
|
|
3496
3515
|
if (structural && !canEditTableStructure(node3))
|
|
3497
3516
|
throw new Error(
|
|
3498
3517
|
"Cannot change the structure of a merged, nested, or complex table. The original DOCX package remains unchanged."
|
|
3499
3518
|
);
|
|
3500
|
-
const width =
|
|
3501
|
-
if (!width ||
|
|
3519
|
+
const width = table4.rows[0]?.length ?? 0;
|
|
3520
|
+
if (!width || table4.rows.some((row3) => row3.length !== width || row3.some((cell) => !cell.paragraphs.length)))
|
|
3502
3521
|
throw new Error("Tables must contain rectangular rows and at least one paragraph per cell.");
|
|
3503
3522
|
const oldRows = flatRows(node3).map((entry3) => entry3.element);
|
|
3504
3523
|
const sourceById = /* @__PURE__ */ new Map();
|
|
@@ -3519,7 +3538,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3519
3538
|
const usedCells = /* @__PURE__ */ new Set();
|
|
3520
3539
|
const usedRows = /* @__PURE__ */ new Set();
|
|
3521
3540
|
const columns = /* @__PURE__ */ new Map();
|
|
3522
|
-
const nextRows =
|
|
3541
|
+
const nextRows = table4.rows.map((row3, rowIndex2) => {
|
|
3523
3542
|
const sources = row3.map(
|
|
3524
3543
|
(cell) => cell.paragraphs.map((p) => sourceById.get(p.id)).find(Boolean)
|
|
3525
3544
|
);
|
|
@@ -3534,7 +3553,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3534
3553
|
patchRowProperties(
|
|
3535
3554
|
doc,
|
|
3536
3555
|
tr,
|
|
3537
|
-
|
|
3556
|
+
table4.rowProperties?.[rowIndex2],
|
|
3538
3557
|
sourceRow === void 0 ? void 0 : base2?.rowProperties?.[sourceRow]
|
|
3539
3558
|
);
|
|
3540
3559
|
const nextCells = row3.map((cell, ci) => {
|
|
@@ -11560,8 +11579,8 @@ function gd14(name3, formula) {
|
|
|
11560
11579
|
const parts = formula.trim().split(/\s+/);
|
|
11561
11580
|
return { name: name3, formula, args: parts.slice(1) };
|
|
11562
11581
|
}
|
|
11563
|
-
function parseGdTable(
|
|
11564
|
-
return
|
|
11582
|
+
function parseGdTable(table4) {
|
|
11583
|
+
return table4.trim().split(/[\n;]/).filter((entry3) => entry3.length > 0).map((entry3) => {
|
|
11565
11584
|
const sep = entry3.indexOf("|");
|
|
11566
11585
|
return gd14(entry3.slice(0, sep), entry3.slice(sep + 1));
|
|
11567
11586
|
});
|
|
@@ -13454,8 +13473,8 @@ function parseDiagramDataModel(source2, part) {
|
|
|
13454
13473
|
"CONNECTION_ENDPOINT_MISSING",
|
|
13455
13474
|
`dgm:cxn ${attribute4} references missing point: ${id3}.`
|
|
13456
13475
|
);
|
|
13457
|
-
const
|
|
13458
|
-
connections2.push(
|
|
13476
|
+
const label2 = connectionLabel(connection, transitionText);
|
|
13477
|
+
connections2.push(label2 ? { ...connection, label: label2 } : connection);
|
|
13459
13478
|
if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
|
|
13460
13479
|
parentById.set(connection.destId, connection.sourceId);
|
|
13461
13480
|
}
|
|
@@ -13494,14 +13513,14 @@ function colorList(container) {
|
|
|
13494
13513
|
}
|
|
13495
13514
|
function parseDiagramColors(source2) {
|
|
13496
13515
|
const root = rootOf2(source2);
|
|
13497
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13498
|
-
name: stringAttribute(
|
|
13499
|
-
fill: colorList(first(
|
|
13500
|
-
line: colorList(first(
|
|
13501
|
-
effect: colorList(first(
|
|
13502
|
-
textLine: colorList(first(
|
|
13503
|
-
textFill: colorList(first(
|
|
13504
|
-
textEffect: colorList(first(
|
|
13516
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13517
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13518
|
+
fill: colorList(first(label2, "fillClrLst", NS.dgm)),
|
|
13519
|
+
line: colorList(first(label2, "linClrLst", NS.dgm)),
|
|
13520
|
+
effect: colorList(first(label2, "effectClrLst", NS.dgm)),
|
|
13521
|
+
textLine: colorList(first(label2, "txLinClrLst", NS.dgm)),
|
|
13522
|
+
textFill: colorList(first(label2, "txFillClrLst", NS.dgm)),
|
|
13523
|
+
textEffect: colorList(first(label2, "txEffectClrLst", NS.dgm))
|
|
13505
13524
|
}));
|
|
13506
13525
|
return { ...parseDefinitionHeader(root), labels };
|
|
13507
13526
|
}
|
|
@@ -13534,16 +13553,16 @@ function parseStyleReferences(style3) {
|
|
|
13534
13553
|
var hasContent = (element2) => Boolean(element2 && (element2.attributes.length > 0 || elements(element2).length > 0));
|
|
13535
13554
|
function parseDiagramQuickStyle(source2) {
|
|
13536
13555
|
const root = rootOf2(source2);
|
|
13537
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13538
|
-
name: stringAttribute(
|
|
13539
|
-
...parseStyleReferences(first(
|
|
13540
|
-
hasScene3d: Boolean(first(
|
|
13541
|
-
hasShape3d: hasContent(first(
|
|
13556
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13557
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13558
|
+
...parseStyleReferences(first(label2, "style", NS.dgm)),
|
|
13559
|
+
hasScene3d: Boolean(first(label2, "scene3d", NS.dgm)),
|
|
13560
|
+
hasShape3d: hasContent(first(label2, "sp3d", NS.dgm))
|
|
13542
13561
|
}));
|
|
13543
13562
|
return {
|
|
13544
13563
|
...parseDefinitionHeader(root),
|
|
13545
13564
|
labels,
|
|
13546
|
-
has3d: labels.some((
|
|
13565
|
+
has3d: labels.some((label2) => label2.hasShape3d)
|
|
13547
13566
|
};
|
|
13548
13567
|
}
|
|
13549
13568
|
function parseDiagramLayoutSummary(source2) {
|
|
@@ -14713,10 +14732,10 @@ function parseDisplayUnits(context, element2) {
|
|
|
14713
14732
|
if (!element2) return void 0;
|
|
14714
14733
|
reportUnmodelled(context, element2, DISPLAY_UNITS);
|
|
14715
14734
|
const labelElement = cChild(element2, "dispUnitsLbl");
|
|
14716
|
-
let
|
|
14735
|
+
let label2;
|
|
14717
14736
|
if (labelElement) {
|
|
14718
14737
|
reportUnmodelled(context, labelElement, DISPLAY_UNITS_LABEL);
|
|
14719
|
-
|
|
14738
|
+
label2 = assignDefined(
|
|
14720
14739
|
{},
|
|
14721
14740
|
{
|
|
14722
14741
|
layout: manualLayout(labelElement),
|
|
@@ -14731,7 +14750,7 @@ function parseDisplayUnits(context, element2) {
|
|
|
14731
14750
|
{
|
|
14732
14751
|
builtInUnit: cVal(element2, "builtInUnit"),
|
|
14733
14752
|
customUnit: cNumber(context, element2, "custUnit"),
|
|
14734
|
-
label:
|
|
14753
|
+
label: label2,
|
|
14735
14754
|
extLst: extensionList2(element2)
|
|
14736
14755
|
}
|
|
14737
14756
|
);
|
|
@@ -15585,10 +15604,10 @@ function titleXml(context, title) {
|
|
|
15585
15604
|
function labelOptionsXml(context, options) {
|
|
15586
15605
|
return numberFormatXml(options.numberFormat) + shapePropertiesXml(context, options.spPr) + textBodyXml(context, options.txPr) + valXml("dLblPos", options.position) + valXml("showLegendKey", options.showLegendKey) + valXml("showVal", options.showValue) + valXml("showCatName", options.showCategoryName) + valXml("showSerName", options.showSeriesName) + valXml("showPercent", options.showPercent) + valXml("showBubbleSize", options.showBubbleSize) + (options.separator === void 0 ? "" : textElement("separator", options.separator));
|
|
15587
15606
|
}
|
|
15588
|
-
function labelXml(context,
|
|
15607
|
+
function labelXml(context, label2) {
|
|
15589
15608
|
return elementXml(
|
|
15590
15609
|
"dLbl",
|
|
15591
|
-
valXml("idx",
|
|
15610
|
+
valXml("idx", label2.index) + valXml("delete", label2.deleted) + layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + labelOptionsXml(context, label2) + raw(context, label2.extLst)
|
|
15592
15611
|
);
|
|
15593
15612
|
}
|
|
15594
15613
|
function dataLabelsXml(context, labels) {
|
|
@@ -15596,7 +15615,7 @@ function dataLabelsXml(context, labels) {
|
|
|
15596
15615
|
const leaderLines = labels.leaderLines ? elementXml("leaderLines", shapePropertiesXml(context, labels.leaderLines.spPr)) : "";
|
|
15597
15616
|
return elementXml(
|
|
15598
15617
|
"dLbls",
|
|
15599
|
-
labels.labels.map((
|
|
15618
|
+
labels.labels.map((label2) => labelXml(context, label2)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
|
|
15600
15619
|
);
|
|
15601
15620
|
}
|
|
15602
15621
|
|
|
@@ -15608,21 +15627,21 @@ function surfaceXml(context, local, surface) {
|
|
|
15608
15627
|
valXml("thickness", surface.thickness) + shapePropertiesXml(context, surface.spPr) + raw(context, surface.pictureOptionsXml) + raw(context, surface.extLst)
|
|
15609
15628
|
);
|
|
15610
15629
|
}
|
|
15611
|
-
function dataTableXml(context,
|
|
15612
|
-
if (!
|
|
15630
|
+
function dataTableXml(context, table4) {
|
|
15631
|
+
if (!table4) return "";
|
|
15613
15632
|
return elementXml(
|
|
15614
15633
|
"dTable",
|
|
15615
|
-
valXml("showHorzBorder",
|
|
15634
|
+
valXml("showHorzBorder", table4.showHorizontalBorder) + valXml("showVertBorder", table4.showVerticalBorder) + valXml("showOutline", table4.showOutline) + valXml("showKeys", table4.showKeys) + shapePropertiesXml(context, table4.spPr) + textBodyXml(context, table4.txPr) + raw(context, table4.extLst)
|
|
15616
15635
|
);
|
|
15617
15636
|
}
|
|
15618
15637
|
function displayUnitsXml(context, units2) {
|
|
15619
15638
|
if (!units2) return "";
|
|
15620
|
-
const
|
|
15639
|
+
const label2 = units2.label;
|
|
15621
15640
|
return elementXml(
|
|
15622
15641
|
"dispUnits",
|
|
15623
|
-
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (
|
|
15642
|
+
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (label2 ? elementXml(
|
|
15624
15643
|
"dispUnitsLbl",
|
|
15625
|
-
layoutXml(context,
|
|
15644
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr)
|
|
15626
15645
|
) : "") + raw(context, units2.extLst)
|
|
15627
15646
|
);
|
|
15628
15647
|
}
|
|
@@ -15647,11 +15666,11 @@ function axisXml(context, axis) {
|
|
|
15647
15666
|
}
|
|
15648
15667
|
|
|
15649
15668
|
// chart/write-analysis.ts
|
|
15650
|
-
function trendlineLabelXml(context,
|
|
15651
|
-
if (!
|
|
15669
|
+
function trendlineLabelXml(context, label2) {
|
|
15670
|
+
if (!label2) return "";
|
|
15652
15671
|
return elementXml(
|
|
15653
15672
|
"trendlineLbl",
|
|
15654
|
-
layoutXml(context,
|
|
15673
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + numberFormatXml(label2.numberFormat) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr) + raw(context, label2.extLst)
|
|
15655
15674
|
);
|
|
15656
15675
|
}
|
|
15657
15676
|
function trendlineXml(context, trendline) {
|
|
@@ -17902,16 +17921,16 @@ var RelationshipAllocator = class {
|
|
|
17902
17921
|
|
|
17903
17922
|
// docx/write.ts
|
|
17904
17923
|
var twips2 = (pixels) => String(Math.round(pixels * 15));
|
|
17905
|
-
function createTable(doc,
|
|
17924
|
+
function createTable(doc, table4, allocator, contentWidthTwips, spans2) {
|
|
17906
17925
|
const node3 = makeW(doc, "tbl");
|
|
17907
|
-
const { tblPr, tblGrid } = buildNewTableProperties(doc,
|
|
17926
|
+
const { tblPr, tblGrid } = buildNewTableProperties(doc, table4, contentWidthTwips);
|
|
17908
17927
|
node3.appendChild(tblPr);
|
|
17909
17928
|
node3.appendChild(tblGrid);
|
|
17910
|
-
const columns = tableColumnCount(
|
|
17911
|
-
|
|
17929
|
+
const columns = tableColumnCount(table4);
|
|
17930
|
+
table4.rows.forEach((row3, rowIndex2) => {
|
|
17912
17931
|
const tr = makeW(doc, "tr");
|
|
17913
17932
|
const spanned = row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0);
|
|
17914
|
-
const trPr = buildRowProperties(doc,
|
|
17933
|
+
const trPr = buildRowProperties(doc, table4.rowProperties?.[rowIndex2], columns - spanned);
|
|
17915
17934
|
if (trPr) tr.appendChild(trPr);
|
|
17916
17935
|
for (const cell of row3) {
|
|
17917
17936
|
const tc = makeW(doc, "tc");
|
|
@@ -18314,28 +18333,28 @@ function validateCell(c2, cell) {
|
|
|
18314
18333
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18315
18334
|
c2.at(".margins").signed(side2, cell.margins[side2], "ST_SignedTwipsMeasure");
|
|
18316
18335
|
}
|
|
18317
|
-
function validateTable(c2,
|
|
18318
|
-
c2.unsigned("widthTwips",
|
|
18319
|
-
c2.signed("indentTwips",
|
|
18336
|
+
function validateTable(c2, table4) {
|
|
18337
|
+
c2.unsigned("widthTwips", table4.widthTwips, "ST_TwipsMeasure");
|
|
18338
|
+
c2.signed("indentTwips", table4.indentTwips, "ST_SignedTwipsMeasure");
|
|
18320
18339
|
c2.check(
|
|
18321
18340
|
"alignment",
|
|
18322
|
-
|
|
18341
|
+
table4.alignment,
|
|
18323
18342
|
(v) => v === "left" || v === "center" || v === "right",
|
|
18324
18343
|
'must be "left", "center" or "right"'
|
|
18325
18344
|
);
|
|
18326
|
-
c2.enum("justification",
|
|
18327
|
-
|
|
18345
|
+
c2.enum("justification", table4.justification, isStJcTable, "ST_JcTable");
|
|
18346
|
+
table4.grid?.forEach(
|
|
18328
18347
|
(width, index3) => c2.at(`.grid[${index3}]`).unsigned("width", width, "ST_TwipsMeasure")
|
|
18329
18348
|
);
|
|
18330
|
-
validateBorders(c2.at(".borders"),
|
|
18331
|
-
if (
|
|
18349
|
+
validateBorders(c2.at(".borders"), table4.borders);
|
|
18350
|
+
if (table4.cellMargins)
|
|
18332
18351
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18333
|
-
c2.at(".cellMargins").signed(side2,
|
|
18334
|
-
|
|
18352
|
+
c2.at(".cellMargins").signed(side2, table4.cellMargins[side2], "ST_SignedTwipsMeasure");
|
|
18353
|
+
table4.rowProperties?.forEach((row3, index3) => {
|
|
18335
18354
|
if (row3)
|
|
18336
18355
|
c2.at(`.rowProperties[${index3}]`).unsigned("heightTwips", row3.heightTwips, "ST_TwipsMeasure");
|
|
18337
18356
|
});
|
|
18338
|
-
|
|
18357
|
+
table4.rows.forEach(
|
|
18339
18358
|
(row3, r) => row3.forEach((cell, k) => validateCell(c2.at(`.rows[${r}][${k}]`), cell))
|
|
18340
18359
|
);
|
|
18341
18360
|
}
|
|
@@ -19767,40 +19786,40 @@ function parseTable(node3, id3, parseParagraph3) {
|
|
|
19767
19786
|
(cell, ci) => parseCell(cell.element, parseParagraph3, `${id3}-r${ri}c${ci}`, cell.control)
|
|
19768
19787
|
)
|
|
19769
19788
|
);
|
|
19770
|
-
const
|
|
19789
|
+
const table4 = { type: "table", id: id3, rows, structureEditable: canEditTableStructure(node3) };
|
|
19771
19790
|
const gridElement = first2(node3, "tblGrid");
|
|
19772
19791
|
const grid = gridElement ? children2(gridElement, "gridCol").flatMap((column2) => {
|
|
19773
19792
|
const width2 = dxa(getW(column2, "w"));
|
|
19774
19793
|
return width2 === void 0 ? [] : [width2];
|
|
19775
19794
|
}) : [];
|
|
19776
|
-
if (grid.length)
|
|
19795
|
+
if (grid.length) table4.grid = grid;
|
|
19777
19796
|
const tblPr = first2(node3, "tblPr");
|
|
19778
19797
|
const tableWidth = first2(tblPr, "tblW");
|
|
19779
19798
|
const width = (getW(tableWidth, "type") ?? "dxa") === "dxa" ? dxa(getW(tableWidth, "w")) : void 0;
|
|
19780
|
-
if (width !== void 0)
|
|
19799
|
+
if (width !== void 0) table4.widthTwips = width;
|
|
19781
19800
|
const justification = enumValue(isStJcTable, getW(first2(tblPr, "jc"), "val"), "w:tblPr/w:jc");
|
|
19782
19801
|
if (justification) {
|
|
19783
|
-
|
|
19802
|
+
table4.justification = justification;
|
|
19784
19803
|
const rtl = onOffElement(first2(tblPr, "bidiVisual")) === true;
|
|
19785
|
-
|
|
19804
|
+
table4.alignment = justification === "start" ? rtl ? "right" : "left" : justification === "end" ? rtl ? "left" : "right" : justification;
|
|
19786
19805
|
}
|
|
19787
19806
|
const indent = parseSignedTwips(getW(first2(tblPr, "tblInd"), "w"));
|
|
19788
|
-
if (indent !== void 0)
|
|
19807
|
+
if (indent !== void 0) table4.indentTwips = indent;
|
|
19789
19808
|
const borders = parseTableBorders(first2(tblPr, "tblBorders"));
|
|
19790
|
-
if (borders)
|
|
19809
|
+
if (borders) table4.borders = borders;
|
|
19791
19810
|
const styleId = getW(first2(tblPr, "tblStyle"), "val");
|
|
19792
|
-
if (styleId)
|
|
19811
|
+
if (styleId) table4.style = styleId;
|
|
19793
19812
|
const look = parseLook(first2(tblPr, "tblLook"));
|
|
19794
|
-
if (look)
|
|
19813
|
+
if (look) table4.look = look;
|
|
19795
19814
|
const cellMargins = parseMargins(first2(tblPr, "tblCellMar"));
|
|
19796
|
-
if (cellMargins)
|
|
19815
|
+
if (cellMargins) table4.cellMargins = cellMargins;
|
|
19797
19816
|
const rowProperties = rowEntries.map(({ element: element2, control }) => {
|
|
19798
19817
|
const properties = parseRowProperties(element2);
|
|
19799
19818
|
if (control) properties.contentControl = control;
|
|
19800
19819
|
return properties;
|
|
19801
19820
|
});
|
|
19802
|
-
if (rowProperties.some((row3) => Object.keys(row3).length))
|
|
19803
|
-
return
|
|
19821
|
+
if (rowProperties.some((row3) => Object.keys(row3).length)) table4.rowProperties = rowProperties;
|
|
19822
|
+
return table4;
|
|
19804
19823
|
}
|
|
19805
19824
|
|
|
19806
19825
|
// docx/hyperlink.ts
|
|
@@ -20854,19 +20873,19 @@ var nextSheetId = (workbook) => workbook.sheets.reduce((max, sheet) => Math.max(
|
|
|
20854
20873
|
var MAX_ROW = 1048575;
|
|
20855
20874
|
var MAX_COL = 16383;
|
|
20856
20875
|
function columnLabel(col) {
|
|
20857
|
-
let
|
|
20876
|
+
let label2 = "";
|
|
20858
20877
|
let n = col + 1;
|
|
20859
20878
|
while (n > 0) {
|
|
20860
20879
|
const rem = (n - 1) % 26;
|
|
20861
|
-
|
|
20880
|
+
label2 = String.fromCharCode(65 + rem) + label2;
|
|
20862
20881
|
n = Math.floor((n - 1) / 26);
|
|
20863
20882
|
}
|
|
20864
|
-
return
|
|
20883
|
+
return label2;
|
|
20865
20884
|
}
|
|
20866
|
-
function columnIndex(
|
|
20867
|
-
if (!/^[A-Za-z]{1,3}$/.test(
|
|
20885
|
+
function columnIndex(label2) {
|
|
20886
|
+
if (!/^[A-Za-z]{1,3}$/.test(label2)) return -1;
|
|
20868
20887
|
let n = 0;
|
|
20869
|
-
for (const ch of
|
|
20888
|
+
for (const ch of label2.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
20870
20889
|
return n - 1;
|
|
20871
20890
|
}
|
|
20872
20891
|
var formatAddress = (address2) => `${columnLabel(address2.col)}${address2.row + 1}`;
|
|
@@ -23237,6 +23256,223 @@ var pivotColumnFields = (pivot) => [
|
|
|
23237
23256
|
...pivot.columnField ? pivot.moreColumnFields ?? [] : []
|
|
23238
23257
|
];
|
|
23239
23258
|
|
|
23259
|
+
// i18n/locale.ts
|
|
23260
|
+
var SUPPORTED_OFFICE_LOCALES = ["en", "fr", "de", "es", "zh-CN"];
|
|
23261
|
+
var DEFAULT_REJECTED_SUBTAGS = ["hant", "tw", "hk", "mo"];
|
|
23262
|
+
function normalizeLocale(input, supported2, fallback, options = {}) {
|
|
23263
|
+
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
23264
|
+
const language = parts[0];
|
|
23265
|
+
if (!language) return fallback;
|
|
23266
|
+
const find3 = (tag) => supported2.find((item) => item.toLowerCase() === tag);
|
|
23267
|
+
const exact = find3(parts.join("-"));
|
|
23268
|
+
if (exact) return exact;
|
|
23269
|
+
const base2 = find3(language);
|
|
23270
|
+
if (base2) return base2;
|
|
23271
|
+
const rejected = options.rejectedSubtags ?? DEFAULT_REJECTED_SUBTAGS;
|
|
23272
|
+
if (parts.slice(1).some((part) => rejected.includes(part))) return fallback;
|
|
23273
|
+
return supported2.find((item) => item.toLowerCase().split("-")[0] === language && item.includes("-")) ?? fallback;
|
|
23274
|
+
}
|
|
23275
|
+
function normalizeOfficeLocale(input) {
|
|
23276
|
+
return normalizeLocale(input, SUPPORTED_OFFICE_LOCALES, "en");
|
|
23277
|
+
}
|
|
23278
|
+
|
|
23279
|
+
// xlsx/pivot/captions-locales.ts
|
|
23280
|
+
var table = (words2, prefix3, rest, functions) => ({
|
|
23281
|
+
...rest,
|
|
23282
|
+
functions,
|
|
23283
|
+
aggregates: Object.fromEntries(
|
|
23284
|
+
Object.keys(words2).map((fn) => [fn, prefix3(words2[fn])])
|
|
23285
|
+
)
|
|
23286
|
+
});
|
|
23287
|
+
var GERMAN = {
|
|
23288
|
+
sum: "Summe",
|
|
23289
|
+
count: "Anzahl",
|
|
23290
|
+
average: "Mittelwert",
|
|
23291
|
+
max: "Max",
|
|
23292
|
+
min: "Min",
|
|
23293
|
+
product: "Produkt",
|
|
23294
|
+
countNums: "Anzahl (Zahlen)",
|
|
23295
|
+
stdDev: "Standardabweichung",
|
|
23296
|
+
stdDevp: "Standardabweichung (Grundgesamtheit)",
|
|
23297
|
+
var: "Varianz",
|
|
23298
|
+
varp: "Varianz (Grundgesamtheit)"
|
|
23299
|
+
};
|
|
23300
|
+
var SPANISH = {
|
|
23301
|
+
sum: "Suma",
|
|
23302
|
+
count: "Cuenta",
|
|
23303
|
+
average: "Promedio",
|
|
23304
|
+
max: "M\xE1x",
|
|
23305
|
+
min: "M\xEDn",
|
|
23306
|
+
product: "Producto",
|
|
23307
|
+
countNums: "Cuenta de n\xFAmeros",
|
|
23308
|
+
stdDev: "Desvest",
|
|
23309
|
+
stdDevp: "Desvestp",
|
|
23310
|
+
var: "Var",
|
|
23311
|
+
varp: "Varp"
|
|
23312
|
+
};
|
|
23313
|
+
var FRENCH = {
|
|
23314
|
+
sum: "Somme",
|
|
23315
|
+
count: "Nombre",
|
|
23316
|
+
average: "Moyenne",
|
|
23317
|
+
max: "Max",
|
|
23318
|
+
min: "Min",
|
|
23319
|
+
product: "Produit",
|
|
23320
|
+
countNums: "Nombre (nombres)",
|
|
23321
|
+
stdDev: "\xC9cartype",
|
|
23322
|
+
stdDevp: "\xC9cartypep",
|
|
23323
|
+
var: "Var",
|
|
23324
|
+
varp: "Varp"
|
|
23325
|
+
};
|
|
23326
|
+
var CHINESE = {
|
|
23327
|
+
sum: "\u6C42\u548C",
|
|
23328
|
+
count: "\u8BA1\u6570",
|
|
23329
|
+
average: "\u5E73\u5747\u503C",
|
|
23330
|
+
max: "\u6700\u5927\u503C",
|
|
23331
|
+
min: "\u6700\u5C0F\u503C",
|
|
23332
|
+
product: "\u4E58\u79EF",
|
|
23333
|
+
countNums: "\u6570\u503C\u8BA1\u6570",
|
|
23334
|
+
stdDev: "\u6807\u51C6\u504F\u5DEE",
|
|
23335
|
+
stdDevp: "\u603B\u4F53\u6807\u51C6\u504F\u5DEE",
|
|
23336
|
+
var: "\u65B9\u5DEE",
|
|
23337
|
+
varp: "\u603B\u4F53\u65B9\u5DEE"
|
|
23338
|
+
};
|
|
23339
|
+
var LOCALIZED_PIVOT_CAPTIONS = {
|
|
23340
|
+
de: table(
|
|
23341
|
+
GERMAN,
|
|
23342
|
+
(word) => `${word} von {0}`,
|
|
23343
|
+
{
|
|
23344
|
+
rowLabels: "Zeilenbeschriftungen",
|
|
23345
|
+
columnLabels: "Spaltenbeschriftungen",
|
|
23346
|
+
grandTotal: "Gesamtergebnis",
|
|
23347
|
+
values: "Werte",
|
|
23348
|
+
all: "(Alle)",
|
|
23349
|
+
blank: "(leer)",
|
|
23350
|
+
subtotal: "{0} Ergebnis",
|
|
23351
|
+
measureTotal: "Gesamt {0}"
|
|
23352
|
+
},
|
|
23353
|
+
GERMAN
|
|
23354
|
+
),
|
|
23355
|
+
es: table(
|
|
23356
|
+
SPANISH,
|
|
23357
|
+
(word) => `${word} de {0}`,
|
|
23358
|
+
{
|
|
23359
|
+
rowLabels: "Etiquetas de fila",
|
|
23360
|
+
columnLabels: "Etiquetas de columna",
|
|
23361
|
+
grandTotal: "Total general",
|
|
23362
|
+
values: "Valores",
|
|
23363
|
+
all: "(Todas)",
|
|
23364
|
+
blank: "(en blanco)",
|
|
23365
|
+
subtotal: "{0} Total",
|
|
23366
|
+
measureTotal: "Total {0}"
|
|
23367
|
+
},
|
|
23368
|
+
SPANISH
|
|
23369
|
+
),
|
|
23370
|
+
fr: table(
|
|
23371
|
+
FRENCH,
|
|
23372
|
+
(word) => `${word} de {0}`,
|
|
23373
|
+
{
|
|
23374
|
+
rowLabels: "\xC9tiquettes de lignes",
|
|
23375
|
+
columnLabels: "\xC9tiquettes de colonnes",
|
|
23376
|
+
grandTotal: "Total g\xE9n\xE9ral",
|
|
23377
|
+
values: "Valeurs",
|
|
23378
|
+
all: "(Tous)",
|
|
23379
|
+
blank: "(vide)",
|
|
23380
|
+
subtotal: "{0} Total",
|
|
23381
|
+
measureTotal: "Total {0}"
|
|
23382
|
+
},
|
|
23383
|
+
FRENCH
|
|
23384
|
+
),
|
|
23385
|
+
"zh-CN": table(
|
|
23386
|
+
CHINESE,
|
|
23387
|
+
(word) => `${word}\u9879:{0}`,
|
|
23388
|
+
{
|
|
23389
|
+
rowLabels: "\u884C\u6807\u7B7E",
|
|
23390
|
+
columnLabels: "\u5217\u6807\u7B7E",
|
|
23391
|
+
grandTotal: "\u603B\u8BA1",
|
|
23392
|
+
values: "\u6570\u503C",
|
|
23393
|
+
all: "(\u5168\u90E8)",
|
|
23394
|
+
blank: "(\u7A7A\u767D)",
|
|
23395
|
+
subtotal: "{0} \u6C47\u603B",
|
|
23396
|
+
measureTotal: "\u603B\u8BA1 {0}"
|
|
23397
|
+
},
|
|
23398
|
+
CHINESE
|
|
23399
|
+
)
|
|
23400
|
+
};
|
|
23401
|
+
|
|
23402
|
+
// xlsx/pivot/captions.ts
|
|
23403
|
+
var FUNCTIONS = {
|
|
23404
|
+
sum: "Sum",
|
|
23405
|
+
count: "Count",
|
|
23406
|
+
average: "Average",
|
|
23407
|
+
max: "Max",
|
|
23408
|
+
min: "Min",
|
|
23409
|
+
product: "Product",
|
|
23410
|
+
countNums: "Count",
|
|
23411
|
+
stdDev: "StdDev",
|
|
23412
|
+
stdDevp: "StdDevp",
|
|
23413
|
+
var: "Var",
|
|
23414
|
+
varp: "Varp"
|
|
23415
|
+
};
|
|
23416
|
+
var aggregateNames = () => Object.fromEntries(
|
|
23417
|
+
Object.keys(FUNCTIONS).map((fn) => [
|
|
23418
|
+
fn,
|
|
23419
|
+
`${fn[0].toUpperCase()}${fn.slice(1)} of {0}`
|
|
23420
|
+
])
|
|
23421
|
+
);
|
|
23422
|
+
var ENGLISH_PIVOT_CAPTIONS = {
|
|
23423
|
+
rowLabels: "Row Labels",
|
|
23424
|
+
columnLabels: "Column Labels",
|
|
23425
|
+
grandTotal: "Grand Total",
|
|
23426
|
+
values: "Values",
|
|
23427
|
+
all: "(All)",
|
|
23428
|
+
blank: "(blank)",
|
|
23429
|
+
subtotal: "{0} Total",
|
|
23430
|
+
measureTotal: "Total {0}",
|
|
23431
|
+
functions: FUNCTIONS,
|
|
23432
|
+
aggregates: aggregateNames()
|
|
23433
|
+
};
|
|
23434
|
+
var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
|
|
23435
|
+
function pivotCaptions(pivot) {
|
|
23436
|
+
const own2 = pivot.captions;
|
|
23437
|
+
if (!own2) return ENGLISH_PIVOT_CAPTIONS;
|
|
23438
|
+
return {
|
|
23439
|
+
...ENGLISH_PIVOT_CAPTIONS,
|
|
23440
|
+
...Object.fromEntries(Object.entries(own2).filter(([, value2]) => typeof value2 === "string")),
|
|
23441
|
+
functions: { ...ENGLISH_PIVOT_CAPTIONS.functions, ...own2.functions },
|
|
23442
|
+
aggregates: { ...ENGLISH_PIVOT_CAPTIONS.aggregates, ...own2.aggregates }
|
|
23443
|
+
};
|
|
23444
|
+
}
|
|
23445
|
+
var pivotMeasureName = (aggregate2, field2, pivot = {}) => fillCaption(pivotCaptions(pivot).aggregates[aggregate2], field2);
|
|
23446
|
+
function localizedPivotCaptions(locale) {
|
|
23447
|
+
const caps = LOCALIZED_PIVOT_CAPTIONS[normalizeOfficeLocale(locale)];
|
|
23448
|
+
return caps ? structuredClone(caps) : void 0;
|
|
23449
|
+
}
|
|
23450
|
+
function trimmedCaptions(caps) {
|
|
23451
|
+
const out = {};
|
|
23452
|
+
for (const key2 of [
|
|
23453
|
+
"rowLabels",
|
|
23454
|
+
"columnLabels",
|
|
23455
|
+
"grandTotal",
|
|
23456
|
+
"values",
|
|
23457
|
+
"all",
|
|
23458
|
+
"blank",
|
|
23459
|
+
"subtotal",
|
|
23460
|
+
"measureTotal"
|
|
23461
|
+
])
|
|
23462
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2]) out[key2] = caps[key2];
|
|
23463
|
+
for (const key2 of ["functions", "aggregates"]) {
|
|
23464
|
+
const changed = Object.keys(caps[key2]).filter(
|
|
23465
|
+
(fn) => caps[key2][fn] !== ENGLISH_PIVOT_CAPTIONS[key2][fn]
|
|
23466
|
+
);
|
|
23467
|
+
if (changed.length) out[key2] = Object.fromEntries(changed.map((fn) => [fn, caps[key2][fn]]));
|
|
23468
|
+
}
|
|
23469
|
+
return Object.keys(out).length ? out : void 0;
|
|
23470
|
+
}
|
|
23471
|
+
function authoredCaptions(options) {
|
|
23472
|
+
const own2 = options.captions ?? localizedPivotCaptions(options.locale);
|
|
23473
|
+
return own2 && Object.keys(own2).length ? structuredClone(own2) : void 0;
|
|
23474
|
+
}
|
|
23475
|
+
|
|
23240
23476
|
// xlsx/formula/date-serial.ts
|
|
23241
23477
|
var DAY_MS = 864e5;
|
|
23242
23478
|
var EPOCH_19002 = Date.UTC(1899, 11, 30);
|
|
@@ -23495,9 +23731,9 @@ function expandDateGroups(pivot) {
|
|
|
23495
23731
|
fields: [...pivot.fields, ...derived.map((entry3) => entry3.name)],
|
|
23496
23732
|
records: pivot.records.map((record2) => [
|
|
23497
23733
|
...record2,
|
|
23498
|
-
...tables.map((
|
|
23499
|
-
const value2 = record2[
|
|
23500
|
-
return typeof value2 === "number" ?
|
|
23734
|
+
...tables.map((table4) => {
|
|
23735
|
+
const value2 = record2[table4.base];
|
|
23736
|
+
return typeof value2 === "number" ? table4.labels[table4.index(value2)] : null;
|
|
23501
23737
|
})
|
|
23502
23738
|
])
|
|
23503
23739
|
};
|
|
@@ -23701,6 +23937,17 @@ function pruneItemFilters(pivot) {
|
|
|
23701
23937
|
return next.length ? next : void 0;
|
|
23702
23938
|
}
|
|
23703
23939
|
|
|
23940
|
+
// xlsx/pivot/item-labels.ts
|
|
23941
|
+
var keyOf = (field2, item) => `${field2}\0${pivotValueKey(item)}`;
|
|
23942
|
+
function pivotItemLabeler(pivot) {
|
|
23943
|
+
const blank = pivotCaptions(pivot).blank;
|
|
23944
|
+
const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
|
|
23945
|
+
return (field2, value2) => names?.get(keyOf(field2, value2)) ?? (value2 === null || value2 === "" ? blank : pivotItemLabel(value2));
|
|
23946
|
+
}
|
|
23947
|
+
var pivotItemName = (pivot, field2, item) => pivot.itemNames?.find(
|
|
23948
|
+
(entry3) => entry3.field === field2 && pivotValueKey(entry3.item) === pivotValueKey(item)
|
|
23949
|
+
)?.name;
|
|
23950
|
+
|
|
23704
23951
|
// xlsx/pivot/page-filter.ts
|
|
23705
23952
|
function validatePivotPageFilter(pivot) {
|
|
23706
23953
|
const filter2 = pivot.pageFilter;
|
|
@@ -23712,8 +23959,8 @@ function validatePivotPageFilter(pivot) {
|
|
|
23712
23959
|
pivot.columnField,
|
|
23713
23960
|
pivot.valueField,
|
|
23714
23961
|
...extras.map((v) => v?.field)
|
|
23715
|
-
].includes(filter2.field)
|
|
23716
|
-
throw new Error("Report filters require
|
|
23962
|
+
].includes(filter2.field))
|
|
23963
|
+
throw new Error("Report filters require a separate source field.");
|
|
23717
23964
|
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))
|
|
23718
23965
|
throw new Error("Choose a cached literal report filter item.");
|
|
23719
23966
|
}
|
|
@@ -23726,10 +23973,10 @@ function pagedProjection(pivot) {
|
|
|
23726
23973
|
if (!filter2) return pivot;
|
|
23727
23974
|
const labels = /* @__PURE__ */ new Map();
|
|
23728
23975
|
for (const item of pivotItems(pivot, filter2.field)) {
|
|
23729
|
-
const
|
|
23730
|
-
if (
|
|
23976
|
+
const label2 = String(pivotItemLabel(item)).toLowerCase(), key3 = pivotValueKey(item);
|
|
23977
|
+
if (label2 === "(all)" || labels.has(label2) && labels.get(label2) !== key3)
|
|
23731
23978
|
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
23732
|
-
labels.set(
|
|
23979
|
+
labels.set(label2, key3);
|
|
23733
23980
|
}
|
|
23734
23981
|
if (filter2.item === void 0) return pivot;
|
|
23735
23982
|
const index3 = pivot.fields.indexOf(filter2.field), key2 = pivotValueKey(filter2.item);
|
|
@@ -23747,7 +23994,7 @@ function prependPivotPage(grid, pivot) {
|
|
|
23747
23994
|
values: [
|
|
23748
23995
|
[
|
|
23749
23996
|
pivot.pageFilter.field,
|
|
23750
|
-
pivot.pageFilter.item === void 0 ?
|
|
23997
|
+
pivot.pageFilter.item === void 0 ? pivotCaptions(pivot).all : pivotItemLabeler(pivot)(pivot.pageFilter.field, pivot.pageFilter.item),
|
|
23751
23998
|
...Array(width - 2).fill(null)
|
|
23752
23999
|
],
|
|
23753
24000
|
Array(width).fill(null),
|
|
@@ -23886,7 +24133,7 @@ function validatePivotFields(pivot) {
|
|
|
23886
24133
|
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
23887
24134
|
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
23888
24135
|
throw new Error("Values on rows require multiple measures.");
|
|
23889
|
-
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !==
|
|
24136
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
|
|
23890
24137
|
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
23891
24138
|
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
23892
24139
|
(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())
|
|
@@ -23899,8 +24146,8 @@ function validatePivotFields(pivot) {
|
|
|
23899
24146
|
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")
|
|
23900
24147
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
23901
24148
|
}
|
|
23902
|
-
function pivotCaption(aggregate2, field2) {
|
|
23903
|
-
return
|
|
24149
|
+
function pivotCaption(aggregate2, field2, pivot) {
|
|
24150
|
+
return pivotMeasureName(aggregate2, field2, pivot);
|
|
23904
24151
|
}
|
|
23905
24152
|
|
|
23906
24153
|
// xlsx/write/xml-out.ts
|
|
@@ -23947,7 +24194,7 @@ var pivotMeasures = (pivot) => [
|
|
|
23947
24194
|
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
23948
24195
|
...pivot.additionalValues ?? []
|
|
23949
24196
|
];
|
|
23950
|
-
function normalizedPivotMeasures(values2) {
|
|
24197
|
+
function normalizedPivotMeasures(values2, pivot) {
|
|
23951
24198
|
if (!Array.isArray(values2) || values2.length > 15)
|
|
23952
24199
|
throw new Error("Choose between one and sixteen PivotTable value fields.");
|
|
23953
24200
|
return values2.map((value2) => {
|
|
@@ -23959,7 +24206,7 @@ function normalizedPivotMeasures(values2) {
|
|
|
23959
24206
|
return {
|
|
23960
24207
|
field: value2.field,
|
|
23961
24208
|
aggregate: aggregate2,
|
|
23962
|
-
caption: value2.caption ??
|
|
24209
|
+
caption: value2.caption ?? pivotMeasureName(aggregate2, value2.field, pivot)
|
|
23963
24210
|
};
|
|
23964
24211
|
});
|
|
23965
24212
|
}
|
|
@@ -23994,7 +24241,6 @@ var pivotMeasureNumber = (pivot, records, measure2) => aggregateValues(records,
|
|
|
23994
24241
|
|
|
23995
24242
|
// xlsx/pivot/columns.ts
|
|
23996
24243
|
var SEPARATOR = "";
|
|
23997
|
-
var label = pivotItemLabel;
|
|
23998
24244
|
var columnKey = (keys, depth) => keys.slice(0, depth).join(SEPARATOR);
|
|
23999
24245
|
var recordColumnKeys = (record2, indices) => indices.map((index3) => pivotValueKey(record2[index3] ?? null));
|
|
24000
24246
|
function pivotColumnEntries(pivot) {
|
|
@@ -24069,7 +24315,9 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
|
24069
24315
|
const rows = levels + 1 + Number(count2 > 1);
|
|
24070
24316
|
const grid = Array.from({ length: rows }, () => Array(width).fill(null));
|
|
24071
24317
|
if (count2 === 1 && !valuesOnRows) grid[0][0] = pivot.valueCaption;
|
|
24072
|
-
const
|
|
24318
|
+
const caps = pivotCaptions(pivot);
|
|
24319
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24320
|
+
const titles = compact3 ? [caps.columnLabels] : [...columns.names, ...count2 > 1 ? [caps.values] : []];
|
|
24073
24321
|
titles.forEach((title, i2) => {
|
|
24074
24322
|
grid[0][labelColumns + i2] = title;
|
|
24075
24323
|
});
|
|
@@ -24082,17 +24330,17 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
|
24082
24330
|
if (entry3.kind === "leaf") {
|
|
24083
24331
|
entry3.path.forEach((_index, level) => {
|
|
24084
24332
|
const continued = entry3.path.slice(0, level + 1).every((p, i2) => p === previous[i2]);
|
|
24085
|
-
if (!continued) grid[1 + level][at2] =
|
|
24333
|
+
if (!continued) grid[1 + level][at2] = labelOf(columns.names[level], entry3.values[level]);
|
|
24086
24334
|
});
|
|
24087
24335
|
previous = entry3.path;
|
|
24088
24336
|
if (count2 > 1) measures2.forEach((measure2, m) => grid[rows - 1][at2 + m] = measure2.caption);
|
|
24089
24337
|
return;
|
|
24090
24338
|
}
|
|
24091
24339
|
const row3 = entry3.kind === "grand" ? 1 : entry3.path.length;
|
|
24092
|
-
const name3 = entry3.kind === "grand" ? "" : String(
|
|
24340
|
+
const name3 = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
|
|
24093
24341
|
measures2.forEach((measure2, m) => {
|
|
24094
|
-
const custom = entry3.fn ?
|
|
24095
|
-
grid[row3][at2 + m] = custom ? count2 === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure2.field}` : count2 === 1 ? entry3.kind === "grand" ?
|
|
24342
|
+
const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
|
|
24343
|
+
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}`;
|
|
24096
24344
|
});
|
|
24097
24345
|
});
|
|
24098
24346
|
return grid;
|
|
@@ -24125,7 +24373,6 @@ function pivotColumnItemsXml(entries, measures2, remap) {
|
|
|
24125
24373
|
}
|
|
24126
24374
|
|
|
24127
24375
|
// xlsx/pivot/nested.ts
|
|
24128
|
-
var label2 = pivotItemLabel;
|
|
24129
24376
|
var MAX_CELLS = 1e6;
|
|
24130
24377
|
var node = (index3, value2) => ({
|
|
24131
24378
|
index: index3,
|
|
@@ -24155,6 +24402,8 @@ function nestedPivotGrid(pivot) {
|
|
|
24155
24402
|
const labelColumns = compact3 ? 1 : levels;
|
|
24156
24403
|
const measures2 = pivotMeasures(pivot);
|
|
24157
24404
|
const functions = names.map((name3) => fieldSubtotalFunctions(pivot, name3));
|
|
24405
|
+
const caps = pivotCaptions(pivot);
|
|
24406
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24158
24407
|
const root = node(0, null);
|
|
24159
24408
|
for (const record2 of pivot.records) {
|
|
24160
24409
|
const keys = recordColumnKeys(record2, columnFields);
|
|
@@ -24181,7 +24430,7 @@ function nestedPivotGrid(pivot) {
|
|
|
24181
24430
|
}
|
|
24182
24431
|
const dimensions3 = pivotColumnDimensions(pivot, columns, labelColumns, onRows);
|
|
24183
24432
|
const rowTitles = names.map((name3) => name3);
|
|
24184
|
-
if (onRows) rowTitles.splice(valuesAt, 0,
|
|
24433
|
+
if (onRows) rowTitles.splice(valuesAt, 0, caps.values);
|
|
24185
24434
|
let values2 = [];
|
|
24186
24435
|
let indents = [];
|
|
24187
24436
|
const rowEntries = [];
|
|
@@ -24260,11 +24509,11 @@ function nestedPivotGrid(pivot) {
|
|
|
24260
24509
|
const children4 = [...group.children.values()].sort((a2, b) => a2.index - b.index);
|
|
24261
24510
|
children4.forEach((child7, position2) => {
|
|
24262
24511
|
const here = {
|
|
24263
|
-
labels: [...path2.labels,
|
|
24512
|
+
labels: [...path2.labels, labelOf(names[field2], child7.value)],
|
|
24264
24513
|
indices: [...path2.indices, child7.index],
|
|
24265
24514
|
firsts: [...path2.firsts, position2 === 0]
|
|
24266
24515
|
};
|
|
24267
|
-
const text8 =
|
|
24516
|
+
const text8 = labelOf(names[field2], child7.value);
|
|
24268
24517
|
if (last)
|
|
24269
24518
|
return push3(level, () => [
|
|
24270
24519
|
labelCells(path2, leafShown(here.firsts), level, text8),
|
|
@@ -24287,14 +24536,14 @@ function nestedPivotGrid(pivot) {
|
|
|
24287
24536
|
]);
|
|
24288
24537
|
if (own2 === "auto") {
|
|
24289
24538
|
if (showsValue) return;
|
|
24290
|
-
if (valuesAbove) subtotal(
|
|
24539
|
+
if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure2);
|
|
24291
24540
|
else measures2.forEach((one2, m) => subtotal(`${caption} ${one2.caption}`, void 0, m));
|
|
24292
24541
|
} else
|
|
24293
24542
|
for (const fn of own2)
|
|
24294
|
-
if (valuesAbove) subtotal(`${caption} ${
|
|
24543
|
+
if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure2);
|
|
24295
24544
|
else
|
|
24296
24545
|
measures2.forEach(
|
|
24297
|
-
(one2, m) => subtotal(`${caption} ${
|
|
24546
|
+
(one2, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one2.field}`, fn, m)
|
|
24298
24547
|
);
|
|
24299
24548
|
});
|
|
24300
24549
|
};
|
|
@@ -24305,12 +24554,12 @@ function nestedPivotGrid(pivot) {
|
|
|
24305
24554
|
]);
|
|
24306
24555
|
const build2 = () => {
|
|
24307
24556
|
walk2(0, root, void 0, { labels: [], indices: [], firsts: [] });
|
|
24308
|
-
if (onRows) measures2.forEach((one2, m) => grand(
|
|
24309
|
-
else grand(
|
|
24557
|
+
if (onRows) measures2.forEach((one2, m) => grand(fillCaption(caps.measureTotal, one2.caption), m));
|
|
24558
|
+
else grand(caps.grandTotal);
|
|
24310
24559
|
};
|
|
24311
24560
|
build2();
|
|
24312
24561
|
counting = false;
|
|
24313
|
-
values2 = pivotColumnHeaders(pivot, columns, compact3 ? [
|
|
24562
|
+
values2 = pivotColumnHeaders(pivot, columns, compact3 ? [caps.rowLabels] : rowTitles, onRows);
|
|
24314
24563
|
const firstDataRow = values2.length;
|
|
24315
24564
|
indents = values2.map(() => 0);
|
|
24316
24565
|
build2();
|
|
@@ -24343,14 +24592,14 @@ function pivotTableAt(sheet, at2) {
|
|
|
24343
24592
|
var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
24344
24593
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
24345
24594
|
var TABLE = {
|
|
24346
|
-
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",
|
|
24595
|
+
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",
|
|
24347
24596
|
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
24348
24597
|
pageFields: "count",
|
|
24349
24598
|
pageField: "fld item hier",
|
|
24350
24599
|
pivotFields: "count",
|
|
24351
24600
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal numFmtId sumSubtotal countASubtotal avgSubtotal maxSubtotal minSubtotal productSubtotal countSubtotal stdDevSubtotal stdDevPSubtotal varSubtotal varPSubtotal",
|
|
24352
24601
|
items: "count",
|
|
24353
|
-
item: "x t h",
|
|
24602
|
+
item: "x t h n",
|
|
24354
24603
|
rowFields: "count",
|
|
24355
24604
|
colFields: "count",
|
|
24356
24605
|
field: "x",
|
|
@@ -24451,8 +24700,8 @@ function inspect(node3, profile, cache3) {
|
|
|
24451
24700
|
}
|
|
24452
24701
|
for (const child7 of elements(node3)) inspect(child7, profile, cache3);
|
|
24453
24702
|
}
|
|
24454
|
-
function assertPivotAdmission(
|
|
24455
|
-
inspect(
|
|
24703
|
+
function assertPivotAdmission(table4, cache3) {
|
|
24704
|
+
inspect(table4, TABLE, false);
|
|
24456
24705
|
inspect(cache3, CACHE, true);
|
|
24457
24706
|
}
|
|
24458
24707
|
function assertPivotRecords(records) {
|
|
@@ -24463,6 +24712,121 @@ function assertPivotRecords(records) {
|
|
|
24463
24712
|
);
|
|
24464
24713
|
}
|
|
24465
24714
|
|
|
24715
|
+
// xlsx/pivot/captions-read.ts
|
|
24716
|
+
var ATTRIBUTES2 = {
|
|
24717
|
+
rowHeaderCaption: "rowLabels",
|
|
24718
|
+
colHeaderCaption: "columnLabels",
|
|
24719
|
+
grandTotalCaption: "grandTotal",
|
|
24720
|
+
dataCaption: "values"
|
|
24721
|
+
};
|
|
24722
|
+
function readPivotCaptionAttributes(root) {
|
|
24723
|
+
const out = {};
|
|
24724
|
+
for (const [attribute4, key2] of Object.entries(ATTRIBUTES2)) {
|
|
24725
|
+
const text8 = att(root, attribute4);
|
|
24726
|
+
if (text8 !== void 0)
|
|
24727
|
+
out[key2] = decodeEscapes(text8);
|
|
24728
|
+
}
|
|
24729
|
+
return out;
|
|
24730
|
+
}
|
|
24731
|
+
function aggregateCaptionsOf(pivot) {
|
|
24732
|
+
const out = {};
|
|
24733
|
+
for (const measure2 of [
|
|
24734
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
24735
|
+
...pivot.additionalValues ?? []
|
|
24736
|
+
]) {
|
|
24737
|
+
const at2 = measure2.caption.indexOf(measure2.field);
|
|
24738
|
+
if (at2 < 0 || measure2.caption === measure2.field) continue;
|
|
24739
|
+
const template = `${measure2.caption.slice(0, at2)}{0}${measure2.caption.slice(at2 + measure2.field.length)}`;
|
|
24740
|
+
if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure2.aggregate])
|
|
24741
|
+
out[measure2.aggregate] = template;
|
|
24742
|
+
}
|
|
24743
|
+
return Object.keys(out).length ? out : void 0;
|
|
24744
|
+
}
|
|
24745
|
+
var MARK = "";
|
|
24746
|
+
var SENTINELS = {
|
|
24747
|
+
rowLabels: `${MARK}R`,
|
|
24748
|
+
columnLabels: `${MARK}C`,
|
|
24749
|
+
grandTotal: `${MARK}G`,
|
|
24750
|
+
values: `${MARK}V`,
|
|
24751
|
+
all: `${MARK}A`,
|
|
24752
|
+
blank: `${MARK}B`,
|
|
24753
|
+
subtotal: `{0}${MARK}S`,
|
|
24754
|
+
measureTotal: `${MARK}M{0}`,
|
|
24755
|
+
functions: Object.fromEntries(
|
|
24756
|
+
Object.keys(ENGLISH_PIVOT_CAPTIONS.functions).map((fn) => [fn, `${MARK}F${fn}`])
|
|
24757
|
+
),
|
|
24758
|
+
aggregates: ENGLISH_PIVOT_CAPTIONS.aggregates
|
|
24759
|
+
};
|
|
24760
|
+
function templateOf(cached6, arg) {
|
|
24761
|
+
if (!arg || !cached6.includes(arg)) return void 0;
|
|
24762
|
+
if (cached6.startsWith(arg)) return `{0}${cached6.slice(arg.length)}`;
|
|
24763
|
+
if (cached6.endsWith(arg)) return `${cached6.slice(0, -arg.length)}{0}`;
|
|
24764
|
+
const at2 = cached6.indexOf(arg);
|
|
24765
|
+
return `${cached6.slice(0, at2)}{0}${cached6.slice(at2 + arg.length)}`;
|
|
24766
|
+
}
|
|
24767
|
+
function inferPivotCaptions(pivot, sheet, named3) {
|
|
24768
|
+
const known = pivotCaptions({ captions: named3 });
|
|
24769
|
+
const probe = { ...SENTINELS };
|
|
24770
|
+
for (const key2 of Object.keys(named3))
|
|
24771
|
+
if (typeof named3[key2] === "string")
|
|
24772
|
+
probe[key2] = known[key2];
|
|
24773
|
+
const grid = pivotGrid({ ...pivot, captions: probe });
|
|
24774
|
+
const found = /* @__PURE__ */ new Map();
|
|
24775
|
+
const set = (key2, value2) => {
|
|
24776
|
+
if (value2 === void 0) return;
|
|
24777
|
+
const before = found.get(key2);
|
|
24778
|
+
found.set(key2, before === void 0 || before === value2 ? value2 : null);
|
|
24779
|
+
};
|
|
24780
|
+
grid.values.forEach(
|
|
24781
|
+
(line3, r) => line3.forEach((expected, c2) => {
|
|
24782
|
+
if (typeof expected !== "string" || !expected.includes(MARK)) return;
|
|
24783
|
+
const cached6 = getCell(
|
|
24784
|
+
sheet,
|
|
24785
|
+
pivot.location.start.row + r,
|
|
24786
|
+
pivot.location.start.col + c2
|
|
24787
|
+
)?.value;
|
|
24788
|
+
if (typeof cached6 !== "string") return;
|
|
24789
|
+
const kind = /\u0001([RCGVASMFB])(\w*)/.exec(expected);
|
|
24790
|
+
if (!kind) return;
|
|
24791
|
+
const at2 = kind.index;
|
|
24792
|
+
switch (kind[1]) {
|
|
24793
|
+
case "R":
|
|
24794
|
+
return set("rowLabels", cached6);
|
|
24795
|
+
case "C":
|
|
24796
|
+
return set("columnLabels", cached6);
|
|
24797
|
+
case "G":
|
|
24798
|
+
return set("grandTotal", cached6);
|
|
24799
|
+
case "V":
|
|
24800
|
+
return set("values", cached6);
|
|
24801
|
+
case "A":
|
|
24802
|
+
return set("all", cached6);
|
|
24803
|
+
case "B":
|
|
24804
|
+
return set("blank", cached6);
|
|
24805
|
+
case "S":
|
|
24806
|
+
return set("subtotal", templateOf(cached6, expected.slice(0, at2)));
|
|
24807
|
+
case "M":
|
|
24808
|
+
return set("measureTotal", templateOf(cached6, expected.slice(at2 + 2)));
|
|
24809
|
+
case "F": {
|
|
24810
|
+
const item = expected.slice(0, at2 - 1);
|
|
24811
|
+
const of = / of (.*)$/.exec(expected.slice(at2));
|
|
24812
|
+
const word = cached6.slice(item.length + 1, of ? cached6.length - of[0].length : void 0);
|
|
24813
|
+
if (cached6.startsWith(`${item} `) && (!of || cached6.endsWith(of[0])))
|
|
24814
|
+
set(`function:${kind[2]}`, word);
|
|
24815
|
+
}
|
|
24816
|
+
}
|
|
24817
|
+
})
|
|
24818
|
+
);
|
|
24819
|
+
const out = pivotCaptions({ captions: named3 });
|
|
24820
|
+
const functions = { ...out.functions };
|
|
24821
|
+
for (const [key2, value2] of found) {
|
|
24822
|
+
if (value2 === null) continue;
|
|
24823
|
+
if (key2.startsWith("function:")) functions[key2.slice(9)] = value2;
|
|
24824
|
+
else out[key2] = value2;
|
|
24825
|
+
}
|
|
24826
|
+
out.functions = functions;
|
|
24827
|
+
return trimmedCaptions(out);
|
|
24828
|
+
}
|
|
24829
|
+
|
|
24466
24830
|
// xlsx/slicer/read-slicers.ts
|
|
24467
24831
|
var TABLE_SLICER_URI = "{2F2917AC-EB37-4324-AD4E-5DD8C200BD13}";
|
|
24468
24832
|
var X152 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
@@ -24538,12 +24902,12 @@ function parseSlicerCache(xml, partName) {
|
|
|
24538
24902
|
if (data) return void 0;
|
|
24539
24903
|
const list2 = byLocal(root, "extLst");
|
|
24540
24904
|
const ext = list2 ? elements(list2).find((node3) => node3.getAttribute("uri") === TABLE_SLICER_URI) : void 0;
|
|
24541
|
-
const
|
|
24542
|
-
const tableId = numAttr(
|
|
24543
|
-
const column2 = numAttr(
|
|
24544
|
-
if (!
|
|
24905
|
+
const table4 = ext ? first(ext, "tableSlicerCache", X152) : void 0;
|
|
24906
|
+
const tableId = numAttr(table4, "tableId");
|
|
24907
|
+
const column2 = numAttr(table4, "column");
|
|
24908
|
+
if (!table4 || tableId === void 0 || column2 === void 0) return void 0;
|
|
24545
24909
|
const cache3 = { ...common, source: { kind: "table", tableId, column: column2 } };
|
|
24546
|
-
if (att(
|
|
24910
|
+
if (att(table4, "sortOrder") === "descending") cache3.sortOrder = "descending";
|
|
24547
24911
|
if (elements(root).some((node3) => node3.localName === "pivotTables")) return void 0;
|
|
24548
24912
|
return cache3;
|
|
24549
24913
|
}
|
|
@@ -24628,14 +24992,14 @@ function parseTimelineCache(xml, partName) {
|
|
|
24628
24992
|
}
|
|
24629
24993
|
|
|
24630
24994
|
// xlsx/slicer/table-filter.ts
|
|
24631
|
-
function tableFilterBounds(
|
|
24995
|
+
function tableFilterBounds(table4) {
|
|
24632
24996
|
return {
|
|
24633
|
-
start:
|
|
24634
|
-
end: { ...
|
|
24997
|
+
start: table4.range.start,
|
|
24998
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
24635
24999
|
};
|
|
24636
25000
|
}
|
|
24637
|
-
function tableAutoFilter(
|
|
24638
|
-
const columns =
|
|
25001
|
+
function tableAutoFilter(table4) {
|
|
25002
|
+
const columns = table4.columns.flatMap(
|
|
24639
25003
|
(column2, offset2) => column2.filter ? [
|
|
24640
25004
|
{
|
|
24641
25005
|
offset: offset2,
|
|
@@ -24645,12 +25009,12 @@ function tableAutoFilter(table3) {
|
|
|
24645
25009
|
] : []
|
|
24646
25010
|
);
|
|
24647
25011
|
if (!columns.length) return void 0;
|
|
24648
|
-
return { range: tableFilterBounds(
|
|
25012
|
+
return { range: tableFilterBounds(table4), columns };
|
|
24649
25013
|
}
|
|
24650
|
-
function applyTableFilter(workbook, sheet,
|
|
24651
|
-
if (!
|
|
24652
|
-
const bounds2 = tableFilterBounds(
|
|
24653
|
-
const filter2 = tableAutoFilter(
|
|
25014
|
+
function applyTableFilter(workbook, sheet, table4) {
|
|
25015
|
+
if (!table4.headerRow) return;
|
|
25016
|
+
const bounds2 = tableFilterBounds(table4);
|
|
25017
|
+
const filter2 = tableAutoFilter(table4);
|
|
24654
25018
|
for (let row3 = bounds2.start.row + 1; row3 <= bounds2.end.row; row3++) {
|
|
24655
25019
|
const visible = !filter2 || rowMatchesFilter(workbook, sheet, row3, filter2);
|
|
24656
25020
|
setRowFiltered(sheet, row3, !visible, !!filter2);
|
|
@@ -24658,8 +25022,8 @@ function applyTableFilter(workbook, sheet, table3) {
|
|
|
24658
25022
|
}
|
|
24659
25023
|
function readTableFilteredRows(workbook) {
|
|
24660
25024
|
for (const sheet of workbook.sheets)
|
|
24661
|
-
for (const
|
|
24662
|
-
const filter2 = tableAutoFilter(
|
|
25025
|
+
for (const table4 of sheet.tables) {
|
|
25026
|
+
const filter2 = tableAutoFilter(table4);
|
|
24663
25027
|
if (!filter2) continue;
|
|
24664
25028
|
for (let row3 = filter2.range.start.row + 1; row3 <= filter2.range.end.row; row3++) {
|
|
24665
25029
|
const info = sheet.rowInfo.get(row3);
|
|
@@ -24778,9 +25142,9 @@ function settleSlicers(workbook, warn) {
|
|
|
24778
25142
|
if (cache3.source.kind === "table") {
|
|
24779
25143
|
const { tableId, column: column2 } = cache3.source;
|
|
24780
25144
|
for (const sheet of workbook.sheets) {
|
|
24781
|
-
const
|
|
24782
|
-
if (
|
|
24783
|
-
return
|
|
25145
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === tableId);
|
|
25146
|
+
if (table4)
|
|
25147
|
+
return table4.headerRow && !table4.filterNotModeled && table4.columns.some((entry3) => entry3.sourceId === column2);
|
|
24784
25148
|
}
|
|
24785
25149
|
return false;
|
|
24786
25150
|
}
|
|
@@ -24958,7 +25322,7 @@ function readFieldGroups(fields, names) {
|
|
|
24958
25322
|
throw new Error("Unsupported pivot field group");
|
|
24959
25323
|
const labels = children(list2, "s", NS.x).map((node3) => decodeEscapes(att(node3, "v") ?? ""));
|
|
24960
25324
|
const expected = numberGroupLabels({ start, end, by });
|
|
24961
|
-
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((
|
|
25325
|
+
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((label2, i2) => label2 !== expected[i2]))
|
|
24962
25326
|
throw new Error("Unsupported pivot group items");
|
|
24963
25327
|
groups.push({ field: names[index3] ?? "", start, end, by });
|
|
24964
25328
|
});
|
|
@@ -25042,7 +25406,7 @@ function readDateGroups(fields, count2, names, dateFields, records, date1904) {
|
|
|
25042
25406
|
const node3 = first(first(entry3.node, "fieldGroup", NS.x), "groupItems", NS.x);
|
|
25043
25407
|
const actual = children(node3, "s", NS.x).map((item) => decodeEscapes(att(item, "v") ?? ""));
|
|
25044
25408
|
const name3 = decodeEscapes(att(entry3.node, "name") ?? "");
|
|
25045
|
-
if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((
|
|
25409
|
+
if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((label2) => !label2) || new Set(actual).size !== actual.length)
|
|
25046
25410
|
throw unsupported("group items");
|
|
25047
25411
|
if (name3 !== dateGroupFieldName(entry3.unit, field2) || actual.some((l, i2) => l !== labels[i2]))
|
|
25048
25412
|
localized[entry3.unit] = { name: name3, labels: actual };
|
|
@@ -25100,6 +25464,25 @@ function readItemFilters(fields, names, shared) {
|
|
|
25100
25464
|
return filters.length ? filters : void 0;
|
|
25101
25465
|
}
|
|
25102
25466
|
|
|
25467
|
+
// xlsx/pivot/item-names-read.ts
|
|
25468
|
+
function readItemNames(tableFields, names, shared) {
|
|
25469
|
+
const out = [];
|
|
25470
|
+
tableFields.forEach((field2, index3) => {
|
|
25471
|
+
const list2 = first(field2, "items", NS.x);
|
|
25472
|
+
if (!list2 || index3 >= names.length) return;
|
|
25473
|
+
for (const item of children(list2, "item", NS.x)) {
|
|
25474
|
+
const name3 = att(item, "n");
|
|
25475
|
+
if (name3 === void 0) continue;
|
|
25476
|
+
const at2 = Number(att(item, "x"));
|
|
25477
|
+
const value2 = shared[index3]?.[at2];
|
|
25478
|
+
if (att(item, "t") !== void 0 || !Number.isInteger(at2) || value2 === void 0)
|
|
25479
|
+
throw new Error("Unsupported pivot item name");
|
|
25480
|
+
out.push({ field: names[index3], item: value2, name: decodeEscapes(name3) });
|
|
25481
|
+
}
|
|
25482
|
+
});
|
|
25483
|
+
return out;
|
|
25484
|
+
}
|
|
25485
|
+
|
|
25103
25486
|
// xlsx/pivot/values-axis.ts
|
|
25104
25487
|
function remapPivotRowEntries(entries, axes2) {
|
|
25105
25488
|
return entries.map(
|
|
@@ -25222,7 +25605,10 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25222
25605
|
};
|
|
25223
25606
|
const rowAxes = pivotRowFields(pivot).map((name3) => axisValues(name3, "axisRow")), rowItems = read("rowItems");
|
|
25224
25607
|
const grid = pivotGrid(pivot);
|
|
25225
|
-
const
|
|
25608
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
25609
|
+
const levelAxes = [...rowAxes];
|
|
25610
|
+
if (valuesAt >= 0) levelAxes.splice(valuesAt, 0, null);
|
|
25611
|
+
const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, levelAxes) : [
|
|
25226
25612
|
...rowAxes[0].map((index3) => ({ indices: [index3] })),
|
|
25227
25613
|
{ indices: [0], type: "grand" }
|
|
25228
25614
|
];
|
|
@@ -25232,11 +25618,11 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25232
25618
|
const expected2 = entries[i2];
|
|
25233
25619
|
const xs = children(item, "x", NS.x).map((x) => integer3(x.getAttribute("v"), 0)), prefix3 = integer3(item.getAttribute("r"), 0);
|
|
25234
25620
|
const type = expected2.type === void 0 || expected2.type === "default" || expected2.type === "grand" ? expected2.type : PIVOT_SUBTOTALS[expected2.type].item;
|
|
25235
|
-
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))
|
|
25621
|
+
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))
|
|
25236
25622
|
throw new Error("Unmodeled page row item");
|
|
25237
25623
|
previousRow = expected2.type === "grand" ? [] : expected2.indices;
|
|
25238
25624
|
});
|
|
25239
|
-
const measures2 = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25625
|
+
const measures2 = valuesAt >= 0 ? 1 : 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25240
25626
|
if (columns)
|
|
25241
25627
|
for (const col of columns)
|
|
25242
25628
|
for (let m = 0; m < measures2; m++) expected.push(measures2 > 1 ? [col, m] : [col]);
|
|
@@ -25278,6 +25664,10 @@ function value(node3, date1904 = false) {
|
|
|
25278
25664
|
if (node3.localName === "e" && isErrorCode(v)) return { error: v };
|
|
25279
25665
|
throw new Error("Unsupported pivot cache item");
|
|
25280
25666
|
}
|
|
25667
|
+
var namedAggregates = (pivot) => {
|
|
25668
|
+
const aggregates = aggregateCaptionsOf(pivot);
|
|
25669
|
+
return aggregates ? { aggregates } : {};
|
|
25670
|
+
};
|
|
25281
25671
|
function readOne(workbook, source2, part) {
|
|
25282
25672
|
const xml = source2.text(part);
|
|
25283
25673
|
const root = parseXml(xml).documentElement;
|
|
@@ -25424,6 +25814,7 @@ function readOne(workbook, source2, part) {
|
|
|
25424
25814
|
location.start.row -= 2;
|
|
25425
25815
|
}
|
|
25426
25816
|
const itemFilters = readItemFilters(tableFields, names, shared);
|
|
25817
|
+
const itemNames = readItemNames(tableFields, names, shared);
|
|
25427
25818
|
const slicerCacheId = readSlicerCacheId(cache3);
|
|
25428
25819
|
const fieldGroups = readFieldGroups(fields, names);
|
|
25429
25820
|
const dateFields = readDateFields(fields, names);
|
|
@@ -25462,6 +25853,7 @@ function readOne(workbook, source2, part) {
|
|
|
25462
25853
|
const pivot = {
|
|
25463
25854
|
...pageFilter ? { pageFilter } : {},
|
|
25464
25855
|
...itemFilters ? { itemFilters } : {},
|
|
25856
|
+
...itemNames.length ? { itemNames } : {},
|
|
25465
25857
|
...fieldGroups.length ? { fieldGroups } : {},
|
|
25466
25858
|
...dateFields.length ? { dateFields } : {},
|
|
25467
25859
|
...dateGroups.length ? { dateGroups } : {},
|
|
@@ -25504,6 +25896,12 @@ function readOne(workbook, source2, part) {
|
|
|
25504
25896
|
...col ? { columnField: col } : {},
|
|
25505
25897
|
...moreColumns.length ? { moreColumnFields: moreColumns } : {}
|
|
25506
25898
|
};
|
|
25899
|
+
const captions = trimmedCaptions(
|
|
25900
|
+
pivotCaptions({
|
|
25901
|
+
captions: { ...readPivotCaptionAttributes(root), ...namedAggregates(pivot) }
|
|
25902
|
+
})
|
|
25903
|
+
);
|
|
25904
|
+
if (captions) pivot.captions = captions;
|
|
25507
25905
|
if (pageFilter && moreColumns.length) throw new Error("Report filters support one column field");
|
|
25508
25906
|
assertPageAxisItems(root, pivot, shared, cache3, recordRoot);
|
|
25509
25907
|
return pivot;
|
|
@@ -25531,6 +25929,12 @@ function readPivotTables(workbook, source2, warn, slicers) {
|
|
|
25531
25929
|
if (slicers.blocked.has(pivotKey(sheet.sheetId, name3)) || cache3 && (caches2.get(cache3) ?? 0) > 1)
|
|
25532
25930
|
throw new Error("Shared pivot cache or unsupported slicer connection");
|
|
25533
25931
|
const pivot = readOne(workbook, source2, part);
|
|
25932
|
+
const inferred = inferPivotCaptions(pivot, sheet, {
|
|
25933
|
+
...readPivotCaptionAttributes(parseXml(pivot.sourceXml).documentElement),
|
|
25934
|
+
...namedAggregates(pivot)
|
|
25935
|
+
});
|
|
25936
|
+
if (inferred) pivot.captions = inferred;
|
|
25937
|
+
else delete pivot.captions;
|
|
25534
25938
|
const grid = pivotGrid(pivot);
|
|
25535
25939
|
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(
|
|
25536
25940
|
(line3, r) => line3.some(
|
|
@@ -26170,7 +26574,7 @@ function mergeSpacedAreas(tokens3) {
|
|
|
26170
26574
|
}
|
|
26171
26575
|
return out;
|
|
26172
26576
|
}
|
|
26173
|
-
function
|
|
26577
|
+
function templateOf2(formula) {
|
|
26174
26578
|
const cached6 = templates.get(formula);
|
|
26175
26579
|
if (cached6 !== void 0) return cached6;
|
|
26176
26580
|
const raw2 = safeTokens(formula);
|
|
@@ -26200,7 +26604,7 @@ function templateOf(formula) {
|
|
|
26200
26604
|
return template;
|
|
26201
26605
|
}
|
|
26202
26606
|
function rewriteTemplate(formula, rewrite2) {
|
|
26203
|
-
const template =
|
|
26607
|
+
const template = templateOf2(formula);
|
|
26204
26608
|
if (!template) return formula;
|
|
26205
26609
|
let next;
|
|
26206
26610
|
for (let i2 = 0; i2 < template.length; i2++) {
|
|
@@ -27501,14 +27905,14 @@ function readDataTable(f6) {
|
|
|
27501
27905
|
const ref = parseRange(att(f6, "ref") ?? "");
|
|
27502
27906
|
const r1 = att(f6, "r1");
|
|
27503
27907
|
if (!ref || !r1) return void 0;
|
|
27504
|
-
const
|
|
27908
|
+
const table4 = { ref, r1 };
|
|
27505
27909
|
const r2 = att(f6, "r2");
|
|
27506
|
-
if (r2)
|
|
27507
|
-
if (boolAttr(f6, "dt2D"))
|
|
27508
|
-
if (boolAttr(f6, "dtr"))
|
|
27509
|
-
if (boolAttr(f6, "del1"))
|
|
27510
|
-
if (boolAttr(f6, "del2"))
|
|
27511
|
-
return
|
|
27910
|
+
if (r2) table4.r2 = r2;
|
|
27911
|
+
if (boolAttr(f6, "dt2D")) table4.dt2D = true;
|
|
27912
|
+
if (boolAttr(f6, "dtr")) table4.dtr = true;
|
|
27913
|
+
if (boolAttr(f6, "del1")) table4.del1 = true;
|
|
27914
|
+
if (boolAttr(f6, "del2")) table4.del2 = true;
|
|
27915
|
+
return table4;
|
|
27512
27916
|
}
|
|
27513
27917
|
function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet) {
|
|
27514
27918
|
const kind = att(f6, "t") ?? "normal";
|
|
@@ -27532,8 +27936,8 @@ function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet
|
|
|
27532
27936
|
}
|
|
27533
27937
|
if (kind === "dataTable") {
|
|
27534
27938
|
delete cell.legacyFormula;
|
|
27535
|
-
const
|
|
27536
|
-
if (
|
|
27939
|
+
const table4 = readDataTable(f6);
|
|
27940
|
+
if (table4) (sheet.dataTables ??= []).push(table4);
|
|
27537
27941
|
else ctx.warn("A what-if data table formula could not be read; its cached values were kept.");
|
|
27538
27942
|
return;
|
|
27539
27943
|
}
|
|
@@ -27725,14 +28129,14 @@ function parseTable3(xml, partName) {
|
|
|
27725
28129
|
if (id3 !== void 0 && Number.isInteger(id3) && id3 >= 0) column2.sourceId = id3;
|
|
27726
28130
|
const fn = att(node3, "totalsRowFunction");
|
|
27727
28131
|
if (fn && fn !== "none") column2.totalsRowFunction = fn;
|
|
27728
|
-
const
|
|
27729
|
-
if (
|
|
28132
|
+
const label2 = att(node3, "totalsRowLabel");
|
|
28133
|
+
if (label2 !== void 0) column2.totalsRowLabel = label2;
|
|
27730
28134
|
const calculated = xFirst(node3, "calculatedColumnFormula");
|
|
27731
28135
|
if (calculated) column2.calculatedColumnFormula = stripFuturePrefixes(xText(calculated));
|
|
27732
28136
|
return column2;
|
|
27733
28137
|
}
|
|
27734
28138
|
);
|
|
27735
|
-
const
|
|
28139
|
+
const table4 = {
|
|
27736
28140
|
id: numAttr(root, "id") ?? 1,
|
|
27737
28141
|
name: name3,
|
|
27738
28142
|
displayName: att(root, "displayName") ?? name3,
|
|
@@ -27742,26 +28146,26 @@ function parseTable3(xml, partName) {
|
|
|
27742
28146
|
columns,
|
|
27743
28147
|
partName
|
|
27744
28148
|
};
|
|
27745
|
-
readColumnFilters(root,
|
|
28149
|
+
readColumnFilters(root, table4);
|
|
27746
28150
|
const info = xFirst(root, "tableStyleInfo");
|
|
27747
28151
|
if (info) {
|
|
27748
28152
|
const style3 = att(info, "name");
|
|
27749
|
-
if (style3)
|
|
27750
|
-
|
|
27751
|
-
|
|
27752
|
-
|
|
27753
|
-
|
|
28153
|
+
if (style3) table4.styleName = style3;
|
|
28154
|
+
table4.showRowStripes = boolAttr(info, "showRowStripes", false);
|
|
28155
|
+
table4.showColumnStripes = boolAttr(info, "showColumnStripes", false);
|
|
28156
|
+
table4.showFirstColumn = boolAttr(info, "showFirstColumn", false);
|
|
28157
|
+
table4.showLastColumn = boolAttr(info, "showLastColumn", false);
|
|
27754
28158
|
}
|
|
27755
|
-
return
|
|
28159
|
+
return table4;
|
|
27756
28160
|
}
|
|
27757
|
-
function readColumnFilters(root,
|
|
28161
|
+
function readColumnFilters(root, table4) {
|
|
27758
28162
|
const filter2 = xFirst(root, "autoFilter");
|
|
27759
28163
|
for (const node3 of filter2 ? xChildren(filter2, "filterColumn") : []) {
|
|
27760
|
-
const column2 =
|
|
28164
|
+
const column2 = table4.columns[numAttr(node3, "colId") ?? -1];
|
|
27761
28165
|
const filters = xChildren(node3, "filters");
|
|
27762
28166
|
const simple = column2 && isValueListFilterColumn(node3);
|
|
27763
28167
|
if (!simple) {
|
|
27764
|
-
|
|
28168
|
+
table4.filterNotModeled = true;
|
|
27765
28169
|
continue;
|
|
27766
28170
|
}
|
|
27767
28171
|
const values2 = xChildren(filters[0], "filter").map((child7) => att(child7, "val") ?? "");
|
|
@@ -27840,8 +28244,8 @@ function readTables(ctx, partName, node3, sheet) {
|
|
|
27840
28244
|
const rel = rels.get(relAttr(part, "id") ?? "");
|
|
27841
28245
|
const target2 = rel ? ctx.source.target(partName, rel) : void 0;
|
|
27842
28246
|
const xml = target2 ? ctx.source.text(target2) : void 0;
|
|
27843
|
-
const
|
|
27844
|
-
if (
|
|
28247
|
+
const table4 = target2 && xml ? parseTable3(xml, target2) : void 0;
|
|
28248
|
+
if (table4) sheet.tables.push(table4);
|
|
27845
28249
|
else ctx.warn("A table part could not be read and was dropped.");
|
|
27846
28250
|
}
|
|
27847
28251
|
}
|
|
@@ -30311,14 +30715,14 @@ function unique(args, ctx) {
|
|
|
30311
30715
|
const byCol = args.length > 1 && args[1] !== null && toBool(ctx.toScalar(args[1] ?? null));
|
|
30312
30716
|
const once = args.length > 2 && args[2] !== null && toBool(ctx.toScalar(args[2] ?? null));
|
|
30313
30717
|
if (byCol) m = transpose(m);
|
|
30314
|
-
const
|
|
30718
|
+
const keyOf3 = (row3) => JSON.stringify(
|
|
30315
30719
|
row3.map(
|
|
30316
30720
|
(v) => isError(v) ? `#${v.error}` : typeof v === "string" ? `s${v.toLowerCase()}` : v
|
|
30317
30721
|
)
|
|
30318
30722
|
);
|
|
30319
30723
|
const counts = /* @__PURE__ */ new Map();
|
|
30320
30724
|
for (const row3 of m.data) {
|
|
30321
|
-
const key2 =
|
|
30725
|
+
const key2 = keyOf3(row3);
|
|
30322
30726
|
const entry3 = counts.get(key2);
|
|
30323
30727
|
if (entry3) entry3.count++;
|
|
30324
30728
|
else counts.set(key2, { row: row3, count: 1 });
|
|
@@ -30603,30 +31007,30 @@ function gammaLn(z) {
|
|
|
30603
31007
|
|
|
30604
31008
|
// xlsx/formula/functions/database.ts
|
|
30605
31009
|
var C3 = "Database";
|
|
30606
|
-
var
|
|
31010
|
+
var label = (value2) => value2 === null ? "" : typeof value2 === "string" ? value2 : String(value2);
|
|
30607
31011
|
function tableOf(ctx, value2) {
|
|
30608
31012
|
const [head, ...records] = ctx.toMatrix(value2 ?? null).data;
|
|
30609
31013
|
if (!head || records.length === 0) fail(ERR.VALUE);
|
|
30610
|
-
return { headers: head.map((v) =>
|
|
31014
|
+
return { headers: head.map((v) => label(v).toLowerCase()), records };
|
|
30611
31015
|
}
|
|
30612
|
-
function fieldIndex(
|
|
31016
|
+
function fieldIndex(table4, field2) {
|
|
30613
31017
|
const value2 = scalar2(field2);
|
|
30614
31018
|
if (isError(value2)) fail(value2);
|
|
30615
31019
|
if (typeof value2 === "number") {
|
|
30616
31020
|
const index4 = Math.trunc(value2) - 1;
|
|
30617
|
-
if (index4 < 0 || index4 >=
|
|
31021
|
+
if (index4 < 0 || index4 >= table4.headers.length) fail(ERR.VALUE);
|
|
30618
31022
|
return index4;
|
|
30619
31023
|
}
|
|
30620
|
-
const index3 =
|
|
31024
|
+
const index3 = table4.headers.indexOf(label(value2).toLowerCase());
|
|
30621
31025
|
if (index3 < 0) fail(ERR.VALUE);
|
|
30622
31026
|
return index3;
|
|
30623
31027
|
}
|
|
30624
|
-
function recordFilter(
|
|
31028
|
+
function recordFilter(table4, criteria) {
|
|
30625
31029
|
const [head, ...rows] = criteria;
|
|
30626
31030
|
if (!head || rows.length === 0) fail(ERR.VALUE);
|
|
30627
31031
|
const columns = head.map((name3) => {
|
|
30628
31032
|
if (name3 === null || name3 === "") return -1;
|
|
30629
|
-
return
|
|
31033
|
+
return table4.headers.indexOf(label(name3).toLowerCase());
|
|
30630
31034
|
});
|
|
30631
31035
|
const alternatives = rows.map(
|
|
30632
31036
|
(row3) => row3.flatMap((cell, c2) => {
|
|
@@ -30640,10 +31044,10 @@ function recordFilter(table3, criteria) {
|
|
|
30640
31044
|
return (record2) => alternatives.some((tests) => tests.every((test) => test(record2)));
|
|
30641
31045
|
}
|
|
30642
31046
|
function selected(ctx, args) {
|
|
30643
|
-
const
|
|
30644
|
-
const column2 = fieldIndex(
|
|
30645
|
-
const matches2 = recordFilter(
|
|
30646
|
-
return
|
|
31047
|
+
const table4 = tableOf(ctx, args[0]);
|
|
31048
|
+
const column2 = fieldIndex(table4, args[1]);
|
|
31049
|
+
const matches2 = recordFilter(table4, ctx.toMatrix(args[2] ?? null).data);
|
|
31050
|
+
return table4.records.filter(matches2).map((record2) => record2[column2] ?? null);
|
|
30647
31051
|
}
|
|
30648
31052
|
var numbers = (values2) => {
|
|
30649
31053
|
for (const v of values2) if (isError(v)) fail(v);
|
|
@@ -31471,9 +31875,9 @@ var BESSEL_FUNCTIONS = [
|
|
|
31471
31875
|
];
|
|
31472
31876
|
|
|
31473
31877
|
// xlsx/formula/functions/convert.ts
|
|
31474
|
-
var
|
|
31878
|
+
var table2 = /* @__PURE__ */ new Map();
|
|
31475
31879
|
var add3 = (dimension3, names, factor, extra = {}) => {
|
|
31476
|
-
for (const name3 of names)
|
|
31880
|
+
for (const name3 of names) table2.set(name3, { dimension: dimension3, factor, ...extra });
|
|
31477
31881
|
};
|
|
31478
31882
|
add3("mass", ["g"], 1, { prefix: "metric" });
|
|
31479
31883
|
add3("mass", ["sg"], 14593.9029372064);
|
|
@@ -31604,10 +32008,10 @@ var BINARY2 = {
|
|
|
31604
32008
|
ki: 2 ** 10
|
|
31605
32009
|
};
|
|
31606
32010
|
function resolve(name3) {
|
|
31607
|
-
const direct =
|
|
32011
|
+
const direct = table2.get(name3);
|
|
31608
32012
|
if (direct) return { dimension: direct.dimension, factor: direct.factor };
|
|
31609
32013
|
for (const length of [2, 1]) {
|
|
31610
|
-
const unit3 =
|
|
32014
|
+
const unit3 = table2.get(name3.slice(length));
|
|
31611
32015
|
const prefix3 = name3.slice(0, length);
|
|
31612
32016
|
if (!unit3?.prefix) continue;
|
|
31613
32017
|
const scale2 = (unit3.prefix === "binary" ? BINARY2[prefix3] : void 0) ?? METRIC[prefix3];
|
|
@@ -32942,30 +33346,30 @@ function findTable(host, name3, sheet, row3, col) {
|
|
|
32942
33346
|
if (name3) {
|
|
32943
33347
|
const lower3 = name3.toLowerCase();
|
|
32944
33348
|
for (let s = 0; s < sheets.length; s++) {
|
|
32945
|
-
const
|
|
33349
|
+
const table5 = sheets[s]?.tables.find(
|
|
32946
33350
|
(t) => t.displayName.toLowerCase() === lower3 || t.name.toLowerCase() === lower3
|
|
32947
33351
|
);
|
|
32948
|
-
if (
|
|
33352
|
+
if (table5) return { table: table5, sheet: s };
|
|
32949
33353
|
}
|
|
32950
33354
|
return void 0;
|
|
32951
33355
|
}
|
|
32952
|
-
const
|
|
33356
|
+
const table4 = sheets[sheet]?.tables.find(
|
|
32953
33357
|
(t) => row3 >= t.range.start.row && row3 <= t.range.end.row && col >= t.range.start.col && col <= t.range.end.col
|
|
32954
33358
|
);
|
|
32955
|
-
return
|
|
33359
|
+
return table4 ? { table: table4, sheet } : void 0;
|
|
32956
33360
|
}
|
|
32957
33361
|
function resolveStructured(ref, frame2) {
|
|
32958
33362
|
const found = findTable(frame2.host, ref.table, frame2.sheet, frame2.row, frame2.col);
|
|
32959
33363
|
if (!found) return ref.table ? ERR.NAME : ERR.REF;
|
|
32960
|
-
const { table:
|
|
32961
|
-
const range2 = normalizeRange(
|
|
32962
|
-
const headerRow =
|
|
32963
|
-
const dataStart = range2.start.row + (
|
|
32964
|
-
const dataEnd = range2.end.row - (
|
|
32965
|
-
const totalsRow =
|
|
33364
|
+
const { table: table4, sheet } = found;
|
|
33365
|
+
const range2 = normalizeRange(table4.range);
|
|
33366
|
+
const headerRow = table4.headerRow ? range2.start.row : -1;
|
|
33367
|
+
const dataStart = range2.start.row + (table4.headerRow ? 1 : 0);
|
|
33368
|
+
const dataEnd = range2.end.row - (table4.totalsRow ? 1 : 0);
|
|
33369
|
+
const totalsRow = table4.totalsRow ? range2.end.row : -1;
|
|
32966
33370
|
const columnOf = (name3) => {
|
|
32967
33371
|
const lower3 = name3.toLowerCase();
|
|
32968
|
-
const index3 =
|
|
33372
|
+
const index3 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === lower3);
|
|
32969
33373
|
return index3 < 0 ? -1 : range2.start.col + index3;
|
|
32970
33374
|
};
|
|
32971
33375
|
let c1 = range2.start.col;
|
|
@@ -34277,16 +34681,16 @@ function lookupArray(value2) {
|
|
|
34277
34681
|
}
|
|
34278
34682
|
function vhlookup(args, ctx, vertical2) {
|
|
34279
34683
|
const lookup2 = blankAsZero(args);
|
|
34280
|
-
const
|
|
34684
|
+
const table4 = lookupArray(args[1] ?? null);
|
|
34281
34685
|
const index3 = int3(args[2]);
|
|
34282
34686
|
const approximate2 = args.length < 4 ? true : bool(args[3]);
|
|
34283
|
-
const { rows, cols } = shape(
|
|
34687
|
+
const { rows, cols } = shape(table4);
|
|
34284
34688
|
if (index3 < 1) fail(ERR.VALUE);
|
|
34285
34689
|
if (index3 > (vertical2 ? cols : rows)) fail(ERR.REF);
|
|
34286
|
-
const keys = line2(ctx,
|
|
34690
|
+
const keys = line2(ctx, table4, vertical2 ? "col" : "row", 0);
|
|
34287
34691
|
const at2 = approximate2 ? findAscending(keys, lookup2) : findExact(keys, lookup2, true);
|
|
34288
34692
|
if (at2 < 0) fail(ERR.NA);
|
|
34289
|
-
return vertical2 ? cellOf(
|
|
34693
|
+
return vertical2 ? cellOf(table4, at2, index3 - 1) : cellOf(table4, index3 - 1, at2);
|
|
34290
34694
|
}
|
|
34291
34695
|
function match(args, ctx) {
|
|
34292
34696
|
const lookup2 = blankAsZero(args);
|
|
@@ -35730,10 +36134,10 @@ var REGRESSION_FUNCTIONS = [
|
|
|
35730
36134
|
const lay = logs(layout2(ctx, args));
|
|
35731
36135
|
const fit3 = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
|
|
35732
36136
|
const stats = !omitted(args, 3) && bool(args[3]);
|
|
35733
|
-
const
|
|
35734
|
-
if (!stats) return
|
|
36137
|
+
const table4 = coefficientTable(fit3, stats, Math.exp);
|
|
36138
|
+
if (!stats) return table4;
|
|
35735
36139
|
const plain5 = coefficientTable(fit3, true, (v) => v).data;
|
|
35736
|
-
return new Matrix([
|
|
36140
|
+
return new Matrix([table4.data[0] ?? [], ...plain5.slice(1)]);
|
|
35737
36141
|
},
|
|
35738
36142
|
ARGS
|
|
35739
36143
|
),
|
|
@@ -38119,7 +38523,7 @@ function headerMode(args, i2, ctx, firstRow) {
|
|
|
38119
38523
|
if (mode === 1 || mode === 3) return true;
|
|
38120
38524
|
return fail(ERR.VALUE);
|
|
38121
38525
|
}
|
|
38122
|
-
var
|
|
38526
|
+
var keyOf2 = (values2) => JSON.stringify(values2);
|
|
38123
38527
|
var plain2 = (v) => v === void 0 || isError(v) ? null : v;
|
|
38124
38528
|
function compareBy(keys, rows) {
|
|
38125
38529
|
return (a2, b) => {
|
|
@@ -38159,12 +38563,12 @@ function groupby(args, ctx) {
|
|
|
38159
38563
|
if (rows.length === 0) fail(ERR.CALC);
|
|
38160
38564
|
const groups = /* @__PURE__ */ new Map();
|
|
38161
38565
|
for (const r of rows) {
|
|
38162
|
-
const key2 =
|
|
38566
|
+
const key2 = keyOf2(keysM.data[r]);
|
|
38163
38567
|
const found = groups.get(key2);
|
|
38164
38568
|
if (found) found.push(r);
|
|
38165
38569
|
else groups.set(key2, [r]);
|
|
38166
38570
|
}
|
|
38167
|
-
const
|
|
38571
|
+
const table4 = [...groups.values()].map((members3) => {
|
|
38168
38572
|
const key2 = keysM.data[members3[0]];
|
|
38169
38573
|
const cells3 = Array.from(
|
|
38170
38574
|
{ length: vCols },
|
|
@@ -38176,8 +38580,8 @@ function groupby(args, ctx) {
|
|
|
38176
38580
|
return [...key2, ...cells3];
|
|
38177
38581
|
});
|
|
38178
38582
|
for (const key2 of sort2) if (Math.abs(key2) > kCols + vCols) fail(ERR.VALUE);
|
|
38179
|
-
const order =
|
|
38180
|
-
const out = order.map((i2) =>
|
|
38583
|
+
const order = table4.map((_, i2) => i2).sort(compareBy(sort2, table4));
|
|
38584
|
+
const out = order.map((i2) => table4[i2]);
|
|
38181
38585
|
if (depth !== 0) {
|
|
38182
38586
|
const total2 = [
|
|
38183
38587
|
"Total",
|
|
@@ -38226,8 +38630,8 @@ function pivotby(args, ctx) {
|
|
|
38226
38630
|
const colKeys = /* @__PURE__ */ new Map();
|
|
38227
38631
|
for (const r of used) {
|
|
38228
38632
|
for (const [map, key2] of [
|
|
38229
|
-
[rowKeys,
|
|
38230
|
-
[colKeys,
|
|
38633
|
+
[rowKeys, keyOf2(rowsM.data[r])],
|
|
38634
|
+
[colKeys, keyOf2(colsM.data[r])]
|
|
38231
38635
|
]) {
|
|
38232
38636
|
const found = map.get(key2);
|
|
38233
38637
|
if (found) found.push(r);
|
|
@@ -38960,8 +39364,8 @@ function resolveName(node3, frame2) {
|
|
|
38960
39364
|
const value2 = evaluateDefinedName(node3.name, sheet, node3.prefix !== void 0, frame2);
|
|
38961
39365
|
if (value2 !== void 0) return value2;
|
|
38962
39366
|
if (!node3.prefix) {
|
|
38963
|
-
const
|
|
38964
|
-
if (!(isError(
|
|
39367
|
+
const table4 = resolveStructured({ table: node3.name, specials: [] }, frame2);
|
|
39368
|
+
if (!(isError(table4) && table4.error === "#NAME?")) return table4;
|
|
38965
39369
|
}
|
|
38966
39370
|
return ERR.NAME;
|
|
38967
39371
|
}
|
|
@@ -40611,8 +41015,8 @@ function deleteSheetInFormula(formula, sheetName, tableNames = []) {
|
|
|
40611
41015
|
for (const token of tokens3) {
|
|
40612
41016
|
const prefix3 = token.prefix;
|
|
40613
41017
|
const onSheet = prefix3 !== void 0 && prefix3.book === void 0 && prefix3.sheet2 === void 0 && same5(prefix3.sheet, sheetName);
|
|
40614
|
-
const
|
|
40615
|
-
if ((token.kind === "ref" || token.kind === "name") && onSheet ||
|
|
41018
|
+
const table4 = typeof token.value === "string" && tables.has(token.value.toLowerCase()) && (token.kind === "structured" || token.kind === "name" && !prefix3);
|
|
41019
|
+
if ((token.kind === "ref" || token.kind === "name") && onSheet || table4) {
|
|
40616
41020
|
token.text = "#REF!";
|
|
40617
41021
|
changed = true;
|
|
40618
41022
|
}
|
|
@@ -40675,11 +41079,11 @@ function renameTableColumnInFormula(formula, tableName, oldName, newName, inside
|
|
|
40675
41079
|
// xlsx/formula/structured-to-a1.ts
|
|
40676
41080
|
var abs = (row3, col, rowAbs = true) => `$${columnLabel(col)}${rowAbs ? "$" : ""}${row3 + 1}`;
|
|
40677
41081
|
function a1For(ref, t) {
|
|
40678
|
-
const { table:
|
|
40679
|
-
const { start, end } =
|
|
41082
|
+
const { table: table4 } = t;
|
|
41083
|
+
const { start, end } = table4.range;
|
|
40680
41084
|
const index3 = (name3) => {
|
|
40681
41085
|
if (name3 === void 0) return void 0;
|
|
40682
|
-
const i2 =
|
|
41086
|
+
const i2 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === name3.toLowerCase());
|
|
40683
41087
|
return i2 < 0 ? -1 : start.col + i2;
|
|
40684
41088
|
};
|
|
40685
41089
|
const c1 = index3(ref.column);
|
|
@@ -40687,10 +41091,10 @@ function a1For(ref, t) {
|
|
|
40687
41091
|
if (c1 === -1 || c2 === -1) return "#REF!";
|
|
40688
41092
|
const colLo = c1 ?? start.col;
|
|
40689
41093
|
const colHi = c2 ?? end.col;
|
|
40690
|
-
const headerRow =
|
|
40691
|
-
const totalsRow =
|
|
40692
|
-
const dataLo = start.row + (
|
|
40693
|
-
const dataHi = end.row - (
|
|
41094
|
+
const headerRow = table4.headerRow ? start.row : void 0;
|
|
41095
|
+
const totalsRow = table4.totalsRow ? end.row : void 0;
|
|
41096
|
+
const dataLo = start.row + (table4.headerRow ? 1 : 0);
|
|
41097
|
+
const dataHi = end.row - (table4.totalsRow ? 1 : 0);
|
|
40694
41098
|
const specials = new Set(ref.specials);
|
|
40695
41099
|
let rowLo;
|
|
40696
41100
|
let rowHi;
|
|
@@ -42123,8 +42527,8 @@ function sheetDataXml(ctx, sheet) {
|
|
|
42123
42527
|
].sort((a2, b) => a2 - b);
|
|
42124
42528
|
const spills = new SpillPlan(sheet);
|
|
42125
42529
|
const tables = /* @__PURE__ */ new Map();
|
|
42126
|
-
for (const
|
|
42127
|
-
tables.set(`${
|
|
42530
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
42531
|
+
tables.set(`${table4.ref.start.row}:${table4.ref.start.col}`, table4);
|
|
42128
42532
|
let out = "";
|
|
42129
42533
|
for (const row3 of rows) {
|
|
42130
42534
|
const cells3 = sheet.rows.get(row3);
|
|
@@ -42606,29 +43010,29 @@ function setChildText(doc, parent, local, text8, before) {
|
|
|
42606
43010
|
node3.textContent = text8;
|
|
42607
43011
|
if (!existing) insertBefore(parent, node3, before);
|
|
42608
43012
|
}
|
|
42609
|
-
function tableFilterRange(
|
|
43013
|
+
function tableFilterRange(table4) {
|
|
42610
43014
|
return {
|
|
42611
|
-
start:
|
|
42612
|
-
end: { ...
|
|
43015
|
+
start: table4.range.start,
|
|
43016
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
42613
43017
|
};
|
|
42614
43018
|
}
|
|
42615
|
-
function sourceColumnsForPatch(root,
|
|
43019
|
+
function sourceColumnsForPatch(root, table4, names) {
|
|
42616
43020
|
const list2 = xKid(root, "tableColumns");
|
|
42617
43021
|
const source2 = list2 ? xKids(list2, "tableColumn") : [];
|
|
42618
43022
|
const byId2 = new Map(source2.map((c2) => [Number(c2.getAttribute("id")), c2]));
|
|
42619
43023
|
const byName2 = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
42620
|
-
const tracked =
|
|
43024
|
+
const tracked = table4.partName !== void 0 || table4.columns.some((c2) => c2.sourceId !== void 0);
|
|
42621
43025
|
const used = /* @__PURE__ */ new Set();
|
|
42622
43026
|
return names.map((name3, index3) => {
|
|
42623
|
-
const id3 =
|
|
43027
|
+
const id3 = table4.columns[index3]?.sourceId;
|
|
42624
43028
|
const match2 = id3 !== void 0 ? byId2.get(id3) : tracked ? void 0 : source2.length === names.length ? source2[index3] : byName2.get(name3.toLowerCase());
|
|
42625
43029
|
if (!match2 || used.has(match2)) return void 0;
|
|
42626
43030
|
used.add(match2);
|
|
42627
43031
|
return match2;
|
|
42628
43032
|
});
|
|
42629
43033
|
}
|
|
42630
|
-
function syncColumnFilters(doc, filter2,
|
|
42631
|
-
|
|
43034
|
+
function syncColumnFilters(doc, filter2, table4) {
|
|
43035
|
+
table4.columns.forEach((column2, index3) => {
|
|
42632
43036
|
const node3 = xKids(filter2, "filterColumn").find(
|
|
42633
43037
|
(n) => Number(n.getAttribute("colId")) === index3
|
|
42634
43038
|
);
|
|
@@ -42650,29 +43054,29 @@ function syncColumnFilters(doc, filter2, table3) {
|
|
|
42650
43054
|
}
|
|
42651
43055
|
});
|
|
42652
43056
|
}
|
|
42653
|
-
function patchAutoFilter(doc, root,
|
|
43057
|
+
function patchAutoFilter(doc, root, table4, before, names) {
|
|
42654
43058
|
const existing = xKid(root, "autoFilter");
|
|
42655
|
-
if (!
|
|
43059
|
+
if (!table4.headerRow) {
|
|
42656
43060
|
if (existing) root.removeChild(existing);
|
|
42657
43061
|
return;
|
|
42658
43062
|
}
|
|
42659
43063
|
const filter2 = existing ?? doc.createElementNS(NS.x, "autoFilter");
|
|
42660
|
-
const range2 = tableFilterRange(
|
|
43064
|
+
const range2 = tableFilterRange(table4);
|
|
42661
43065
|
filter2.setAttribute("ref", formatRange(range2));
|
|
42662
43066
|
const list2 = xKid(root, "tableColumns");
|
|
42663
43067
|
const original = list2 ? xKids(list2, "tableColumn") : [];
|
|
42664
|
-
const current = new Map(sourceColumnsForPatch(root,
|
|
43068
|
+
const current = new Map(sourceColumnsForPatch(root, table4, names).map((c2, index3) => [c2, index3]));
|
|
42665
43069
|
for (const column2 of xKids(filter2, "filterColumn")) {
|
|
42666
43070
|
const old = original[Number(column2.getAttribute("colId") ?? "0")];
|
|
42667
43071
|
const index3 = old ? current.get(old) : void 0;
|
|
42668
43072
|
if (index3 === void 0) filter2.removeChild(column2);
|
|
42669
43073
|
else column2.setAttribute("colId", num(index3));
|
|
42670
43074
|
}
|
|
42671
|
-
syncColumnFilters(doc, filter2,
|
|
43075
|
+
syncColumnFilters(doc, filter2, table4);
|
|
42672
43076
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
42673
43077
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
42674
43078
|
if (!sort2) return;
|
|
42675
|
-
const moved = before.start.row !==
|
|
43079
|
+
const moved = before.start.row !== table4.range.start.row || before.start.col !== table4.range.start.col || before.end.col !== table4.range.end.col;
|
|
42676
43080
|
if (moved) {
|
|
42677
43081
|
sort2.parentNode?.removeChild(sort2);
|
|
42678
43082
|
return;
|
|
@@ -42694,7 +43098,7 @@ function patchAutoFilter(doc, root, table3, before, names) {
|
|
|
42694
43098
|
}
|
|
42695
43099
|
}
|
|
42696
43100
|
var COLUMN_CHILD_ORDER = ["calculatedColumnFormula", "totalsRowFormula", "xmlColumnPr", "extLst"];
|
|
42697
|
-
function patchColumns(doc, root, sheet,
|
|
43101
|
+
function patchColumns(doc, root, sheet, table4, names) {
|
|
42698
43102
|
let list2 = xKid(root, "tableColumns");
|
|
42699
43103
|
if (!list2) {
|
|
42700
43104
|
list2 = doc.createElementNS(NS.x, "tableColumns");
|
|
@@ -42702,7 +43106,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42702
43106
|
}
|
|
42703
43107
|
const sourceColumns = xKids(list2, "tableColumn");
|
|
42704
43108
|
const ids = /* @__PURE__ */ new Set();
|
|
42705
|
-
const picked = sourceColumnsForPatch(root,
|
|
43109
|
+
const picked = sourceColumnsForPatch(root, table4, names).map((match2) => {
|
|
42706
43110
|
if (!match2) return void 0;
|
|
42707
43111
|
const id3 = Number(match2.getAttribute("id"));
|
|
42708
43112
|
if (Number.isInteger(id3) && id3 >= 0 && !ids.has(id3)) ids.add(id3);
|
|
@@ -42711,15 +43115,15 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42711
43115
|
});
|
|
42712
43116
|
for (const column2 of sourceColumns) list2.removeChild(column2);
|
|
42713
43117
|
let nextId3 = Math.max(0, ...ids) + 1;
|
|
42714
|
-
const totalsRow =
|
|
43118
|
+
const totalsRow = table4.range.end.row;
|
|
42715
43119
|
names.forEach((name3, index3) => {
|
|
42716
43120
|
const column2 = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
42717
43121
|
if (!column2.getAttribute("id")) column2.setAttribute("id", num(nextId3++));
|
|
42718
43122
|
column2.setAttribute("name", name3);
|
|
42719
|
-
const model =
|
|
42720
|
-
const fn =
|
|
43123
|
+
const model = table4.columns[index3];
|
|
43124
|
+
const fn = table4.totalsRow ? model?.totalsRowFunction : void 0;
|
|
42721
43125
|
setOrRemove(column2, "totalsRowFunction", fn);
|
|
42722
|
-
setOrRemove(column2, "totalsRowLabel",
|
|
43126
|
+
setOrRemove(column2, "totalsRowLabel", table4.totalsRow ? model?.totalsRowLabel : void 0);
|
|
42723
43127
|
const calculated = model?.calculatedColumnFormula;
|
|
42724
43128
|
setChildText(
|
|
42725
43129
|
doc,
|
|
@@ -42730,7 +43134,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42730
43134
|
);
|
|
42731
43135
|
if (fn !== "custom") setChildText(doc, column2, "totalsRowFormula", void 0, []);
|
|
42732
43136
|
else {
|
|
42733
|
-
const cellFormula = sheet.rows.get(totalsRow)?.get(
|
|
43137
|
+
const cellFormula = sheet.rows.get(totalsRow)?.get(table4.range.start.col + index3)?.formula;
|
|
42734
43138
|
if (cellFormula)
|
|
42735
43139
|
setChildText(
|
|
42736
43140
|
doc,
|
|
@@ -42744,19 +43148,19 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42744
43148
|
});
|
|
42745
43149
|
list2.setAttribute("count", num(names.length));
|
|
42746
43150
|
}
|
|
42747
|
-
function patchStyleInfo(doc, root,
|
|
43151
|
+
function patchStyleInfo(doc, root, table4) {
|
|
42748
43152
|
let info = xKid(root, "tableStyleInfo");
|
|
42749
43153
|
if (!info) {
|
|
42750
43154
|
info = doc.createElementNS(NS.x, "tableStyleInfo");
|
|
42751
43155
|
insertBefore(root, info, ["extLst"]);
|
|
42752
43156
|
}
|
|
42753
|
-
setOrRemove(info, "name",
|
|
42754
|
-
info.setAttribute("showFirstColumn", flag2(
|
|
42755
|
-
info.setAttribute("showLastColumn", flag2(
|
|
42756
|
-
info.setAttribute("showRowStripes", flag2(
|
|
42757
|
-
info.setAttribute("showColumnStripes", flag2(
|
|
43157
|
+
setOrRemove(info, "name", table4.styleName);
|
|
43158
|
+
info.setAttribute("showFirstColumn", flag2(table4.showFirstColumn, false));
|
|
43159
|
+
info.setAttribute("showLastColumn", flag2(table4.showLastColumn, false));
|
|
43160
|
+
info.setAttribute("showRowStripes", flag2(table4.showRowStripes, true));
|
|
43161
|
+
info.setAttribute("showColumnStripes", flag2(table4.showColumnStripes, false));
|
|
42758
43162
|
}
|
|
42759
|
-
function patchTableXml(sourceXml, sheet,
|
|
43163
|
+
function patchTableXml(sourceXml, sheet, table4, id3, names) {
|
|
42760
43164
|
let doc;
|
|
42761
43165
|
try {
|
|
42762
43166
|
doc = parseXml(sourceXml, { label: "XLSX table" });
|
|
@@ -42765,80 +43169,80 @@ function patchTableXml(sourceXml, sheet, table3, id3, names) {
|
|
|
42765
43169
|
}
|
|
42766
43170
|
const root = doc.documentElement;
|
|
42767
43171
|
if (root.localName !== "table") return void 0;
|
|
42768
|
-
const before = parseRange(root.getAttribute("ref") ?? "") ??
|
|
43172
|
+
const before = parseRange(root.getAttribute("ref") ?? "") ?? table4.range;
|
|
42769
43173
|
root.setAttribute("id", num(id3));
|
|
42770
|
-
root.setAttribute("name",
|
|
42771
|
-
root.setAttribute("displayName",
|
|
42772
|
-
root.setAttribute("ref", formatRange(
|
|
42773
|
-
setOrRemove(root, "headerRowCount",
|
|
42774
|
-
if (
|
|
43174
|
+
root.setAttribute("name", table4.name);
|
|
43175
|
+
root.setAttribute("displayName", table4.displayName || table4.name);
|
|
43176
|
+
root.setAttribute("ref", formatRange(table4.range));
|
|
43177
|
+
setOrRemove(root, "headerRowCount", table4.headerRow ? void 0 : "0");
|
|
43178
|
+
if (table4.totalsRow) {
|
|
42775
43179
|
root.setAttribute("totalsRowCount", "1");
|
|
42776
43180
|
root.removeAttribute("totalsRowShown");
|
|
42777
43181
|
} else {
|
|
42778
43182
|
root.removeAttribute("totalsRowCount");
|
|
42779
43183
|
if (!root.hasAttribute("totalsRowShown")) root.setAttribute("totalsRowShown", "0");
|
|
42780
43184
|
}
|
|
42781
|
-
patchAutoFilter(doc, root,
|
|
42782
|
-
patchColumns(doc, root, sheet,
|
|
42783
|
-
patchStyleInfo(doc, root,
|
|
43185
|
+
patchAutoFilter(doc, root, table4, before, names);
|
|
43186
|
+
patchColumns(doc, root, sheet, table4, names);
|
|
43187
|
+
patchStyleInfo(doc, root, table4);
|
|
42784
43188
|
return buildXml(doc);
|
|
42785
43189
|
}
|
|
42786
43190
|
|
|
42787
43191
|
// xlsx/write/tables.ts
|
|
42788
43192
|
var headerTextOf = (value2) => typeof value2 === "string" ? value2 : typeof value2 === "number" || typeof value2 === "boolean" ? String(value2).toUpperCase() : void 0;
|
|
42789
|
-
function resolveTableColumns(sheet,
|
|
43193
|
+
function resolveTableColumns(sheet, table4) {
|
|
42790
43194
|
const headerText = /* @__PURE__ */ new Map();
|
|
42791
43195
|
const used = /* @__PURE__ */ new Set();
|
|
42792
|
-
const width =
|
|
43196
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
42793
43197
|
const names = [];
|
|
42794
43198
|
for (let i2 = 0; i2 < width; i2++) {
|
|
42795
|
-
const col =
|
|
42796
|
-
const row3 =
|
|
42797
|
-
const fromCell =
|
|
42798
|
-
let name3 = (fromCell?.trim() ? fromCell : void 0) ??
|
|
43199
|
+
const col = table4.range.start.col + i2;
|
|
43200
|
+
const row3 = table4.range.start.row;
|
|
43201
|
+
const fromCell = table4.headerRow ? headerTextOf(sheet.rows.get(row3)?.get(col)?.value) : void 0;
|
|
43202
|
+
let name3 = (fromCell?.trim() ? fromCell : void 0) ?? table4.columns[i2]?.name ?? `Column${i2 + 1}`;
|
|
42799
43203
|
if (!name3.trim()) name3 = `Column${i2 + 1}`;
|
|
42800
43204
|
let unique4 = name3;
|
|
42801
43205
|
for (let n = 2; used.has(unique4.toLowerCase()); n++) unique4 = `${name3}${n}`;
|
|
42802
43206
|
used.add(unique4.toLowerCase());
|
|
42803
43207
|
names.push(unique4);
|
|
42804
43208
|
const cell = sheet.rows.get(row3)?.get(col);
|
|
42805
|
-
if (
|
|
43209
|
+
if (table4.headerRow && (typeof cell?.value !== "string" || cell.value !== unique4))
|
|
42806
43210
|
headerText.set(`${row3}:${col}`, unique4);
|
|
42807
43211
|
}
|
|
42808
43212
|
return { names, headerText };
|
|
42809
43213
|
}
|
|
42810
|
-
function tableXml(
|
|
42811
|
-
const range2 = formatRange(
|
|
42812
|
-
const filterEnd = { ...
|
|
42813
|
-
const criteria =
|
|
42814
|
-
const filterRef = formatRange({ start:
|
|
42815
|
-
const filter2 =
|
|
43214
|
+
function tableXml(table4, id3, names) {
|
|
43215
|
+
const range2 = formatRange(table4.range);
|
|
43216
|
+
const filterEnd = { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) };
|
|
43217
|
+
const criteria = table4.columns.map((column2, index3) => column2.filter ? filterColumnXml(index3, column2.filter) : "").join("");
|
|
43218
|
+
const filterRef = formatRange({ start: table4.range.start, end: filterEnd });
|
|
43219
|
+
const filter2 = table4.headerRow ? criteria ? `<autoFilter ref="${filterRef}">${criteria}</autoFilter>` : `<autoFilter ref="${filterRef}"/>` : "";
|
|
42816
43220
|
const columns = names.map((name3, index3) => {
|
|
42817
|
-
const column2 =
|
|
43221
|
+
const column2 = table4.columns[index3];
|
|
42818
43222
|
const calculated = column2?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText3(addFuturePrefixes(column2.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
42819
43223
|
const values2 = attrs2({
|
|
42820
43224
|
id: index3 + 1,
|
|
42821
43225
|
name: name3,
|
|
42822
|
-
totalsRowFunction:
|
|
42823
|
-
totalsRowLabel:
|
|
43226
|
+
totalsRowFunction: table4.totalsRow ? column2?.totalsRowFunction : void 0,
|
|
43227
|
+
totalsRowLabel: table4.totalsRow ? column2?.totalsRowLabel : void 0
|
|
42824
43228
|
});
|
|
42825
43229
|
return calculated ? `<tableColumn${values2}>${calculated}</tableColumn>` : `<tableColumn${values2}/>`;
|
|
42826
43230
|
}).join("");
|
|
42827
43231
|
const style3 = attrs2({
|
|
42828
|
-
name:
|
|
42829
|
-
showFirstColumn:
|
|
42830
|
-
showLastColumn:
|
|
42831
|
-
showRowStripes:
|
|
42832
|
-
showColumnStripes:
|
|
43232
|
+
name: table4.styleName,
|
|
43233
|
+
showFirstColumn: table4.showFirstColumn ?? false,
|
|
43234
|
+
showLastColumn: table4.showLastColumn ?? false,
|
|
43235
|
+
showRowStripes: table4.showRowStripes ?? true,
|
|
43236
|
+
showColumnStripes: table4.showColumnStripes ?? false
|
|
42833
43237
|
});
|
|
42834
43238
|
const head = attrs2({
|
|
42835
43239
|
id: id3,
|
|
42836
|
-
name:
|
|
42837
|
-
displayName:
|
|
43240
|
+
name: table4.name,
|
|
43241
|
+
displayName: table4.displayName || table4.name,
|
|
42838
43242
|
ref: range2,
|
|
42839
|
-
headerRowCount:
|
|
42840
|
-
totalsRowCount:
|
|
42841
|
-
totalsRowShown:
|
|
43243
|
+
headerRowCount: table4.headerRow ? void 0 : 0,
|
|
43244
|
+
totalsRowCount: table4.totalsRow ? 1 : void 0,
|
|
43245
|
+
totalsRowShown: table4.totalsRow ? void 0 : false
|
|
42842
43246
|
});
|
|
42843
43247
|
return `${XML_HEADER}<table xmlns="${NS.x}"${head}>${filter2}<tableColumns count="${names.length}">${columns}</tableColumns><tableStyleInfo${style3}/></table>`;
|
|
42844
43248
|
}
|
|
@@ -42852,24 +43256,24 @@ var SUBTOTAL_CODES = {
|
|
|
42852
43256
|
sum: 109,
|
|
42853
43257
|
var: 110
|
|
42854
43258
|
};
|
|
42855
|
-
function totalsRowFormulas(sheet,
|
|
43259
|
+
function totalsRowFormulas(sheet, table4, names) {
|
|
42856
43260
|
const out = /* @__PURE__ */ new Map();
|
|
42857
|
-
if (!
|
|
42858
|
-
const row3 =
|
|
43261
|
+
if (!table4.totalsRow) return out;
|
|
43262
|
+
const row3 = table4.range.end.row;
|
|
42859
43263
|
names.forEach((name3, index3) => {
|
|
42860
|
-
const code = SUBTOTAL_CODES[
|
|
43264
|
+
const code = SUBTOTAL_CODES[table4.columns[index3]?.totalsRowFunction ?? ""];
|
|
42861
43265
|
if (code === void 0) return;
|
|
42862
|
-
const col =
|
|
43266
|
+
const col = table4.range.start.col + index3;
|
|
42863
43267
|
const escaped = name3.replace(/['#[\]]/g, "'$&");
|
|
42864
|
-
const formula = `SUBTOTAL(${code},${
|
|
43268
|
+
const formula = `SUBTOTAL(${code},${table4.displayName || table4.name}[${escaped}])`;
|
|
42865
43269
|
if (sheet.rows.get(row3)?.get(col)?.formula !== formula) out.set(`${row3}:${col}`, formula);
|
|
42866
43270
|
});
|
|
42867
43271
|
return out;
|
|
42868
43272
|
}
|
|
42869
|
-
function resolveTableNames(
|
|
42870
|
-
const display =
|
|
43273
|
+
function resolveTableNames(table4, before, index3) {
|
|
43274
|
+
const display = table4.displayName || table4.name;
|
|
42871
43275
|
const displayName = before && before.displayName === display ? display : safeTableName(display, index3);
|
|
42872
|
-
const name3 = before && before.name ===
|
|
43276
|
+
const name3 = before && before.name === table4.name ? table4.name : table4.name === display ? displayName : safeTableName(table4.name, index3);
|
|
42873
43277
|
return { name: name3, displayName };
|
|
42874
43278
|
}
|
|
42875
43279
|
function safeTableName(name3, index3) {
|
|
@@ -42962,21 +43366,21 @@ function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
|
42962
43366
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
42963
43367
|
const before = sourceXml && original.partName ? parseTable3(sourceXml, original.partName) : void 0;
|
|
42964
43368
|
const { name: name3, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
42965
|
-
const
|
|
42966
|
-
const { names, headerText: forced } = resolveTableColumns(sheet,
|
|
43369
|
+
const table4 = name3 === original.name && displayName === original.displayName ? original : { ...original, name: name3, displayName };
|
|
43370
|
+
const { names, headerText: forced } = resolveTableColumns(sheet, table4);
|
|
42967
43371
|
for (const [key2, text8] of forced) headerText.set(key2, text8);
|
|
42968
|
-
const totals = totalsRowFormulas(sheet,
|
|
43372
|
+
const totals = totalsRowFormulas(sheet, table4, names);
|
|
42969
43373
|
for (const [key2, formula] of totals) formulas.set(key2, formula);
|
|
42970
|
-
let id3 =
|
|
42971
|
-
const unchanged =
|
|
43374
|
+
let id3 = table4.id;
|
|
43375
|
+
const unchanged = table4.partName && sourceXml && !writer.has(table4.partName) && !ctx.tableIds.has(id3) && forced.size === 0 && totals.size === 0 && table4 === original && sameModel(before, table4);
|
|
42972
43376
|
let part;
|
|
42973
|
-
if (unchanged &&
|
|
42974
|
-
part =
|
|
43377
|
+
if (unchanged && table4.partName) {
|
|
43378
|
+
part = table4.partName;
|
|
42975
43379
|
writer.carry(part);
|
|
42976
43380
|
} else {
|
|
42977
43381
|
while (ctx.tableIds.has(id3) || id3 < 1) id3++;
|
|
42978
|
-
part =
|
|
42979
|
-
const xml = (sourceXml && patchTableXml(sourceXml, sheet,
|
|
43382
|
+
part = table4.partName && !writer.has(table4.partName) ? table4.partName : writer.uniqueName((n) => `xl/tables/table${n}.xml`, ctx.reserved);
|
|
43383
|
+
const xml = (sourceXml && patchTableXml(sourceXml, sheet, table4, id3, names)) ?? tableXml(table4, id3, names);
|
|
42980
43384
|
writer.add(part, xml, CONTENT_TYPES.table);
|
|
42981
43385
|
}
|
|
42982
43386
|
ctx.tableIds.add(id3);
|
|
@@ -43421,13 +43825,13 @@ function derivedFieldXml(pivot, entry3, date1904) {
|
|
|
43421
43825
|
const days = dateGroupDays(entry3.group);
|
|
43422
43826
|
const labels = dateUnitLabels(entry3.unit, range2, days, date1904, entry3.group);
|
|
43423
43827
|
const base2 = pivot.fields.indexOf(entry3.group.field);
|
|
43424
|
-
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((
|
|
43828
|
+
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>`;
|
|
43425
43829
|
}
|
|
43426
43830
|
function groupXml2(pivot, name3, index3) {
|
|
43427
43831
|
const group = groupOf(pivot, name3);
|
|
43428
43832
|
if (!group) return "";
|
|
43429
43833
|
const labels = numberGroupLabels(group);
|
|
43430
|
-
return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((
|
|
43834
|
+
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>`;
|
|
43431
43835
|
}
|
|
43432
43836
|
function slicerExt(pivot) {
|
|
43433
43837
|
if (pivot.slicerCacheId === void 0) return "";
|
|
@@ -43487,6 +43891,10 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43487
43891
|
const compact3 = pivot.layout === "compact";
|
|
43488
43892
|
const outline2 = pivot.layout === "compact" || pivot.layout === "outline";
|
|
43489
43893
|
const top = (pivot.subtotalPosition ?? (outline2 ? "top" : "bottom")) === "top";
|
|
43894
|
+
const named3 = (field2, item) => {
|
|
43895
|
+
const text8 = pivotItemName(pivot, field2, item);
|
|
43896
|
+
return text8 === void 0 ? "" : attrs2({ n: encodeEscapes(text8) });
|
|
43897
|
+
};
|
|
43490
43898
|
const fields = pivot.fields.map((name3, index3) => {
|
|
43491
43899
|
const isDate = pivot.dateFields?.includes(name3) ?? false;
|
|
43492
43900
|
const at2 = rowIdx.indexOf(index3);
|
|
@@ -43501,7 +43909,7 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43501
43909
|
custom.map((fn) => [PIVOT_SUBTOTALS[fn].attr, true])
|
|
43502
43910
|
);
|
|
43503
43911
|
const entries = automatic ? '<item t="default"/>' : custom.map((fn) => `<item t="${PIVOT_SUBTOTALS[fn].item}"/>`).join("");
|
|
43504
|
-
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>`;
|
|
43912
|
+
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>`;
|
|
43505
43913
|
}).join("");
|
|
43506
43914
|
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
43507
43915
|
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
@@ -43531,6 +43939,15 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43531
43939
|
const root = doc.documentElement;
|
|
43532
43940
|
root.setAttribute("name", pivot.name);
|
|
43533
43941
|
root.setAttribute("cacheId", String(cacheId));
|
|
43942
|
+
const caps = pivotCaptions(pivot);
|
|
43943
|
+
root.setAttribute("dataCaption", caps.values);
|
|
43944
|
+
for (const [attribute4, key2] of [
|
|
43945
|
+
["rowHeaderCaption", "rowLabels"],
|
|
43946
|
+
["colHeaderCaption", "columnLabels"],
|
|
43947
|
+
["grandTotalCaption", "grandTotal"]
|
|
43948
|
+
])
|
|
43949
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2] || root.hasAttribute(attribute4))
|
|
43950
|
+
root.setAttribute(attribute4, caps[key2]);
|
|
43534
43951
|
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
43535
43952
|
if (rowsAxis && valuesAt < rowIdx.length) root.setAttribute("dataPosition", String(valuesAt));
|
|
43536
43953
|
else root.removeAttribute("dataPosition");
|
|
@@ -43598,7 +44015,9 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43598
44015
|
}
|
|
43599
44016
|
function dateFilterXml(pivot, filter2) {
|
|
43600
44017
|
const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
43601
|
-
const id3 = Number(
|
|
44018
|
+
const id3 = Number(
|
|
44019
|
+
/\bid="(\d+)"/.exec(/<filter\s[^>]*>/.exec(pivot.sourceXml ?? "")?.[0] ?? "")?.[1] ?? 1
|
|
44020
|
+
);
|
|
43602
44021
|
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>`;
|
|
43603
44022
|
}
|
|
43604
44023
|
|
|
@@ -43654,7 +44073,7 @@ var PivotWritePlan = class {
|
|
|
43654
44073
|
this.tableParts.set(pivot, pivot.partName);
|
|
43655
44074
|
continue;
|
|
43656
44075
|
}
|
|
43657
|
-
const
|
|
44076
|
+
const table4 = pivot.partName ?? writer.uniqueName((n) => `xl/pivotTables/pivotTable${n}.xml`, reserved);
|
|
43658
44077
|
const definition = writer.uniqueName(
|
|
43659
44078
|
(n) => `xl/pivotCache/pivotCacheDefinition${n}.xml`,
|
|
43660
44079
|
reserved
|
|
@@ -43676,24 +44095,24 @@ var PivotWritePlan = class {
|
|
|
43676
44095
|
TYPES2.definition
|
|
43677
44096
|
);
|
|
43678
44097
|
writer.rels(definition, cacheRels);
|
|
43679
|
-
writer.add(
|
|
44098
|
+
writer.add(table4, pivotTableXml(pivot, cacheId, cache3), TYPES2.table);
|
|
43680
44099
|
const tableRels = new RelationshipSet();
|
|
43681
|
-
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(
|
|
43682
|
-
writer.rels(
|
|
44100
|
+
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(table4, definition));
|
|
44101
|
+
writer.rels(table4, tableRels);
|
|
43683
44102
|
const rid2 = bookRels.add(
|
|
43684
44103
|
RELATIONSHIP_TYPES.pivotCacheDefinition,
|
|
43685
44104
|
relativeTarget(bookPart, definition)
|
|
43686
44105
|
);
|
|
43687
44106
|
entries.push(`<pivotCache cacheId="${cacheId++}" r:id="${rid2}"/>`);
|
|
43688
|
-
this.tableParts.set(pivot,
|
|
44107
|
+
this.tableParts.set(pivot, table4);
|
|
43689
44108
|
}
|
|
43690
44109
|
this.cachesXml = owns ? entries.length ? `<pivotCaches>${entries.join("")}</pivotCaches>` : "" : void 0;
|
|
43691
44110
|
}
|
|
43692
44111
|
writeSheet(writer, sheet, part, rels) {
|
|
43693
44112
|
for (const pivot of sheet.pivotTables ?? []) {
|
|
43694
|
-
const
|
|
43695
|
-
writer.carry(
|
|
43696
|
-
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part,
|
|
44113
|
+
const table4 = this.tableParts.get(pivot);
|
|
44114
|
+
writer.carry(table4);
|
|
44115
|
+
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part, table4));
|
|
43697
44116
|
}
|
|
43698
44117
|
}
|
|
43699
44118
|
};
|
|
@@ -43863,9 +44282,9 @@ function slicerTarget(workbook, cache3) {
|
|
|
43863
44282
|
const source2 = cache3.source;
|
|
43864
44283
|
for (const [sheetIndex2, sheet] of workbook.sheets.entries()) {
|
|
43865
44284
|
if (source2.kind === "table") {
|
|
43866
|
-
const
|
|
43867
|
-
const offset2 =
|
|
43868
|
-
if (
|
|
44285
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === source2.tableId);
|
|
44286
|
+
const offset2 = table4?.columns.findIndex((column2) => column2.sourceId === source2.column) ?? -1;
|
|
44287
|
+
if (table4 && offset2 >= 0) return { kind: "table", sheet, sheetIndex: sheetIndex2, table: table4, offset: offset2 };
|
|
43869
44288
|
} else {
|
|
43870
44289
|
const first3 = source2.pivots[0];
|
|
43871
44290
|
const pivot = first3 && sheet.sheetId === first3.tabId ? sheet.pivotTables?.find((entry3) => entry3.name === first3.name) : void 0;
|
|
@@ -44054,12 +44473,12 @@ function slicerCacheXml(cache3, facts) {
|
|
|
44054
44473
|
ext.setAttribute("xmlns:x15", X153);
|
|
44055
44474
|
list2.appendChild(ext);
|
|
44056
44475
|
}
|
|
44057
|
-
let
|
|
44058
|
-
if (!
|
|
44059
|
-
|
|
44060
|
-
|
|
44061
|
-
if (cache3.sortOrder === "descending")
|
|
44062
|
-
else
|
|
44476
|
+
let table4 = first(ext, "tableSlicerCache", X153);
|
|
44477
|
+
if (!table4) table4 = ext.appendChild(make2(X153, "x15:tableSlicerCache"));
|
|
44478
|
+
table4.setAttribute("tableId", String(source2.tableId));
|
|
44479
|
+
table4.setAttribute("column", String(source2.column));
|
|
44480
|
+
if (cache3.sortOrder === "descending") table4.setAttribute("sortOrder", "descending");
|
|
44481
|
+
else table4.removeAttribute("sortOrder");
|
|
44063
44482
|
return XML_HEADER + buildXml(root);
|
|
44064
44483
|
}
|
|
44065
44484
|
|
|
@@ -44612,12 +45031,12 @@ function rewriteSheetFormulas(sheet, rewrite2, formulaCells) {
|
|
|
44612
45031
|
}
|
|
44613
45032
|
{
|
|
44614
45033
|
const name3 = sheet.name;
|
|
44615
|
-
for (const
|
|
44616
|
-
for (const [index3, column2] of
|
|
45034
|
+
for (const table4 of sheet.tables)
|
|
45035
|
+
for (const [index3, column2] of table4.columns.entries())
|
|
44617
45036
|
if (column2.calculatedColumnFormula !== void 0)
|
|
44618
45037
|
column2.calculatedColumnFormula = safe(rewrite2, column2.calculatedColumnFormula, name3, {
|
|
44619
|
-
row:
|
|
44620
|
-
col:
|
|
45038
|
+
row: table4.range.start.row + (table4.headerRow ? 1 : 0),
|
|
45039
|
+
col: table4.range.start.col + index3
|
|
44621
45040
|
});
|
|
44622
45041
|
if (formulaCells) {
|
|
44623
45042
|
for (const at2 of formulaCells) {
|
|
@@ -44682,14 +45101,14 @@ function tableHeaderAt(sheet, row3, col) {
|
|
|
44682
45101
|
);
|
|
44683
45102
|
}
|
|
44684
45103
|
function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
44685
|
-
const
|
|
44686
|
-
if (!
|
|
44687
|
-
const column2 =
|
|
45104
|
+
const table4 = tableHeaderAt(sheet, row3, col);
|
|
45105
|
+
if (!table4) return;
|
|
45106
|
+
const column2 = table4.columns[col - table4.range.start.col];
|
|
44688
45107
|
if (!column2) return;
|
|
44689
45108
|
const text8 = displayText(ctx.workbook, getCell(sheet, row3, col)).trim();
|
|
44690
45109
|
if (!text8 || column2.name === text8) return;
|
|
44691
45110
|
const oldName = column2.name;
|
|
44692
|
-
const others =
|
|
45111
|
+
const others = table4.columns.filter((entry3) => entry3 !== column2).map((entry3) => entry3.name);
|
|
44693
45112
|
const newName = uniqueHeaders([...others, text8]).at(-1);
|
|
44694
45113
|
column2.name = newName;
|
|
44695
45114
|
if (newName !== text8) writeValue(sheet, row3, col, newName);
|
|
@@ -44699,10 +45118,10 @@ function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
|
44699
45118
|
ctx.workbook,
|
|
44700
45119
|
(formula, formulaSheet, at2) => renameTableColumnInFormula(
|
|
44701
45120
|
formula,
|
|
44702
|
-
|
|
45121
|
+
table4.name,
|
|
44703
45122
|
oldName,
|
|
44704
45123
|
newName,
|
|
44705
|
-
formulaSheet === sheet.name && !!at2 && rangeContains(
|
|
45124
|
+
formulaSheet === sheet.name && !!at2 && rangeContains(table4.range, at2)
|
|
44706
45125
|
),
|
|
44707
45126
|
cells3
|
|
44708
45127
|
);
|
|
@@ -45826,11 +46245,11 @@ function uniqueColumnName(columns) {
|
|
|
45826
46245
|
const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
|
|
45827
46246
|
for (let n = 1; ; n++) if (!taken.has(`column${n}`)) return `Column${n}`;
|
|
45828
46247
|
}
|
|
45829
|
-
function shiftTable(sheet,
|
|
45830
|
-
const old =
|
|
46248
|
+
function shiftTable(sheet, table4, shift2, moveRange) {
|
|
46249
|
+
const old = table4.range;
|
|
45831
46250
|
const range2 = moveRange(old);
|
|
45832
46251
|
if (!range2) return [];
|
|
45833
|
-
const next = { ...
|
|
46252
|
+
const next = { ...table4, range: range2, columns: [...table4.columns] };
|
|
45834
46253
|
const widened = range2.end.col - range2.start.col !== old.end.col - old.start.col;
|
|
45835
46254
|
if (shift2.axis === "col" && widened) {
|
|
45836
46255
|
if (shift2.count > 0) {
|
|
@@ -46306,8 +46725,8 @@ function cellText(inner2) {
|
|
|
46306
46725
|
).replace(/ /g, " ").trim();
|
|
46307
46726
|
}
|
|
46308
46727
|
function parseHtmlTable(html, base2) {
|
|
46309
|
-
const
|
|
46310
|
-
if (
|
|
46728
|
+
const table4 = /<table\b[^>]*>([\s\S]*?)<\/table>/i.exec(html)?.[1];
|
|
46729
|
+
if (table4 === void 0) return void 0;
|
|
46311
46730
|
const classes = /* @__PURE__ */ new Map();
|
|
46312
46731
|
for (const block of html.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi))
|
|
46313
46732
|
for (const rule2 of removeAll(block[1] ?? "", ["<!--", "-->"]).matchAll(
|
|
@@ -46320,7 +46739,7 @@ function parseHtmlTable(html, base2) {
|
|
|
46320
46739
|
const hyperlinks = [];
|
|
46321
46740
|
let r = 0;
|
|
46322
46741
|
let spanned = 0;
|
|
46323
|
-
for (const tr of
|
|
46742
|
+
for (const tr of table4.matchAll(/<tr\b[^>]*>([\s\S]*?)(?=<tr\b|<\/tbody|<\/table|$)/gi)) {
|
|
46324
46743
|
const row3 = grid[r] ??= [];
|
|
46325
46744
|
let c2 = 0;
|
|
46326
46745
|
for (const td of (tr[1] ?? "").matchAll(
|
|
@@ -47172,9 +47591,9 @@ function filterColumn(ctx, s, col, values2) {
|
|
|
47172
47591
|
}
|
|
47173
47592
|
function sortByColumn(ctx, s, col, descending) {
|
|
47174
47593
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47175
|
-
const
|
|
47594
|
+
const table4 = sheet.tables.find((t) => col >= t.range.start.col && col <= t.range.end.col);
|
|
47176
47595
|
const filter2 = sheet.autoFilter;
|
|
47177
|
-
const target2 =
|
|
47596
|
+
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;
|
|
47178
47597
|
if (!target2) throw new Error("The column is not inside a table or an auto-filter range.");
|
|
47179
47598
|
const range2 = target2.totals ? { start: target2.range.start, end: { ...target2.range.end, row: target2.range.end.row - 1 } } : target2.range;
|
|
47180
47599
|
ctx.run(
|
|
@@ -47234,12 +47653,12 @@ function restore(sheet, saved) {
|
|
|
47234
47653
|
Object.assign(cell, saved.fields);
|
|
47235
47654
|
}
|
|
47236
47655
|
var valueAt = (sheet, row3, col) => getCell(sheet, row3, col)?.value ?? null;
|
|
47237
|
-
function computeDataTable(workbook, calc, sheetIndex2,
|
|
47656
|
+
function computeDataTable(workbook, calc, sheetIndex2, table4) {
|
|
47238
47657
|
const sheet = sheetAt(workbook, sheetIndex2);
|
|
47239
|
-
const { ref } =
|
|
47240
|
-
const first3 = parseInputCell(sheet,
|
|
47241
|
-
const second =
|
|
47242
|
-
if (!first3 ||
|
|
47658
|
+
const { ref } = table4;
|
|
47659
|
+
const first3 = parseInputCell(sheet, table4.r1);
|
|
47660
|
+
const second = table4.dt2D && table4.r2 ? parseInputCell(sheet, table4.r2) : void 0;
|
|
47661
|
+
if (!first3 || table4.dt2D && !second || table4.del1 || table4.del2) return [];
|
|
47243
47662
|
const inputs = [first3, ...second ? [second] : []];
|
|
47244
47663
|
const saved = inputs.map((p) => save(sheet, p.row, p.col));
|
|
47245
47664
|
const top = ref.start.row - 1;
|
|
@@ -47258,11 +47677,11 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47258
47677
|
for (let row3 = ref.start.row; row3 <= ref.end.row; row3++) {
|
|
47259
47678
|
for (let col = ref.start.col; col <= ref.end.col; col++) {
|
|
47260
47679
|
let formulaAt;
|
|
47261
|
-
if (
|
|
47680
|
+
if (table4.dt2D) {
|
|
47262
47681
|
set(first3, valueAt(sheet, top, col));
|
|
47263
47682
|
if (second) set(second, valueAt(sheet, row3, left2));
|
|
47264
47683
|
formulaAt = { row: top, col: left2 };
|
|
47265
|
-
} else if (
|
|
47684
|
+
} else if (table4.dtr) {
|
|
47266
47685
|
set(first3, valueAt(sheet, top, col));
|
|
47267
47686
|
formulaAt = { row: row3, col: left2 };
|
|
47268
47687
|
} else {
|
|
@@ -47287,8 +47706,8 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47287
47706
|
function refreshDataTables(workbook, calc) {
|
|
47288
47707
|
const changed = [];
|
|
47289
47708
|
workbook.sheets.forEach((sheet, index3) => {
|
|
47290
|
-
for (const
|
|
47291
|
-
changed.push(...computeDataTable(workbook, calc, index3,
|
|
47709
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
47710
|
+
changed.push(...computeDataTable(workbook, calc, index3, table4));
|
|
47292
47711
|
});
|
|
47293
47712
|
if (changed.length) calc.recalculateFrom(changed);
|
|
47294
47713
|
}
|
|
@@ -47311,23 +47730,23 @@ function resolve2(sheet, request) {
|
|
|
47311
47730
|
const ref = cellRange(range2.start.row + 1, range2.start.col + 1, range2.end.row, range2.end.col);
|
|
47312
47731
|
if ([row3, col].some((p) => p && rangeContains(ref, p))) return { problem: "input-inside" };
|
|
47313
47732
|
const name3 = (p) => formatAddress(p);
|
|
47314
|
-
const
|
|
47733
|
+
const table4 = { ref, r1: "" };
|
|
47315
47734
|
if (row3 && col) {
|
|
47316
|
-
|
|
47317
|
-
|
|
47318
|
-
|
|
47319
|
-
|
|
47735
|
+
table4.dt2D = true;
|
|
47736
|
+
table4.dtr = true;
|
|
47737
|
+
table4.r1 = name3(row3);
|
|
47738
|
+
table4.r2 = name3(col);
|
|
47320
47739
|
} else if (row3) {
|
|
47321
|
-
|
|
47322
|
-
|
|
47323
|
-
} else if (col)
|
|
47324
|
-
return { table:
|
|
47740
|
+
table4.dtr = true;
|
|
47741
|
+
table4.r1 = name3(row3);
|
|
47742
|
+
} else if (col) table4.r1 = name3(col);
|
|
47743
|
+
return { table: table4 };
|
|
47325
47744
|
}
|
|
47326
47745
|
function createDataTable(ctx, s, request) {
|
|
47327
47746
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47328
47747
|
const result2 = resolve2(sheet, request);
|
|
47329
47748
|
if ("problem" in result2) throw new Error(MESSAGES[result2.problem]);
|
|
47330
|
-
const { table:
|
|
47749
|
+
const { table: table4 } = result2;
|
|
47331
47750
|
const range2 = normalizeRange(request.range);
|
|
47332
47751
|
ctx.run(
|
|
47333
47752
|
"Data Table",
|
|
@@ -47338,16 +47757,16 @@ function createDataTable(ctx, s, request) {
|
|
|
47338
47757
|
],
|
|
47339
47758
|
() => {
|
|
47340
47759
|
sheet.dataTables = (sheet.dataTables ?? []).filter((t) => !rangesIntersect(t.ref, range2));
|
|
47341
|
-
sheet.dataTables.push(
|
|
47342
|
-
for (let row3 =
|
|
47343
|
-
for (let col =
|
|
47760
|
+
sheet.dataTables.push(table4);
|
|
47761
|
+
for (let row3 = table4.ref.start.row; row3 <= table4.ref.end.row; row3++)
|
|
47762
|
+
for (let col = table4.ref.start.col; col <= table4.ref.end.col; col++) {
|
|
47344
47763
|
const cell = ensureCell(sheet, row3, col);
|
|
47345
47764
|
delete cell.formula;
|
|
47346
47765
|
delete cell.arrayRange;
|
|
47347
47766
|
delete cell.legacyFormula;
|
|
47348
47767
|
delete cell.dynamicArray;
|
|
47349
47768
|
}
|
|
47350
|
-
computeDataTable(ctx.workbook, ctx.calc, s,
|
|
47769
|
+
computeDataTable(ctx.workbook, ctx.calc, s, table4);
|
|
47351
47770
|
},
|
|
47352
47771
|
{ sheet: s, ranges: [range2] }
|
|
47353
47772
|
);
|
|
@@ -48216,7 +48635,7 @@ function addScenario(ctx, s, draft) {
|
|
|
48216
48635
|
}
|
|
48217
48636
|
function editScenario(ctx, s, index3, draft) {
|
|
48218
48637
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48219
|
-
const existing = scenariosOf(sheet)[index3];
|
|
48638
|
+
const existing = Number.isInteger(index3) ? scenariosOf(sheet)[index3] : void 0;
|
|
48220
48639
|
if (!existing) throw new ScenarioError("missing");
|
|
48221
48640
|
if (existing.locked && sheet.protection) throw new ScenarioError("locked");
|
|
48222
48641
|
const name3 = checkName(sheet, draft.name, index3);
|
|
@@ -48227,7 +48646,7 @@ function editScenario(ctx, s, index3, draft) {
|
|
|
48227
48646
|
}
|
|
48228
48647
|
function deleteScenario(ctx, s, index3) {
|
|
48229
48648
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48230
|
-
const existing = scenariosOf(sheet)[index3];
|
|
48649
|
+
const existing = Number.isInteger(index3) ? scenariosOf(sheet)[index3] : void 0;
|
|
48231
48650
|
if (!existing) throw new ScenarioError("missing");
|
|
48232
48651
|
if (existing.locked && sheet.protection) throw new ScenarioError("locked");
|
|
48233
48652
|
ctx.run("Delete scenario", "view", PARTS2(s), () => {
|
|
@@ -48664,7 +49083,7 @@ function plan(ctx, s, pivot, old) {
|
|
|
48664
49083
|
if (![start.row, start.col].every(Number.isInteger) || start.row < 0 || start.col < 0 || location.end.row > MAX_ROW || location.end.col > MAX_COL)
|
|
48665
49084
|
throw new Error("The PivotTable result does not fit on the worksheet.");
|
|
48666
49085
|
const source2 = sparklineDataRange(ctx.workbook, s, pivot.source);
|
|
48667
|
-
if (source2.sheet === s && rangesIntersect(source2.range, location) || sheet.merges.some((range2) => rangesIntersect(range2, location)) || sheet.tables.some((
|
|
49086
|
+
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)))
|
|
48668
49087
|
throw new Error("The PivotTable would overlap source data, another table or merged cells.");
|
|
48669
49088
|
let occupied = false;
|
|
48670
49089
|
forEachCellInRange(sheet, location, (cell, row3, col) => {
|
|
@@ -48674,12 +49093,12 @@ function plan(ctx, s, pivot, old) {
|
|
|
48674
49093
|
if (occupied) throw new Error("The PivotTable would overwrite existing cell content.");
|
|
48675
49094
|
return { grid, location };
|
|
48676
49095
|
}
|
|
48677
|
-
function writePivot(ctx, s, pivot, old,
|
|
49096
|
+
function writePivot(ctx, s, pivot, old, label2, inside2) {
|
|
48678
49097
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48679
49098
|
const { grid, location } = plan(ctx, s, pivot, old);
|
|
48680
49099
|
const ranges = [...old ? [old.location] : [], location];
|
|
48681
49100
|
ctx.run(
|
|
48682
|
-
|
|
49101
|
+
label2 ?? (old ? "Refresh PivotTable" : "Create PivotTable"),
|
|
48683
49102
|
"annotations",
|
|
48684
49103
|
[
|
|
48685
49104
|
{ kind: "parts", sheet: s, parts: ["pivotTables"] },
|
|
@@ -48736,8 +49155,10 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
48736
49155
|
const name3 = options.name ?? uniqueName(ctx);
|
|
48737
49156
|
checkName2(ctx, name3);
|
|
48738
49157
|
const aggregate2 = options.aggregate ?? "sum";
|
|
49158
|
+
const captions = authoredCaptions(options);
|
|
48739
49159
|
const pivot = {
|
|
48740
49160
|
...data,
|
|
49161
|
+
...captions ? { captions } : {},
|
|
48741
49162
|
name: name3,
|
|
48742
49163
|
rowField: options.rowField,
|
|
48743
49164
|
layout: options.layout ?? "tabular",
|
|
@@ -48751,12 +49172,12 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
48751
49172
|
...options.repeatLabels !== void 0 ? { repeatLabels: options.repeatLabels } : {},
|
|
48752
49173
|
valueField: options.valueField,
|
|
48753
49174
|
aggregate: aggregate2,
|
|
48754
|
-
valueCaption: pivotCaption(aggregate2, options.valueField),
|
|
49175
|
+
valueCaption: pivotCaption(aggregate2, options.valueField, { captions }),
|
|
48755
49176
|
...options.pageFilter !== void 0 ? { pageFilter: structuredClone(options.pageFilter) } : {},
|
|
48756
49177
|
...options.fieldGroups?.length ? { fieldGroups: structuredClone(options.fieldGroups) } : {},
|
|
48757
49178
|
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
48758
49179
|
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
48759
|
-
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
49180
|
+
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues, { captions }) } : {},
|
|
48760
49181
|
location: { start: { ...destination }, end: { ...destination } },
|
|
48761
49182
|
...options.columnField ? { columnField: options.columnField } : {},
|
|
48762
49183
|
...options.columnField && options.moreColumnFields?.length ? { moreColumnFields: [...options.moreColumnFields] } : {}
|
|
@@ -48779,7 +49200,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
48779
49200
|
rowField: patch2.rowField ?? old.rowField,
|
|
48780
49201
|
valueField,
|
|
48781
49202
|
aggregate: aggregate2,
|
|
48782
|
-
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField)
|
|
49203
|
+
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField, old)
|
|
48783
49204
|
};
|
|
48784
49205
|
if (patch2.columnField !== void 0) {
|
|
48785
49206
|
if (patch2.columnField) next.columnField = patch2.columnField;
|
|
@@ -48829,7 +49250,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
48829
49250
|
else if (patch2.valuesAxis === "columns" || patch2.secondRowField === "")
|
|
48830
49251
|
delete next.valuesPosition;
|
|
48831
49252
|
if (patch2.additionalValues !== void 0) {
|
|
48832
|
-
const measures2 = normalizedPivotMeasures(patch2.additionalValues);
|
|
49253
|
+
const measures2 = normalizedPivotMeasures(patch2.additionalValues, old);
|
|
48833
49254
|
if (measures2.length) next.additionalValues = measures2;
|
|
48834
49255
|
else delete next.additionalValues;
|
|
48835
49256
|
}
|
|
@@ -49003,7 +49424,10 @@ function insertTimeline(ctx, s, ref) {
|
|
|
49003
49424
|
const id3 = Math.max(
|
|
49004
49425
|
1,
|
|
49005
49426
|
...sheet.drawings.flatMap(
|
|
49006
|
-
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(
|
|
49427
|
+
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(/<[\w:]*cNvPr\b[^>]*>/g)].flatMap((m) => {
|
|
49428
|
+
const id4 = /\sid="(\d+)"/.exec(m[0])?.[1];
|
|
49429
|
+
return id4 ? [Number(id4)] : [];
|
|
49430
|
+
}) : []
|
|
49007
49431
|
)
|
|
49008
49432
|
) + 1;
|
|
49009
49433
|
ctx.run(
|
|
@@ -49299,10 +49723,10 @@ function validatePatch(group, patch2) {
|
|
|
49299
49723
|
delete next.manualMax;
|
|
49300
49724
|
validateSettings(next);
|
|
49301
49725
|
}
|
|
49302
|
-
function save2(ctx, s, next,
|
|
49726
|
+
function save2(ctx, s, next, label2, ranges) {
|
|
49303
49727
|
const sheet = sheetAt(ctx.workbook, s);
|
|
49304
49728
|
ctx.run(
|
|
49305
|
-
|
|
49729
|
+
label2,
|
|
49306
49730
|
"annotations",
|
|
49307
49731
|
[{ kind: "parts", sheet: s, parts: ["preserved"] }],
|
|
49308
49732
|
() => sheet.preserved.set("extLst", next),
|
|
@@ -49420,20 +49844,20 @@ function setSlicerSelection(ctx, cacheName, keys) {
|
|
|
49420
49844
|
const target2 = slicerTarget(ctx.workbook, cache3);
|
|
49421
49845
|
if (!target2) throw new Error("The slicer has no data source.");
|
|
49422
49846
|
if (target2.kind === "table") {
|
|
49423
|
-
const { sheet, table:
|
|
49847
|
+
const { sheet, table: table4, offset: offset2 } = target2;
|
|
49424
49848
|
ctx.run(
|
|
49425
49849
|
keys === null ? "Clear slicer filter" : "Filter slicer",
|
|
49426
49850
|
"view",
|
|
49427
49851
|
[{ kind: "sheet", sheet: target2.sheetIndex }],
|
|
49428
49852
|
() => {
|
|
49429
|
-
const column2 =
|
|
49853
|
+
const column2 = table4.columns[offset2];
|
|
49430
49854
|
if (keys === null) delete column2.filter;
|
|
49431
49855
|
else
|
|
49432
49856
|
column2.filter = {
|
|
49433
49857
|
values: keys.filter((key2) => key2 !== ""),
|
|
49434
49858
|
...keys.includes("") ? { blank: true } : {}
|
|
49435
49859
|
};
|
|
49436
|
-
applyTableFilter(ctx.workbook, sheet,
|
|
49860
|
+
applyTableFilter(ctx.workbook, sheet, table4);
|
|
49437
49861
|
},
|
|
49438
49862
|
{ sheet: target2.sheetIndex, structural: true }
|
|
49439
49863
|
);
|
|
@@ -49504,17 +49928,17 @@ function unique2(base2, taken) {
|
|
|
49504
49928
|
function insertSlicer(ctx, s, ref) {
|
|
49505
49929
|
const { workbook } = ctx;
|
|
49506
49930
|
const sheet = sheetAt(workbook, s);
|
|
49507
|
-
let
|
|
49931
|
+
let table4;
|
|
49508
49932
|
let pivot;
|
|
49509
49933
|
let field2;
|
|
49510
49934
|
if (ref.kind === "table") {
|
|
49511
|
-
|
|
49935
|
+
table4 = sheet.tables.find(
|
|
49512
49936
|
(entry3) => entry3.name === ref.table || entry3.displayName === ref.table
|
|
49513
49937
|
);
|
|
49514
|
-
if (!
|
|
49938
|
+
if (!table4?.headerRow || table4.filterNotModeled)
|
|
49515
49939
|
throw new Error("Choose a table with a header row and value filters.");
|
|
49516
49940
|
field2 = ref.column;
|
|
49517
|
-
if (!
|
|
49941
|
+
if (!table4.columns.some((column2) => column2.name === field2))
|
|
49518
49942
|
throw new Error("Choose a column of the table.");
|
|
49519
49943
|
} else {
|
|
49520
49944
|
pivot = sheet.pivotTables?.find((entry3) => entry3.name === ref.pivot);
|
|
@@ -49534,14 +49958,17 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49534
49958
|
(c2) => names.has(c2.toLowerCase())
|
|
49535
49959
|
).replace(/ /g, "_");
|
|
49536
49960
|
const metrics = createGridMetrics(sheet, { zoom: 100 });
|
|
49537
|
-
const anchorCell =
|
|
49961
|
+
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 };
|
|
49538
49962
|
const x = Math.max(metrics.colLeft(anchorCell.col), frameBounds(sheet) + 10);
|
|
49539
49963
|
const box5 = { x, y: metrics.rowTop(anchorCell.row), ...SLICER_BOX };
|
|
49540
49964
|
const anchor = pixelBoxToAnchor(sheet, box5, metrics, "twoCell");
|
|
49541
49965
|
const id3 = Math.max(
|
|
49542
49966
|
1,
|
|
49543
49967
|
...sheet.drawings.flatMap(
|
|
49544
|
-
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(
|
|
49968
|
+
(d) => "sourceXml" in d && d.sourceXml ? [...d.sourceXml.matchAll(/<[\w:]*cNvPr\b[^>]*>/g)].flatMap((m) => {
|
|
49969
|
+
const id4 = /\sid="(\d+)"/.exec(m[0])?.[1];
|
|
49970
|
+
return id4 ? [Number(id4)] : [];
|
|
49971
|
+
}) : []
|
|
49545
49972
|
)
|
|
49546
49973
|
) + 1;
|
|
49547
49974
|
ctx.run(
|
|
@@ -49551,13 +49978,13 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49551
49978
|
() => {
|
|
49552
49979
|
const book = cloneBook(workbook);
|
|
49553
49980
|
let source2;
|
|
49554
|
-
if (
|
|
49555
|
-
if (
|
|
49556
|
-
|
|
49981
|
+
if (table4) {
|
|
49982
|
+
if (table4.columns.some((column2) => column2.sourceId === void 0))
|
|
49983
|
+
table4.columns.forEach((column2, index3) => column2.sourceId ??= index3 + 1);
|
|
49557
49984
|
source2 = {
|
|
49558
49985
|
kind: "table",
|
|
49559
|
-
tableId:
|
|
49560
|
-
column:
|
|
49986
|
+
tableId: table4.id,
|
|
49987
|
+
column: table4.columns.find((column2) => column2.name === field2).sourceId
|
|
49561
49988
|
};
|
|
49562
49989
|
} else {
|
|
49563
49990
|
const target2 = pivot;
|
|
@@ -50043,9 +50470,9 @@ var SUBTOTAL = {
|
|
|
50043
50470
|
var: 110
|
|
50044
50471
|
};
|
|
50045
50472
|
var escapeColumn = (name3) => name3.replace(/['#[\]]/g, "'$&");
|
|
50046
|
-
function applyTotalsRow(sheet,
|
|
50047
|
-
const row3 =
|
|
50048
|
-
const { columns } =
|
|
50473
|
+
function applyTotalsRow(sheet, table4) {
|
|
50474
|
+
const row3 = table4.range.end.row;
|
|
50475
|
+
const { columns } = table4;
|
|
50049
50476
|
if (!columns.some((c2) => c2.totalsRowFunction || c2.totalsRowLabel)) {
|
|
50050
50477
|
const first3 = columns[0];
|
|
50051
50478
|
const last = columns[columns.length - 1];
|
|
@@ -50053,12 +50480,12 @@ function applyTotalsRow(sheet, table3) {
|
|
|
50053
50480
|
if (last) last.totalsRowFunction = "sum";
|
|
50054
50481
|
}
|
|
50055
50482
|
columns.forEach((column2, i2) => {
|
|
50056
|
-
const col =
|
|
50483
|
+
const col = table4.range.start.col + i2;
|
|
50057
50484
|
const code = SUBTOTAL[column2.totalsRowFunction ?? ""];
|
|
50058
50485
|
if (code !== void 0) {
|
|
50059
50486
|
const cell = ensureCell(sheet, row3, col);
|
|
50060
50487
|
clearContents(cell);
|
|
50061
|
-
cell.formula = `SUBTOTAL(${code},${
|
|
50488
|
+
cell.formula = `SUBTOTAL(${code},${table4.name}[${escapeColumn(column2.name)}])`;
|
|
50062
50489
|
} else if (column2.totalsRowLabel && column2.totalsRowFunction !== "custom")
|
|
50063
50490
|
writeValue(sheet, row3, col, column2.totalsRowLabel);
|
|
50064
50491
|
});
|
|
@@ -50082,8 +50509,8 @@ function validateTableName(workbook, name3, self) {
|
|
|
50082
50509
|
) || workbook.definedNames.some((n) => n.name.toLowerCase() === lower3);
|
|
50083
50510
|
return taken ? "That name is already used by another table or name." : void 0;
|
|
50084
50511
|
}
|
|
50085
|
-
function renameTableIn(workbook,
|
|
50086
|
-
const old =
|
|
50512
|
+
function renameTableIn(workbook, table4, name3) {
|
|
50513
|
+
const old = table4.name;
|
|
50087
50514
|
if (old === name3) return;
|
|
50088
50515
|
const rename = (f6) => renameTableInFormula(f6, old, name3);
|
|
50089
50516
|
rewriteFormulas(workbook, rename);
|
|
@@ -50092,73 +50519,73 @@ function renameTableIn(workbook, table3, name3) {
|
|
|
50092
50519
|
for (const column2 of t.columns)
|
|
50093
50520
|
if (column2.calculatedColumnFormula)
|
|
50094
50521
|
column2.calculatedColumnFormula = rename(column2.calculatedColumnFormula);
|
|
50095
|
-
|
|
50096
|
-
|
|
50522
|
+
table4.name = name3;
|
|
50523
|
+
table4.displayName = name3;
|
|
50097
50524
|
}
|
|
50098
50525
|
var byId = (sheet, id3) => {
|
|
50099
|
-
const
|
|
50100
|
-
if (!
|
|
50101
|
-
return
|
|
50526
|
+
const table4 = sheet.tables.find((t) => t.id === id3);
|
|
50527
|
+
if (!table4) throw new Error("The table disappeared during the edit.");
|
|
50528
|
+
return table4;
|
|
50102
50529
|
};
|
|
50103
|
-
function insertBandRow(workbook, sheet,
|
|
50530
|
+
function insertBandRow(workbook, sheet, table4, row3) {
|
|
50104
50531
|
const shift2 = { axis: "row", at: row3, count: 1 };
|
|
50105
|
-
const band2 = { lo:
|
|
50532
|
+
const band2 = { lo: table4.range.start.col, hi: table4.range.end.col };
|
|
50106
50533
|
assertInsertFits(sheet, shift2, band2);
|
|
50107
50534
|
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band2));
|
|
50108
50535
|
shiftSheetContent(sheet, shift2, band2);
|
|
50109
50536
|
}
|
|
50110
50537
|
function setHeaderRow(workbook, sheet, id3, on) {
|
|
50111
|
-
let
|
|
50112
|
-
if (
|
|
50113
|
-
const { start, end } =
|
|
50538
|
+
let table4 = byId(sheet, id3);
|
|
50539
|
+
if (table4.headerRow === on) return;
|
|
50540
|
+
const { start, end } = table4.range;
|
|
50114
50541
|
if (!on) {
|
|
50115
50542
|
if (start.row === end.row) throw new Error("A table needs at least one row.");
|
|
50116
50543
|
clearRow(sheet, start.row, start.col, end.col);
|
|
50117
|
-
|
|
50118
|
-
|
|
50544
|
+
table4.range = { start: { row: start.row + 1, col: start.col }, end };
|
|
50545
|
+
table4.headerRow = false;
|
|
50119
50546
|
return;
|
|
50120
50547
|
}
|
|
50121
50548
|
if (start.row === 0 || !rowIsEmpty(sheet, start.row - 1, start.col, end.col)) {
|
|
50122
|
-
insertBandRow(workbook, sheet,
|
|
50123
|
-
|
|
50124
|
-
}
|
|
50125
|
-
const top =
|
|
50126
|
-
const left2 =
|
|
50127
|
-
|
|
50128
|
-
|
|
50129
|
-
uniqueHeaders(
|
|
50130
|
-
const column2 =
|
|
50549
|
+
insertBandRow(workbook, sheet, table4, start.row);
|
|
50550
|
+
table4 = byId(sheet, id3);
|
|
50551
|
+
}
|
|
50552
|
+
const top = table4.range.start.row - 1;
|
|
50553
|
+
const left2 = table4.range.start.col;
|
|
50554
|
+
table4.range = { start: { row: top, col: left2 }, end: table4.range.end };
|
|
50555
|
+
table4.headerRow = true;
|
|
50556
|
+
uniqueHeaders(table4.columns.map((c2) => c2.name)).forEach((name3, i2) => {
|
|
50557
|
+
const column2 = table4.columns[i2];
|
|
50131
50558
|
if (column2) column2.name = name3;
|
|
50132
50559
|
writeValue(sheet, top, left2 + i2, name3);
|
|
50133
50560
|
});
|
|
50134
50561
|
}
|
|
50135
50562
|
function setTotalsRow(workbook, sheet, id3, on) {
|
|
50136
|
-
let
|
|
50137
|
-
if (
|
|
50138
|
-
const { start, end } =
|
|
50563
|
+
let table4 = byId(sheet, id3);
|
|
50564
|
+
if (table4.totalsRow === on) return;
|
|
50565
|
+
const { start, end } = table4.range;
|
|
50139
50566
|
if (!on) {
|
|
50140
50567
|
clearRow(sheet, end.row, start.col, end.col);
|
|
50141
|
-
|
|
50142
|
-
|
|
50568
|
+
table4.range = { start, end: { row: end.row - 1, col: end.col } };
|
|
50569
|
+
table4.totalsRow = false;
|
|
50143
50570
|
return;
|
|
50144
50571
|
}
|
|
50145
50572
|
if (end.row === MAX_ROW) throw new RangeError("The insert area extends beyond the sheet.");
|
|
50146
50573
|
if (!rowIsEmpty(sheet, end.row + 1, start.col, end.col)) {
|
|
50147
|
-
insertBandRow(workbook, sheet,
|
|
50148
|
-
|
|
50574
|
+
insertBandRow(workbook, sheet, table4, end.row + 1);
|
|
50575
|
+
table4 = byId(sheet, id3);
|
|
50149
50576
|
}
|
|
50150
|
-
|
|
50151
|
-
|
|
50152
|
-
applyTotalsRow(sheet,
|
|
50577
|
+
table4.range = { start: table4.range.start, end: { row: table4.range.end.row + 1, col: end.col } };
|
|
50578
|
+
table4.totalsRow = true;
|
|
50579
|
+
applyTotalsRow(sheet, table4);
|
|
50153
50580
|
}
|
|
50154
|
-
function resizedColumns(workbook, sheet,
|
|
50581
|
+
function resizedColumns(workbook, sheet, table4, range2) {
|
|
50155
50582
|
const width = range2.end.col - range2.start.col + 1;
|
|
50156
|
-
const oldAt = (col) => col >=
|
|
50583
|
+
const oldAt = (col) => col >= table4.range.start.col && col <= table4.range.end.col ? table4.columns[col - table4.range.start.col] : void 0;
|
|
50157
50584
|
const texts = Array.from({ length: width }, (_v, i2) => {
|
|
50158
50585
|
const col = range2.start.col + i2;
|
|
50159
50586
|
const old = oldAt(col);
|
|
50160
50587
|
if (old) return old.name;
|
|
50161
|
-
return
|
|
50588
|
+
return table4.headerRow ? displayText(workbook, getCell(sheet, range2.start.row, col)) : "";
|
|
50162
50589
|
});
|
|
50163
50590
|
return uniqueHeaders(texts).map((name3, i2) => {
|
|
50164
50591
|
const old = oldAt(range2.start.col + i2);
|
|
@@ -50166,30 +50593,30 @@ function resizedColumns(workbook, sheet, table3, range2) {
|
|
|
50166
50593
|
});
|
|
50167
50594
|
}
|
|
50168
50595
|
function resizeTableIn(workbook, sheet, id3, range2) {
|
|
50169
|
-
const
|
|
50596
|
+
const table4 = byId(sheet, id3);
|
|
50170
50597
|
const r = normalizeRange(range2);
|
|
50171
|
-
if (
|
|
50598
|
+
if (table4.headerRow && r.start.row !== table4.range.start.row)
|
|
50172
50599
|
throw new Error("The table headers must remain in the same row.");
|
|
50173
|
-
if (!rangesIntersect(r,
|
|
50174
|
-
if (r.end.row - r.start.row + 1 < (
|
|
50600
|
+
if (!rangesIntersect(r, table4.range)) throw new Error("The new range must overlap the table.");
|
|
50601
|
+
if (r.end.row - r.start.row + 1 < (table4.headerRow ? 2 : 1) + (table4.totalsRow ? 1 : 0))
|
|
50175
50602
|
throw new Error("The table range is too small.");
|
|
50176
|
-
if (sheet.tables.some((t) => t !==
|
|
50603
|
+
if (sheet.tables.some((t) => t !== table4 && rangesIntersect(t.range, r)))
|
|
50177
50604
|
throw new Error("A table cannot overlap another table.");
|
|
50178
50605
|
if (sheet.pivotTables?.some((pivot) => rangesIntersect(pivot.location, r)))
|
|
50179
50606
|
throw new Error("A table cannot overlap a PivotTable.");
|
|
50180
50607
|
if (sheet.merges.some((m) => rangesIntersect(m, r)))
|
|
50181
50608
|
throw new Error("A table cannot contain merged cells.");
|
|
50182
|
-
const oldEnd =
|
|
50183
|
-
|
|
50184
|
-
|
|
50185
|
-
if (
|
|
50186
|
-
|
|
50609
|
+
const oldEnd = table4.range.end.row;
|
|
50610
|
+
table4.columns = resizedColumns(workbook, sheet, table4, r);
|
|
50611
|
+
table4.range = r;
|
|
50612
|
+
if (table4.headerRow)
|
|
50613
|
+
table4.columns.forEach((column2, i2) => {
|
|
50187
50614
|
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
50188
50615
|
if (cell?.value !== column2.name) writeValue(sheet, r.start.row, r.start.col + i2, column2.name);
|
|
50189
50616
|
});
|
|
50190
|
-
if (
|
|
50617
|
+
if (table4.totalsRow) {
|
|
50191
50618
|
if (oldEnd !== r.end.row) clearRow(sheet, oldEnd, r.start.col, r.end.col);
|
|
50192
|
-
applyTotalsRow(sheet,
|
|
50619
|
+
applyTotalsRow(sheet, table4);
|
|
50193
50620
|
}
|
|
50194
50621
|
}
|
|
50195
50622
|
var STYLE_KEYS = [
|
|
@@ -50217,20 +50644,20 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50217
50644
|
"structure",
|
|
50218
50645
|
[scope],
|
|
50219
50646
|
() => {
|
|
50220
|
-
const
|
|
50221
|
-
if (renaming) renameTableIn(workbook,
|
|
50647
|
+
const table4 = byId(sheet, id3);
|
|
50648
|
+
if (renaming) renameTableIn(workbook, table4, name3);
|
|
50222
50649
|
for (const key2 of STYLE_KEYS) {
|
|
50223
50650
|
if (!(key2 in patch2)) continue;
|
|
50224
50651
|
const value2 = patch2[key2];
|
|
50225
|
-
if (value2 === void 0) delete
|
|
50226
|
-
else
|
|
50652
|
+
if (value2 === void 0) delete table4[key2];
|
|
50653
|
+
else table4[key2] = value2;
|
|
50227
50654
|
}
|
|
50228
50655
|
if (patch2.columns) {
|
|
50229
|
-
const width =
|
|
50656
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
50230
50657
|
if (patch2.columns.length !== width) throw new Error("Give one column per table column.");
|
|
50231
|
-
const before =
|
|
50232
|
-
|
|
50233
|
-
for (const [index3, column2] of
|
|
50658
|
+
const before = table4.columns;
|
|
50659
|
+
table4.columns = structuredClone(patch2.columns);
|
|
50660
|
+
for (const [index3, column2] of table4.columns.entries()) {
|
|
50234
50661
|
const sourceId = before[index3]?.sourceId;
|
|
50235
50662
|
if (column2.sourceId === void 0 && sourceId !== void 0) column2.sourceId = sourceId;
|
|
50236
50663
|
const filter2 = before[index3]?.filter;
|
|
@@ -50239,7 +50666,7 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50239
50666
|
}
|
|
50240
50667
|
if (patch2.headerRow !== void 0) setHeaderRow(workbook, sheet, id3, patch2.headerRow);
|
|
50241
50668
|
if (patch2.totalsRow !== void 0) setTotalsRow(workbook, sheet, id3, patch2.totalsRow);
|
|
50242
|
-
else if (patch2.columns &&
|
|
50669
|
+
else if (patch2.columns && table4.totalsRow) applyTotalsRow(sheet, byId(sheet, id3));
|
|
50243
50670
|
if (patch2.range) resizeTableIn(workbook, sheet, id3, patch2.range);
|
|
50244
50671
|
},
|
|
50245
50672
|
{ sheet: s, ranges: [current.range], structural: true }
|
|
@@ -50259,13 +50686,13 @@ function resizeTable(ctx, s, ref, range2) {
|
|
|
50259
50686
|
function convertTableToRange(ctx, s, ref) {
|
|
50260
50687
|
const { workbook } = ctx;
|
|
50261
50688
|
const sheet = sheetAt(workbook, s);
|
|
50262
|
-
const
|
|
50689
|
+
const table4 = sheet.tables[tableIndex(sheet, ref)];
|
|
50263
50690
|
ctx.run(
|
|
50264
50691
|
"Convert to range",
|
|
50265
50692
|
"structure",
|
|
50266
50693
|
[{ kind: "workbook" }],
|
|
50267
50694
|
() => {
|
|
50268
|
-
const live2 = byId(sheet,
|
|
50695
|
+
const live2 = byId(sheet, table4.id);
|
|
50269
50696
|
const base2 = { table: live2, tableSheet: sheet.name };
|
|
50270
50697
|
const { start, end } = live2.range;
|
|
50271
50698
|
for (const ws of workbook.sheets)
|
|
@@ -50290,7 +50717,7 @@ function convertTableToRange(ctx, s, ref) {
|
|
|
50290
50717
|
});
|
|
50291
50718
|
sheet.tables = sheet.tables.filter((t) => t.id !== live2.id);
|
|
50292
50719
|
},
|
|
50293
|
-
{ sheet: s, ranges: [
|
|
50720
|
+
{ sheet: s, ranges: [table4.range], structural: true }
|
|
50294
50721
|
);
|
|
50295
50722
|
}
|
|
50296
50723
|
|
|
@@ -53196,7 +53623,7 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53196
53623
|
});
|
|
53197
53624
|
const name3 = nextTableName(workbook);
|
|
53198
53625
|
const id3 = Math.max(0, ...workbook.sheets.flatMap((ws) => ws.tables.map((t) => t.id))) + 1;
|
|
53199
|
-
const
|
|
53626
|
+
const table4 = {
|
|
53200
53627
|
id: id3,
|
|
53201
53628
|
name: name3,
|
|
53202
53629
|
displayName: name3,
|
|
@@ -53210,8 +53637,8 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53210
53637
|
showFirstColumn: false,
|
|
53211
53638
|
showLastColumn: false
|
|
53212
53639
|
};
|
|
53213
|
-
sheet.tables.push(
|
|
53214
|
-
return
|
|
53640
|
+
sheet.tables.push(table4);
|
|
53641
|
+
return table4;
|
|
53215
53642
|
},
|
|
53216
53643
|
{ sheet: s, ranges: [r], structural: !hasHeader }
|
|
53217
53644
|
);
|
|
@@ -53415,8 +53842,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
53415
53842
|
if (!workbook.warnings.includes(message)) workbook.warnings.push(message);
|
|
53416
53843
|
}
|
|
53417
53844
|
};
|
|
53418
|
-
const begin = (
|
|
53419
|
-
const step2 = { label:
|
|
53845
|
+
const begin = (label2, kind, info) => {
|
|
53846
|
+
const step2 = { label: label2, entries: [], structural: info.structural ?? false };
|
|
53420
53847
|
if (info.calc) step2.calc = info.calc;
|
|
53421
53848
|
return { step: step2, kind, sheet: info.sheet, ranges: [...info.ranges ?? []] };
|
|
53422
53849
|
};
|
|
@@ -53440,7 +53867,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53440
53867
|
}
|
|
53441
53868
|
current.step.entries.length = from;
|
|
53442
53869
|
};
|
|
53443
|
-
const run2 = (
|
|
53870
|
+
const run2 = (label2, kind, scopes, fn, info = {}) => {
|
|
53444
53871
|
if (kind === "cells") {
|
|
53445
53872
|
for (const scope of scopes)
|
|
53446
53873
|
if (scope.kind === "cells" && workbook.sheets[scope.sheet]?.pivotTables?.some(
|
|
@@ -53457,7 +53884,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53457
53884
|
}))
|
|
53458
53885
|
throw new Error(DATA_TABLE_PART_ERROR);
|
|
53459
53886
|
const outer = !open;
|
|
53460
|
-
const current = open ?? begin(
|
|
53887
|
+
const current = open ?? begin(label2, kind, info);
|
|
53461
53888
|
if (!outer) {
|
|
53462
53889
|
delete current.step.calc;
|
|
53463
53890
|
if (info.structural) current.step.structural = true;
|
|
@@ -53588,9 +54015,9 @@ function createEditSession(workbook, options = {}) {
|
|
|
53588
54015
|
removeConditionalFormat: (s, index3) => removeConditionalFormat(ctx, s, index3),
|
|
53589
54016
|
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
53590
54017
|
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
53591
|
-
updateTable: (s,
|
|
53592
|
-
resizeTable: (s,
|
|
53593
|
-
convertTableToRange: (s,
|
|
54018
|
+
updateTable: (s, table4, patch2) => updateTable(ctx, s, table4, patch2),
|
|
54019
|
+
resizeTable: (s, table4, range2) => resizeTable(ctx, s, table4, range2),
|
|
54020
|
+
convertTableToRange: (s, table4) => convertTableToRange(ctx, s, table4),
|
|
53594
54021
|
applyCellStyle: (s, ranges, name3) => applyCellStyle(ctx, s, ranges, name3),
|
|
53595
54022
|
setPageSetup: (s, patch2) => setPageSetup(ctx, s, patch2),
|
|
53596
54023
|
setPageBreak: (s, axis, before, present) => setPageBreak(ctx, s, axis, before, present),
|
|
@@ -53627,12 +54054,12 @@ function createEditSession(workbook, options = {}) {
|
|
|
53627
54054
|
validate: (s, r, c2, value2) => validateCellInput(workbook, s, r, c2, value2, {
|
|
53628
54055
|
evaluate: (formula, at2) => calc.evaluate(formula, at2)
|
|
53629
54056
|
}),
|
|
53630
|
-
batch(
|
|
54057
|
+
batch(label2, fn) {
|
|
53631
54058
|
if (open) {
|
|
53632
54059
|
fn();
|
|
53633
54060
|
return;
|
|
53634
54061
|
}
|
|
53635
|
-
const current = begin(
|
|
54062
|
+
const current = begin(label2, "batch", {});
|
|
53636
54063
|
open = current;
|
|
53637
54064
|
try {
|
|
53638
54065
|
fn();
|
|
@@ -54312,9 +54739,9 @@ var VisioPackage = class _VisioPackage {
|
|
|
54312
54739
|
};
|
|
54313
54740
|
|
|
54314
54741
|
// visio/metadata.ts
|
|
54315
|
-
function metadata(value2, max,
|
|
54742
|
+
function metadata(value2, max, label2) {
|
|
54316
54743
|
if (value2.length > max)
|
|
54317
|
-
throw new VisioPackageError("METADATA_LIMIT", `${
|
|
54744
|
+
throw new VisioPackageError("METADATA_LIMIT", `${label2} exceeds its metadata length limit.`);
|
|
54318
54745
|
return value2;
|
|
54319
54746
|
}
|
|
54320
54747
|
function metadataAttributes(node3) {
|
|
@@ -58266,15 +58693,15 @@ function legacyFillGradient(cells3, width, height, resolve3) {
|
|
|
58266
58693
|
|
|
58267
58694
|
// ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/utils/png-encoder.js
|
|
58268
58695
|
var CRC_TABLE = (() => {
|
|
58269
|
-
const
|
|
58696
|
+
const table4 = new Uint32Array(256);
|
|
58270
58697
|
for (let n = 0; n < 256; n++) {
|
|
58271
58698
|
let c2 = n;
|
|
58272
58699
|
for (let k = 0; k < 8; k++) {
|
|
58273
58700
|
c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
|
|
58274
58701
|
}
|
|
58275
|
-
|
|
58702
|
+
table4[n] = c2 >>> 0;
|
|
58276
58703
|
}
|
|
58277
|
-
return
|
|
58704
|
+
return table4;
|
|
58278
58705
|
})();
|
|
58279
58706
|
function crc322(bytes) {
|
|
58280
58707
|
let crc = 4294967295;
|
|
@@ -60948,7 +61375,7 @@ function property(row3, budget, report) {
|
|
|
60948
61375
|
"Shape data has no supported current cached typed value; original cached text is retained."
|
|
60949
61376
|
);
|
|
60950
61377
|
}
|
|
60951
|
-
const
|
|
61378
|
+
const label2 = get("Label"), format5 = get("Format"), prompt = get("Prompt"), sortKey = get("SortKey");
|
|
60952
61379
|
const invisible = boolean(row3.cells, "Invisible", budget, report);
|
|
60953
61380
|
const dataLinked = row3.cells.has("DataLinked") ? boolean(row3.cells, "DataLinked", budget, report) : void 0;
|
|
60954
61381
|
const unit3 = row3.cells.get("Value")?.unit, error = row3.cells.get("Value")?.error;
|
|
@@ -60960,7 +61387,7 @@ function property(row3, budget, report) {
|
|
|
60960
61387
|
...rawType === void 0 ? {} : { rawType },
|
|
60961
61388
|
...rawValue === void 0 ? {} : { rawValue },
|
|
60962
61389
|
...value2 === void 0 ? {} : { value: value2 },
|
|
60963
|
-
...
|
|
61390
|
+
...label2 === void 0 ? {} : { label: label2 },
|
|
60964
61391
|
...format5 === void 0 ? {} : { format: format5 },
|
|
60965
61392
|
...prompt === void 0 ? {} : { prompt },
|
|
60966
61393
|
...sortKey === void 0 ? {} : { sortKey },
|
|
@@ -61193,9 +61620,9 @@ async function readDataRecordsets(pkg, documentPart, check3) {
|
|
|
61193
61620
|
const declared = children3(children3(set, "DataColumns")[0], "DataColumn");
|
|
61194
61621
|
const columns = (declared.length ? declared : []).map((node3) => {
|
|
61195
61622
|
const name4 = attribute3(node3, "ColumnNameID") ?? attribute3(node3, "Name") ?? "";
|
|
61196
|
-
const
|
|
61197
|
-
if (!name4 || name4.length > 255 ||
|
|
61198
|
-
return { name: name4, label:
|
|
61623
|
+
const label2 = attribute3(node3, "Label") ?? attribute3(node3, "Name") ?? name4;
|
|
61624
|
+
if (!name4 || name4.length > 255 || label2.length > 255) invalid2("Invalid data column.");
|
|
61625
|
+
return { name: name4, label: label2, type: typeFromCode(attribute3(node3, "DataType")) };
|
|
61199
61626
|
});
|
|
61200
61627
|
if (!columns.length)
|
|
61201
61628
|
for (const column2 of ado.columns)
|
|
@@ -67858,18 +68285,18 @@ function advances(family, bold) {
|
|
|
67858
68285
|
const key2 = `${name3}|${bold ? "b" : "r"}`;
|
|
67859
68286
|
const known = decoded.get(key2);
|
|
67860
68287
|
if (known) return known;
|
|
67861
|
-
const
|
|
67862
|
-
if (!
|
|
67863
|
-
const values2 = (bold ?
|
|
68288
|
+
const table4 = Object.hasOwn(DESIGN_ADVANCES, name3) ? DESIGN_ADVANCES[name3] : void 0;
|
|
68289
|
+
if (!table4) return void 0;
|
|
68290
|
+
const values2 = (bold ? table4.bold : table4.regular).split(" ").map(Number);
|
|
67864
68291
|
decoded.set(key2, values2);
|
|
67865
68292
|
return values2;
|
|
67866
68293
|
}
|
|
67867
68294
|
function designTextWidthEm(text8, family, bold = false) {
|
|
67868
|
-
const
|
|
67869
|
-
if (!
|
|
68295
|
+
const table4 = advances(family, bold);
|
|
68296
|
+
if (!table4) return void 0;
|
|
67870
68297
|
let units2 = 0;
|
|
67871
68298
|
for (let index3 = 0; index3 < text8.length; ++index3) {
|
|
67872
|
-
const advance =
|
|
68299
|
+
const advance = table4[text8.charCodeAt(index3) - FIRST];
|
|
67873
68300
|
if (advance === void 0 || Number.isNaN(advance)) return void 0;
|
|
67874
68301
|
units2 += advance;
|
|
67875
68302
|
}
|
|
@@ -71080,9 +71507,9 @@ function visioBorderShapes(style3, width, height, title = VISIO_DEFAULT_TITLE) {
|
|
|
71080
71507
|
// visio/edit-page-setup-commands.ts
|
|
71081
71508
|
var VISIO_SCALE_UNITS = Object.freeze(["IN", "FT", "MM", "CM", "M"]);
|
|
71082
71509
|
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";
|
|
71083
|
-
var pageId = (value2,
|
|
71510
|
+
var pageId = (value2, label2) => {
|
|
71084
71511
|
if (typeof value2 !== "string" || !value2 || value2.length > 256)
|
|
71085
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71512
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71086
71513
|
return value2;
|
|
71087
71514
|
};
|
|
71088
71515
|
var newPageId = (value2) => {
|
|
@@ -71189,11 +71616,11 @@ var VISIO_SHAPE_DATA_TYPES = [
|
|
|
71189
71616
|
"date"
|
|
71190
71617
|
];
|
|
71191
71618
|
var invalidText2 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71192
|
-
function shapeDataText(value2,
|
|
71619
|
+
function shapeDataText(value2, label2) {
|
|
71193
71620
|
if (typeof value2 !== "string" || value2.length > VISIO_METADATA_TEXT_LIMIT)
|
|
71194
|
-
fail2("INVALID_EDIT", `${
|
|
71621
|
+
fail2("INVALID_EDIT", `${label2} must be a string within the length limit.`);
|
|
71195
71622
|
if (invalidText2.test(value2) || /[\r\n\t]/.test(value2))
|
|
71196
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71623
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid characters.`);
|
|
71197
71624
|
return value2;
|
|
71198
71625
|
}
|
|
71199
71626
|
function shapeDataRowName(value2) {
|
|
@@ -71201,9 +71628,9 @@ function shapeDataRowName(value2) {
|
|
|
71201
71628
|
fail2("INVALID_EDIT", "Shape Data row names use letters, digits and underscores.");
|
|
71202
71629
|
return value2;
|
|
71203
71630
|
}
|
|
71204
|
-
function visioShapeDataRowName(
|
|
71631
|
+
function visioShapeDataRowName(label2, taken = []) {
|
|
71205
71632
|
const used = new Set([...taken].map((name4) => name4.toLowerCase()));
|
|
71206
|
-
let base2 =
|
|
71633
|
+
let base2 = label2.normalize("NFKD").replace(/[^\w]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 48);
|
|
71207
71634
|
if (!base2) base2 = "Property";
|
|
71208
71635
|
if (/^\d/.test(base2)) base2 = `_${base2}`;
|
|
71209
71636
|
let name3 = base2;
|
|
@@ -71275,18 +71702,18 @@ var TYPES3 = [
|
|
|
71275
71702
|
"unlink-data-rows"
|
|
71276
71703
|
];
|
|
71277
71704
|
var isVisioDataEdit = (edit) => TYPES3.includes(edit.type);
|
|
71278
|
-
var id = (value2,
|
|
71705
|
+
var id = (value2, label2) => {
|
|
71279
71706
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71280
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71707
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71281
71708
|
return value2;
|
|
71282
71709
|
};
|
|
71283
|
-
var name = (value2,
|
|
71284
|
-
const text8 = shapeDataText(value2,
|
|
71710
|
+
var name = (value2, label2) => {
|
|
71711
|
+
const text8 = shapeDataText(value2, label2);
|
|
71285
71712
|
if (!text8.trim() || text8.length > 255)
|
|
71286
|
-
fail2("INVALID_EDIT", `${
|
|
71713
|
+
fail2("INVALID_EDIT", `${label2} must be 1 to 255 characters.`);
|
|
71287
71714
|
return text8;
|
|
71288
71715
|
};
|
|
71289
|
-
function
|
|
71716
|
+
function table3(columns, rows) {
|
|
71290
71717
|
if (!Array.isArray(columns) || !columns.length || columns.length > VISIO_DATA_LIMITS.maxColumns)
|
|
71291
71718
|
fail2("INVALID_EDIT", `A recordset needs 1 to ${VISIO_DATA_LIMITS.maxColumns} columns.`);
|
|
71292
71719
|
if (!Array.isArray(rows) || rows.length > VISIO_DATA_LIMITS.maxRows)
|
|
@@ -71332,14 +71759,14 @@ function snapshotDataEdit(edit) {
|
|
|
71332
71759
|
type: edit.type,
|
|
71333
71760
|
pageId: pageId2,
|
|
71334
71761
|
name: name(edit.name, "The recordset name"),
|
|
71335
|
-
...
|
|
71762
|
+
...table3(edit.columns, edit.rows)
|
|
71336
71763
|
};
|
|
71337
71764
|
case "refresh-data-recordset":
|
|
71338
71765
|
return {
|
|
71339
71766
|
type: edit.type,
|
|
71340
71767
|
pageId: pageId2,
|
|
71341
71768
|
recordsetId: id(edit.recordsetId, "recordset"),
|
|
71342
|
-
...
|
|
71769
|
+
...table3(edit.columns, edit.rows)
|
|
71343
71770
|
};
|
|
71344
71771
|
case "delete-data-recordset":
|
|
71345
71772
|
return { type: edit.type, pageId: pageId2, recordsetId: id(edit.recordsetId, "recordset") };
|
|
@@ -71398,16 +71825,16 @@ function snapshotPageTheme(edit) {
|
|
|
71398
71825
|
var isVisioCommentEdit = (edit) => edit.type === "add-comment" || edit.type === "edit-comment" || edit.type === "delete-comment";
|
|
71399
71826
|
var invalidText3 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71400
71827
|
var dateTime = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?(?:Z|[+-]\d{2}:\d{2})?$/;
|
|
71401
|
-
function string(value2, limit3,
|
|
71828
|
+
function string(value2, limit3, label2, required = true) {
|
|
71402
71829
|
if (typeof value2 !== "string" || value2.length > limit3 || required && !value2.trim())
|
|
71403
|
-
fail2("INVALID_EDIT", `${
|
|
71830
|
+
fail2("INVALID_EDIT", `${label2} must be a non-empty string within its length limit.`);
|
|
71404
71831
|
if (invalidText3.test(value2))
|
|
71405
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71832
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid XML characters.`);
|
|
71406
71833
|
return value2;
|
|
71407
71834
|
}
|
|
71408
|
-
var id2 = (value2,
|
|
71835
|
+
var id2 = (value2, label2) => {
|
|
71409
71836
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71410
|
-
fail2("INVALID_EDIT", `${
|
|
71837
|
+
fail2("INVALID_EDIT", `${label2} must be a canonical unsigned integer.`);
|
|
71411
71838
|
return value2;
|
|
71412
71839
|
};
|
|
71413
71840
|
var date = (value2) => {
|
|
@@ -71930,7 +72357,7 @@ async function editVsdxMasterInstance(pkg, parts, pages, edit, limits, maxOutput
|
|
|
71930
72357
|
|
|
71931
72358
|
// visio/paper-sizes.ts
|
|
71932
72359
|
var mm = (value2) => value2 / 25.4;
|
|
71933
|
-
var size = (id3,
|
|
72360
|
+
var size = (id3, label2, width, height, paperKind) => Object.freeze({ id: id3, label: label2, width, height, ...paperKind === void 0 ? {} : { paperKind } });
|
|
71934
72361
|
var VISIO_PAPER_SIZES = Object.freeze([
|
|
71935
72362
|
size("letter", "Letter", 8.5, 11, 1),
|
|
71936
72363
|
size("tabloid", "Tabloid", 11, 17, 3),
|
|
@@ -73300,7 +73727,7 @@ function snapshotFormatting(edit) {
|
|
|
73300
73727
|
if (!Number.isInteger(value2)) fail2("INVALID_EDIT", "Paint patterns require integers.");
|
|
73301
73728
|
result2[name3] = value2;
|
|
73302
73729
|
}
|
|
73303
|
-
for (const [name3, maximum,
|
|
73730
|
+
for (const [name3, maximum, label2] of [
|
|
73304
73731
|
["beginArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73305
73732
|
["endArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73306
73733
|
["beginArrowSize", 6, "Arrowhead sizes are numbered 0 to 6."],
|
|
@@ -73314,7 +73741,7 @@ function snapshotFormatting(edit) {
|
|
|
73314
73741
|
const value2 = edit[name3];
|
|
73315
73742
|
if (value2 === void 0) continue;
|
|
73316
73743
|
if (typeof value2 !== "number" || !Number.isInteger(value2) || value2 < 0 || value2 > maximum)
|
|
73317
|
-
fail2("INVALID_EDIT",
|
|
73744
|
+
fail2("INVALID_EDIT", label2);
|
|
73318
73745
|
result2[name3] = value2;
|
|
73319
73746
|
}
|
|
73320
73747
|
if (edit.rounding !== void 0) result2.rounding = points(edit.rounding, 0, 720);
|