ooxml-core 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PptxHandler-3A7VEXVK.cjs +13 -0
- package/dist/PptxHandler-7POULDRL.mjs +4 -0
- package/dist/{PptxHandler-R5BVKEBW.mjs → PptxHandler-M35YFCUC.mjs} +2 -2
- package/dist/PresentationBuilder-C7NPM7OQ.mjs +4 -0
- package/dist/{PresentationBuilder-4AF3PZHG.cjs → PresentationBuilder-XVRTITYR.cjs} +6 -5
- package/dist/{PresentationBuilder-W67DIJBV.mjs → PresentationBuilder-Y6DJK6H2.mjs} +2 -2
- package/dist/automation/index.cjs +935 -535
- package/dist/automation/index.mjs +935 -535
- package/dist/chunk-5W2QL4SB.cjs +244 -0
- package/dist/{chunk-ZWI7MTLF.cjs → chunk-AHRFBMLK.cjs} +2846 -1546
- package/dist/{chunk-NWAQEXBK.mjs → chunk-B37EVUMG.mjs} +1 -1
- package/dist/{chunk-HU36GIYM.mjs → chunk-C2Y6SZDN.mjs} +421 -129
- package/dist/chunk-CA7KCNL3.mjs +236 -0
- package/dist/{chunk-BSUIDT6K.cjs → chunk-DWRJ62KP.cjs} +1 -0
- package/dist/{chunk-OPBZBSJF.mjs → chunk-KOX5Y5E5.mjs} +1 -1
- package/dist/{chunk-JFMIPOPV.mjs → chunk-LM6VBPQJ.mjs} +416 -15
- package/dist/{chunk-PC4MTLG4.cjs → chunk-OA5V3JJC.cjs} +8 -8
- package/dist/{chunk-7ZIZFJXT.mjs → chunk-OKGQ2X7D.mjs} +1848 -548
- package/dist/{chunk-X7MGZQ6C.cjs → chunk-UGWY72WC.cjs} +396 -254
- package/dist/{chunk-EMZIHAOH.mjs → chunk-WBCV52YV.mjs} +1846 -565
- package/dist/{chunk-2EBMHIGJ.mjs → chunk-WEFFRYXN.mjs} +379 -242
- package/dist/{chunk-AXF2FC4D.mjs → chunk-WSRCLCMB.mjs} +1 -0
- package/dist/{chunk-LMMP67YN.mjs → chunk-XCJRUBGJ.mjs} +1 -1
- package/dist/pptx/automation/index.cjs +2662 -884
- 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 +2652 -874
- 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 +3208 -1106
- package/dist/pptx/index.d.ts +5 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +156 -65
- package/dist/teams/index.mjs +156 -65
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +867 -467
- package/dist/xlsx/index.mjs +867 -467
- package/dist/xlsx/load/index.cjs +345 -99
- package/dist/xlsx/load/index.mjs +345 -99
- 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 +800 -621
- package/dist/xlsx/ui/index.mjs +800 -621
- 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
|
@@ -81,7 +81,7 @@ var DEFAULT_XML_LIMITS = {
|
|
|
81
81
|
maxNodes: 5e6
|
|
82
82
|
};
|
|
83
83
|
var MARKUP_RE = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<\?[\s\S]*?\?>|<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/g;
|
|
84
|
-
function checkXmlLimits(xml,
|
|
84
|
+
function checkXmlLimits(xml, label2, limits = {}) {
|
|
85
85
|
const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
86
86
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
87
87
|
let depth = 0;
|
|
@@ -94,16 +94,16 @@ function checkXmlLimits(xml, label4, limits = {}) {
|
|
|
94
94
|
continue;
|
|
95
95
|
}
|
|
96
96
|
nodes++;
|
|
97
|
-
if (nodes > maxNodes) throw new Error(`${
|
|
97
|
+
if (nodes > maxNodes) throw new Error(`${label2} XML exceeds the limit of ${maxNodes} elements`);
|
|
98
98
|
if (!selfClosing && ++depth > maxDepth)
|
|
99
|
-
throw new Error(`${
|
|
99
|
+
throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
function parseXml(xml, options = {}) {
|
|
103
|
-
const
|
|
103
|
+
const label2 = options.label ?? "OOXML";
|
|
104
104
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
105
|
-
throw new Error(`${
|
|
106
|
-
checkXmlLimits(xml,
|
|
105
|
+
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
106
|
+
checkXmlLimits(xml, label2, options.limits);
|
|
107
107
|
let parseError = "";
|
|
108
108
|
let parsed;
|
|
109
109
|
try {
|
|
@@ -114,12 +114,12 @@ function parseXml(xml, options = {}) {
|
|
|
114
114
|
}).parseFromString(xml, "application/xml");
|
|
115
115
|
} catch (error) {
|
|
116
116
|
throw new Error(
|
|
117
|
-
`Invalid ${
|
|
117
|
+
`Invalid ${label2} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
118
118
|
{ cause: error }
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
if (parseError || !parsed.documentElement)
|
|
122
|
-
throw new Error(`Invalid ${
|
|
122
|
+
throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
|
|
123
123
|
return parsed;
|
|
124
124
|
}
|
|
125
125
|
var buildXml = (node3) => new xmldom.XMLSerializer().serializeToString(node3);
|
|
@@ -406,10 +406,10 @@ function withParseWarnings(warnings, fn) {
|
|
|
406
406
|
function reportParseWarning(message) {
|
|
407
407
|
if (sink && !sink.includes(message)) sink.push(message);
|
|
408
408
|
}
|
|
409
|
-
function enumValue(guard2, raw2,
|
|
409
|
+
function enumValue(guard2, raw2, label2) {
|
|
410
410
|
if (raw2 === null || raw2 === void 0 || raw2 === "") return void 0;
|
|
411
411
|
if (guard2(raw2)) return raw2;
|
|
412
|
-
reportParseWarning(`Ignored invalid ${
|
|
412
|
+
reportParseWarning(`Ignored invalid ${label2} value \u201C${raw2}\u201D; it is not allowed by the schema.`);
|
|
413
413
|
return void 0;
|
|
414
414
|
}
|
|
415
415
|
|
|
@@ -2298,7 +2298,7 @@ function flatChildren(parent, names, level = "block", enclosing, controls3 = /*
|
|
|
2298
2298
|
return found;
|
|
2299
2299
|
}
|
|
2300
2300
|
var flatBlocks = (container) => flatChildren(container, ["p", "tbl"]);
|
|
2301
|
-
var flatRows = (
|
|
2301
|
+
var flatRows = (table4) => flatChildren(table4, ["tr"], "row");
|
|
2302
2302
|
var flatCells = (row3) => flatChildren(row3, ["tc"], "cell");
|
|
2303
2303
|
var flatCellParagraphs = (cell) => flatChildren(cell, ["p"]);
|
|
2304
2304
|
|
|
@@ -3011,42 +3011,42 @@ function buildMargins(doc, margins, tag) {
|
|
|
3011
3011
|
}
|
|
3012
3012
|
return element2.childNodes.length ? element2 : void 0;
|
|
3013
3013
|
}
|
|
3014
|
-
function tableJustification(
|
|
3015
|
-
const { alignment, justification } =
|
|
3014
|
+
function tableJustification(table4) {
|
|
3015
|
+
const { alignment, justification } = table4;
|
|
3016
3016
|
const implied = justification === "start" ? "left" : justification === "end" ? "right" : justification;
|
|
3017
3017
|
return justification && implied === alignment ? justification : alignment;
|
|
3018
3018
|
}
|
|
3019
|
-
function tableColumnCount(
|
|
3019
|
+
function tableColumnCount(table4) {
|
|
3020
3020
|
return Math.max(
|
|
3021
3021
|
1,
|
|
3022
|
-
...
|
|
3022
|
+
...table4.rows.map((row3) => row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0))
|
|
3023
3023
|
);
|
|
3024
3024
|
}
|
|
3025
|
-
function buildNewTableProperties(doc,
|
|
3025
|
+
function buildNewTableProperties(doc, table4, contentWidthTwips) {
|
|
3026
3026
|
const tblPr = makeW(doc, "tblPr");
|
|
3027
|
-
if (
|
|
3027
|
+
if (table4.style) {
|
|
3028
3028
|
const style3 = makeW(doc, "tblStyle");
|
|
3029
|
-
setW2(style3, "val",
|
|
3029
|
+
setW2(style3, "val", table4.style);
|
|
3030
3030
|
tblPr.appendChild(style3);
|
|
3031
3031
|
}
|
|
3032
3032
|
const width = makeW(doc, "tblW");
|
|
3033
|
-
setW2(width, "w", String(
|
|
3034
|
-
setW2(width, "type",
|
|
3033
|
+
setW2(width, "w", String(table4.widthTwips ?? 0));
|
|
3034
|
+
setW2(width, "type", table4.widthTwips ? "dxa" : "auto");
|
|
3035
3035
|
tblPr.appendChild(width);
|
|
3036
|
-
const jcValue = tableJustification(
|
|
3036
|
+
const jcValue = tableJustification(table4);
|
|
3037
3037
|
if (jcValue) {
|
|
3038
3038
|
const jc = makeW(doc, "jc");
|
|
3039
3039
|
setW2(jc, "val", jcValue);
|
|
3040
3040
|
tblPr.appendChild(jc);
|
|
3041
3041
|
}
|
|
3042
|
-
if (
|
|
3042
|
+
if (table4.indentTwips !== void 0) {
|
|
3043
3043
|
const indent = makeW(doc, "tblInd");
|
|
3044
|
-
setW2(indent, "w", String(
|
|
3044
|
+
setW2(indent, "w", String(table4.indentTwips));
|
|
3045
3045
|
setW2(indent, "type", "dxa");
|
|
3046
3046
|
tblPr.appendChild(indent);
|
|
3047
3047
|
}
|
|
3048
|
-
if (
|
|
3049
|
-
const margins =
|
|
3048
|
+
if (table4.borders) tblPr.appendChild(buildBorders(doc, table4.borders, "tblBorders"));
|
|
3049
|
+
const margins = table4.cellMargins && buildMargins(doc, table4.cellMargins, "tblCellMar");
|
|
3050
3050
|
if (margins) tblPr.appendChild(margins);
|
|
3051
3051
|
const look = makeW(doc, "tblLook");
|
|
3052
3052
|
const lookAttributes = [
|
|
@@ -3061,8 +3061,8 @@ function buildNewTableProperties(doc, table3, contentWidthTwips) {
|
|
|
3061
3061
|
for (const [name3, value2] of lookAttributes) setW2(look, name3, value2);
|
|
3062
3062
|
tblPr.appendChild(look);
|
|
3063
3063
|
const tblGrid = makeW(doc, "tblGrid");
|
|
3064
|
-
const columns = tableColumnCount(
|
|
3065
|
-
const widths =
|
|
3064
|
+
const columns = tableColumnCount(table4);
|
|
3065
|
+
const widths = table4.grid?.length === columns ? table4.grid : Array.from({ length: columns }, () => Math.max(1, Math.floor(contentWidthTwips / columns)));
|
|
3066
3066
|
for (const value2 of widths) {
|
|
3067
3067
|
const column2 = makeW(doc, "gridCol");
|
|
3068
3068
|
setW2(column2, "w", String(value2));
|
|
@@ -3310,14 +3310,14 @@ function patchRowProperties(doc, tr, next, base2) {
|
|
|
3310
3310
|
}
|
|
3311
3311
|
orderChildren(props, ROW_ORDER);
|
|
3312
3312
|
}
|
|
3313
|
-
function patchTableMargins(doc,
|
|
3313
|
+
function patchTableMargins(doc, table4, node3, base2) {
|
|
3314
3314
|
patchMarginProperties(
|
|
3315
3315
|
doc,
|
|
3316
3316
|
node3,
|
|
3317
3317
|
"tblPr",
|
|
3318
3318
|
"tblCellMar",
|
|
3319
3319
|
TABLE_ORDER,
|
|
3320
|
-
|
|
3320
|
+
table4.cellMargins,
|
|
3321
3321
|
base2?.cellMargins
|
|
3322
3322
|
);
|
|
3323
3323
|
}
|
|
@@ -3412,12 +3412,12 @@ function patchCellShading(doc, tc, next, base2) {
|
|
|
3412
3412
|
}
|
|
3413
3413
|
|
|
3414
3414
|
// docx/write-table.ts
|
|
3415
|
-
function canEditTableStructure(
|
|
3415
|
+
function canEditTableStructure(table4) {
|
|
3416
3416
|
const only = (parent, allowed) => Array.from(parent.childNodes).filter(isElement).every((node3) => allowed.some((name3) => named2(node3, name3)));
|
|
3417
|
-
if (!only(
|
|
3418
|
-
const grid = first2(
|
|
3417
|
+
if (!only(table4, ["tblPr", "tblGrid", "tr"])) return false;
|
|
3418
|
+
const grid = first2(table4, "tblGrid");
|
|
3419
3419
|
if (grid && !only(grid, ["gridCol"])) return false;
|
|
3420
|
-
const rows = children2(
|
|
3420
|
+
const rows = children2(table4, "tr");
|
|
3421
3421
|
if (!rows.length) return false;
|
|
3422
3422
|
const [firstRow] = rows;
|
|
3423
3423
|
if (!firstRow) return false;
|
|
@@ -3443,7 +3443,7 @@ function canEditTableStructure(table3) {
|
|
|
3443
3443
|
}
|
|
3444
3444
|
return true;
|
|
3445
3445
|
}
|
|
3446
|
-
var layout = (
|
|
3446
|
+
var layout = (table4) => table4.rows.map((row3) => row3.map((cell) => cell.paragraphs.map((p) => p.id)));
|
|
3447
3447
|
var TABLE_DESCRIPTOR_KEYS = [
|
|
3448
3448
|
"grid",
|
|
3449
3449
|
"widthTwips",
|
|
@@ -3460,9 +3460,9 @@ function pick(source2, keys) {
|
|
|
3460
3460
|
for (const key2 of keys) if (record2[key2] !== void 0) result2[key2] = record2[key2];
|
|
3461
3461
|
return result2;
|
|
3462
3462
|
}
|
|
3463
|
-
function assertNoDescriptorEdits(
|
|
3463
|
+
function assertNoDescriptorEdits(table4, base2) {
|
|
3464
3464
|
if (!base2) return;
|
|
3465
|
-
if (JSON.stringify(pick(
|
|
3465
|
+
if (JSON.stringify(pick(table4, TABLE_DESCRIPTOR_KEYS)) !== JSON.stringify(pick(base2, TABLE_DESCRIPTOR_KEYS)))
|
|
3466
3466
|
throw new Error(
|
|
3467
3467
|
"Cannot edit table grid widths, width, alignment, indent, borders, or style; only cell text and row/column structure changes are supported. The original DOCX package remains unchanged."
|
|
3468
3468
|
);
|
|
@@ -3472,7 +3472,7 @@ function assertNoDescriptorEdits(table3, base2) {
|
|
|
3472
3472
|
const id3 = cell.paragraphs[0]?.id;
|
|
3473
3473
|
if (id3) baseCellById.set(id3, cell);
|
|
3474
3474
|
}
|
|
3475
|
-
for (const row3 of
|
|
3475
|
+
for (const row3 of table4.rows)
|
|
3476
3476
|
for (const cell of row3) {
|
|
3477
3477
|
const id3 = cell.paragraphs[0]?.id;
|
|
3478
3478
|
const source2 = id3 ? baseCellById.get(id3) : void 0;
|
|
@@ -3488,23 +3488,23 @@ function writeNestedTables(doc, tc, cell, base2, writeParagraph, replaceSlots2)
|
|
|
3488
3488
|
const next = tables(cell.sourceBlocks);
|
|
3489
3489
|
const before = tables(base2?.sourceBlocks);
|
|
3490
3490
|
const nodes = children2(tc, "tbl");
|
|
3491
|
-
next.forEach((
|
|
3491
|
+
next.forEach((table4, index3) => {
|
|
3492
3492
|
const node3 = nodes[index3];
|
|
3493
3493
|
if (node3 && before[index3])
|
|
3494
|
-
writeTable(doc,
|
|
3494
|
+
writeTable(doc, table4, node3, before[index3], writeParagraph, replaceSlots2);
|
|
3495
3495
|
});
|
|
3496
3496
|
}
|
|
3497
|
-
function writeTable(doc,
|
|
3498
|
-
if (base2 && JSON.stringify(
|
|
3499
|
-
assertNoDescriptorEdits(
|
|
3500
|
-
patchTableMargins(doc,
|
|
3501
|
-
const structural = base2 && JSON.stringify(layout(
|
|
3497
|
+
function writeTable(doc, table4, node3, base2, writeParagraph, replaceSlots2) {
|
|
3498
|
+
if (base2 && JSON.stringify(table4) === JSON.stringify(base2)) return node3;
|
|
3499
|
+
assertNoDescriptorEdits(table4, base2);
|
|
3500
|
+
patchTableMargins(doc, table4, node3, base2);
|
|
3501
|
+
const structural = base2 && JSON.stringify(layout(table4)) !== JSON.stringify(layout(base2));
|
|
3502
3502
|
if (structural && !canEditTableStructure(node3))
|
|
3503
3503
|
throw new Error(
|
|
3504
3504
|
"Cannot change the structure of a merged, nested, or complex table. The original DOCX package remains unchanged."
|
|
3505
3505
|
);
|
|
3506
|
-
const width =
|
|
3507
|
-
if (!width ||
|
|
3506
|
+
const width = table4.rows[0]?.length ?? 0;
|
|
3507
|
+
if (!width || table4.rows.some((row3) => row3.length !== width || row3.some((cell) => !cell.paragraphs.length)))
|
|
3508
3508
|
throw new Error("Tables must contain rectangular rows and at least one paragraph per cell.");
|
|
3509
3509
|
const oldRows = flatRows(node3).map((entry3) => entry3.element);
|
|
3510
3510
|
const sourceById = /* @__PURE__ */ new Map();
|
|
@@ -3525,7 +3525,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3525
3525
|
const usedCells = /* @__PURE__ */ new Set();
|
|
3526
3526
|
const usedRows = /* @__PURE__ */ new Set();
|
|
3527
3527
|
const columns = /* @__PURE__ */ new Map();
|
|
3528
|
-
const nextRows =
|
|
3528
|
+
const nextRows = table4.rows.map((row3, rowIndex2) => {
|
|
3529
3529
|
const sources = row3.map(
|
|
3530
3530
|
(cell) => cell.paragraphs.map((p) => sourceById.get(p.id)).find(Boolean)
|
|
3531
3531
|
);
|
|
@@ -3540,7 +3540,7 @@ function writeTable(doc, table3, node3, base2, writeParagraph, replaceSlots2) {
|
|
|
3540
3540
|
patchRowProperties(
|
|
3541
3541
|
doc,
|
|
3542
3542
|
tr,
|
|
3543
|
-
|
|
3543
|
+
table4.rowProperties?.[rowIndex2],
|
|
3544
3544
|
sourceRow === void 0 ? void 0 : base2?.rowProperties?.[sourceRow]
|
|
3545
3545
|
);
|
|
3546
3546
|
const nextCells = row3.map((cell, ci) => {
|
|
@@ -11566,8 +11566,8 @@ function gd14(name3, formula) {
|
|
|
11566
11566
|
const parts = formula.trim().split(/\s+/);
|
|
11567
11567
|
return { name: name3, formula, args: parts.slice(1) };
|
|
11568
11568
|
}
|
|
11569
|
-
function parseGdTable(
|
|
11570
|
-
return
|
|
11569
|
+
function parseGdTable(table4) {
|
|
11570
|
+
return table4.trim().split(/[\n;]/).filter((entry3) => entry3.length > 0).map((entry3) => {
|
|
11571
11571
|
const sep = entry3.indexOf("|");
|
|
11572
11572
|
return gd14(entry3.slice(0, sep), entry3.slice(sep + 1));
|
|
11573
11573
|
});
|
|
@@ -13460,8 +13460,8 @@ function parseDiagramDataModel(source2, part) {
|
|
|
13460
13460
|
"CONNECTION_ENDPOINT_MISSING",
|
|
13461
13461
|
`dgm:cxn ${attribute4} references missing point: ${id3}.`
|
|
13462
13462
|
);
|
|
13463
|
-
const
|
|
13464
|
-
connections2.push(
|
|
13463
|
+
const label2 = connectionLabel(connection, transitionText);
|
|
13464
|
+
connections2.push(label2 ? { ...connection, label: label2 } : connection);
|
|
13465
13465
|
if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
|
|
13466
13466
|
parentById.set(connection.destId, connection.sourceId);
|
|
13467
13467
|
}
|
|
@@ -13500,14 +13500,14 @@ function colorList(container) {
|
|
|
13500
13500
|
}
|
|
13501
13501
|
function parseDiagramColors(source2) {
|
|
13502
13502
|
const root = rootOf2(source2);
|
|
13503
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13504
|
-
name: stringAttribute(
|
|
13505
|
-
fill: colorList(first(
|
|
13506
|
-
line: colorList(first(
|
|
13507
|
-
effect: colorList(first(
|
|
13508
|
-
textLine: colorList(first(
|
|
13509
|
-
textFill: colorList(first(
|
|
13510
|
-
textEffect: colorList(first(
|
|
13503
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13504
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13505
|
+
fill: colorList(first(label2, "fillClrLst", NS.dgm)),
|
|
13506
|
+
line: colorList(first(label2, "linClrLst", NS.dgm)),
|
|
13507
|
+
effect: colorList(first(label2, "effectClrLst", NS.dgm)),
|
|
13508
|
+
textLine: colorList(first(label2, "txLinClrLst", NS.dgm)),
|
|
13509
|
+
textFill: colorList(first(label2, "txFillClrLst", NS.dgm)),
|
|
13510
|
+
textEffect: colorList(first(label2, "txEffectClrLst", NS.dgm))
|
|
13511
13511
|
}));
|
|
13512
13512
|
return { ...parseDefinitionHeader(root), labels };
|
|
13513
13513
|
}
|
|
@@ -13540,16 +13540,16 @@ function parseStyleReferences(style3) {
|
|
|
13540
13540
|
var hasContent = (element2) => Boolean(element2 && (element2.attributes.length > 0 || elements(element2).length > 0));
|
|
13541
13541
|
function parseDiagramQuickStyle(source2) {
|
|
13542
13542
|
const root = rootOf2(source2);
|
|
13543
|
-
const labels = children(root, "styleLbl", NS.dgm).map((
|
|
13544
|
-
name: stringAttribute(
|
|
13545
|
-
...parseStyleReferences(first(
|
|
13546
|
-
hasScene3d: Boolean(first(
|
|
13547
|
-
hasShape3d: hasContent(first(
|
|
13543
|
+
const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
13544
|
+
name: stringAttribute(label2, "name") ?? "",
|
|
13545
|
+
...parseStyleReferences(first(label2, "style", NS.dgm)),
|
|
13546
|
+
hasScene3d: Boolean(first(label2, "scene3d", NS.dgm)),
|
|
13547
|
+
hasShape3d: hasContent(first(label2, "sp3d", NS.dgm))
|
|
13548
13548
|
}));
|
|
13549
13549
|
return {
|
|
13550
13550
|
...parseDefinitionHeader(root),
|
|
13551
13551
|
labels,
|
|
13552
|
-
has3d: labels.some((
|
|
13552
|
+
has3d: labels.some((label2) => label2.hasShape3d)
|
|
13553
13553
|
};
|
|
13554
13554
|
}
|
|
13555
13555
|
function parseDiagramLayoutSummary(source2) {
|
|
@@ -14719,10 +14719,10 @@ function parseDisplayUnits(context, element2) {
|
|
|
14719
14719
|
if (!element2) return void 0;
|
|
14720
14720
|
reportUnmodelled(context, element2, DISPLAY_UNITS);
|
|
14721
14721
|
const labelElement = cChild(element2, "dispUnitsLbl");
|
|
14722
|
-
let
|
|
14722
|
+
let label2;
|
|
14723
14723
|
if (labelElement) {
|
|
14724
14724
|
reportUnmodelled(context, labelElement, DISPLAY_UNITS_LABEL);
|
|
14725
|
-
|
|
14725
|
+
label2 = assignDefined(
|
|
14726
14726
|
{},
|
|
14727
14727
|
{
|
|
14728
14728
|
layout: manualLayout(labelElement),
|
|
@@ -14737,7 +14737,7 @@ function parseDisplayUnits(context, element2) {
|
|
|
14737
14737
|
{
|
|
14738
14738
|
builtInUnit: cVal(element2, "builtInUnit"),
|
|
14739
14739
|
customUnit: cNumber(context, element2, "custUnit"),
|
|
14740
|
-
label:
|
|
14740
|
+
label: label2,
|
|
14741
14741
|
extLst: extensionList2(element2)
|
|
14742
14742
|
}
|
|
14743
14743
|
);
|
|
@@ -15591,10 +15591,10 @@ function titleXml(context, title) {
|
|
|
15591
15591
|
function labelOptionsXml(context, options) {
|
|
15592
15592
|
return numberFormatXml(options.numberFormat) + shapePropertiesXml(context, options.spPr) + textBodyXml(context, options.txPr) + valXml("dLblPos", options.position) + valXml("showLegendKey", options.showLegendKey) + valXml("showVal", options.showValue) + valXml("showCatName", options.showCategoryName) + valXml("showSerName", options.showSeriesName) + valXml("showPercent", options.showPercent) + valXml("showBubbleSize", options.showBubbleSize) + (options.separator === void 0 ? "" : textElement("separator", options.separator));
|
|
15593
15593
|
}
|
|
15594
|
-
function labelXml(context,
|
|
15594
|
+
function labelXml(context, label2) {
|
|
15595
15595
|
return elementXml(
|
|
15596
15596
|
"dLbl",
|
|
15597
|
-
valXml("idx",
|
|
15597
|
+
valXml("idx", label2.index) + valXml("delete", label2.deleted) + layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + labelOptionsXml(context, label2) + raw(context, label2.extLst)
|
|
15598
15598
|
);
|
|
15599
15599
|
}
|
|
15600
15600
|
function dataLabelsXml(context, labels) {
|
|
@@ -15602,7 +15602,7 @@ function dataLabelsXml(context, labels) {
|
|
|
15602
15602
|
const leaderLines = labels.leaderLines ? elementXml("leaderLines", shapePropertiesXml(context, labels.leaderLines.spPr)) : "";
|
|
15603
15603
|
return elementXml(
|
|
15604
15604
|
"dLbls",
|
|
15605
|
-
labels.labels.map((
|
|
15605
|
+
labels.labels.map((label2) => labelXml(context, label2)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
|
|
15606
15606
|
);
|
|
15607
15607
|
}
|
|
15608
15608
|
|
|
@@ -15614,21 +15614,21 @@ function surfaceXml(context, local, surface) {
|
|
|
15614
15614
|
valXml("thickness", surface.thickness) + shapePropertiesXml(context, surface.spPr) + raw(context, surface.pictureOptionsXml) + raw(context, surface.extLst)
|
|
15615
15615
|
);
|
|
15616
15616
|
}
|
|
15617
|
-
function dataTableXml(context,
|
|
15618
|
-
if (!
|
|
15617
|
+
function dataTableXml(context, table4) {
|
|
15618
|
+
if (!table4) return "";
|
|
15619
15619
|
return elementXml(
|
|
15620
15620
|
"dTable",
|
|
15621
|
-
valXml("showHorzBorder",
|
|
15621
|
+
valXml("showHorzBorder", table4.showHorizontalBorder) + valXml("showVertBorder", table4.showVerticalBorder) + valXml("showOutline", table4.showOutline) + valXml("showKeys", table4.showKeys) + shapePropertiesXml(context, table4.spPr) + textBodyXml(context, table4.txPr) + raw(context, table4.extLst)
|
|
15622
15622
|
);
|
|
15623
15623
|
}
|
|
15624
15624
|
function displayUnitsXml(context, units2) {
|
|
15625
15625
|
if (!units2) return "";
|
|
15626
|
-
const
|
|
15626
|
+
const label2 = units2.label;
|
|
15627
15627
|
return elementXml(
|
|
15628
15628
|
"dispUnits",
|
|
15629
|
-
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (
|
|
15629
|
+
valXml("custUnit", units2.customUnit) + (units2.customUnit === void 0 ? valXml("builtInUnit", units2.builtInUnit) : "") + (label2 ? elementXml(
|
|
15630
15630
|
"dispUnitsLbl",
|
|
15631
|
-
layoutXml(context,
|
|
15631
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr)
|
|
15632
15632
|
) : "") + raw(context, units2.extLst)
|
|
15633
15633
|
);
|
|
15634
15634
|
}
|
|
@@ -15653,11 +15653,11 @@ function axisXml(context, axis) {
|
|
|
15653
15653
|
}
|
|
15654
15654
|
|
|
15655
15655
|
// chart/write-analysis.ts
|
|
15656
|
-
function trendlineLabelXml(context,
|
|
15657
|
-
if (!
|
|
15656
|
+
function trendlineLabelXml(context, label2) {
|
|
15657
|
+
if (!label2) return "";
|
|
15658
15658
|
return elementXml(
|
|
15659
15659
|
"trendlineLbl",
|
|
15660
|
-
layoutXml(context,
|
|
15660
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + numberFormatXml(label2.numberFormat) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr) + raw(context, label2.extLst)
|
|
15661
15661
|
);
|
|
15662
15662
|
}
|
|
15663
15663
|
function trendlineXml(context, trendline) {
|
|
@@ -17908,16 +17908,16 @@ var RelationshipAllocator = class {
|
|
|
17908
17908
|
|
|
17909
17909
|
// docx/write.ts
|
|
17910
17910
|
var twips2 = (pixels) => String(Math.round(pixels * 15));
|
|
17911
|
-
function createTable(doc,
|
|
17911
|
+
function createTable(doc, table4, allocator, contentWidthTwips, spans2) {
|
|
17912
17912
|
const node3 = makeW(doc, "tbl");
|
|
17913
|
-
const { tblPr, tblGrid } = buildNewTableProperties(doc,
|
|
17913
|
+
const { tblPr, tblGrid } = buildNewTableProperties(doc, table4, contentWidthTwips);
|
|
17914
17914
|
node3.appendChild(tblPr);
|
|
17915
17915
|
node3.appendChild(tblGrid);
|
|
17916
|
-
const columns = tableColumnCount(
|
|
17917
|
-
|
|
17916
|
+
const columns = tableColumnCount(table4);
|
|
17917
|
+
table4.rows.forEach((row3, rowIndex2) => {
|
|
17918
17918
|
const tr = makeW(doc, "tr");
|
|
17919
17919
|
const spanned = row3.reduce((sum3, cell) => sum3 + (cell.gridSpan ?? 1), 0);
|
|
17920
|
-
const trPr = buildRowProperties(doc,
|
|
17920
|
+
const trPr = buildRowProperties(doc, table4.rowProperties?.[rowIndex2], columns - spanned);
|
|
17921
17921
|
if (trPr) tr.appendChild(trPr);
|
|
17922
17922
|
for (const cell of row3) {
|
|
17923
17923
|
const tc = makeW(doc, "tc");
|
|
@@ -18320,28 +18320,28 @@ function validateCell(c2, cell) {
|
|
|
18320
18320
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18321
18321
|
c2.at(".margins").signed(side2, cell.margins[side2], "ST_SignedTwipsMeasure");
|
|
18322
18322
|
}
|
|
18323
|
-
function validateTable(c2,
|
|
18324
|
-
c2.unsigned("widthTwips",
|
|
18325
|
-
c2.signed("indentTwips",
|
|
18323
|
+
function validateTable(c2, table4) {
|
|
18324
|
+
c2.unsigned("widthTwips", table4.widthTwips, "ST_TwipsMeasure");
|
|
18325
|
+
c2.signed("indentTwips", table4.indentTwips, "ST_SignedTwipsMeasure");
|
|
18326
18326
|
c2.check(
|
|
18327
18327
|
"alignment",
|
|
18328
|
-
|
|
18328
|
+
table4.alignment,
|
|
18329
18329
|
(v) => v === "left" || v === "center" || v === "right",
|
|
18330
18330
|
'must be "left", "center" or "right"'
|
|
18331
18331
|
);
|
|
18332
|
-
c2.enum("justification",
|
|
18333
|
-
|
|
18332
|
+
c2.enum("justification", table4.justification, isStJcTable, "ST_JcTable");
|
|
18333
|
+
table4.grid?.forEach(
|
|
18334
18334
|
(width, index3) => c2.at(`.grid[${index3}]`).unsigned("width", width, "ST_TwipsMeasure")
|
|
18335
18335
|
);
|
|
18336
|
-
validateBorders(c2.at(".borders"),
|
|
18337
|
-
if (
|
|
18336
|
+
validateBorders(c2.at(".borders"), table4.borders);
|
|
18337
|
+
if (table4.cellMargins)
|
|
18338
18338
|
for (const side2 of ["top", "bottom", "left", "right"])
|
|
18339
|
-
c2.at(".cellMargins").signed(side2,
|
|
18340
|
-
|
|
18339
|
+
c2.at(".cellMargins").signed(side2, table4.cellMargins[side2], "ST_SignedTwipsMeasure");
|
|
18340
|
+
table4.rowProperties?.forEach((row3, index3) => {
|
|
18341
18341
|
if (row3)
|
|
18342
18342
|
c2.at(`.rowProperties[${index3}]`).unsigned("heightTwips", row3.heightTwips, "ST_TwipsMeasure");
|
|
18343
18343
|
});
|
|
18344
|
-
|
|
18344
|
+
table4.rows.forEach(
|
|
18345
18345
|
(row3, r) => row3.forEach((cell, k) => validateCell(c2.at(`.rows[${r}][${k}]`), cell))
|
|
18346
18346
|
);
|
|
18347
18347
|
}
|
|
@@ -19773,40 +19773,40 @@ function parseTable(node3, id3, parseParagraph3) {
|
|
|
19773
19773
|
(cell, ci) => parseCell(cell.element, parseParagraph3, `${id3}-r${ri}c${ci}`, cell.control)
|
|
19774
19774
|
)
|
|
19775
19775
|
);
|
|
19776
|
-
const
|
|
19776
|
+
const table4 = { type: "table", id: id3, rows, structureEditable: canEditTableStructure(node3) };
|
|
19777
19777
|
const gridElement = first2(node3, "tblGrid");
|
|
19778
19778
|
const grid = gridElement ? children2(gridElement, "gridCol").flatMap((column2) => {
|
|
19779
19779
|
const width2 = dxa(getW(column2, "w"));
|
|
19780
19780
|
return width2 === void 0 ? [] : [width2];
|
|
19781
19781
|
}) : [];
|
|
19782
|
-
if (grid.length)
|
|
19782
|
+
if (grid.length) table4.grid = grid;
|
|
19783
19783
|
const tblPr = first2(node3, "tblPr");
|
|
19784
19784
|
const tableWidth = first2(tblPr, "tblW");
|
|
19785
19785
|
const width = (getW(tableWidth, "type") ?? "dxa") === "dxa" ? dxa(getW(tableWidth, "w")) : void 0;
|
|
19786
|
-
if (width !== void 0)
|
|
19786
|
+
if (width !== void 0) table4.widthTwips = width;
|
|
19787
19787
|
const justification = enumValue(isStJcTable, getW(first2(tblPr, "jc"), "val"), "w:tblPr/w:jc");
|
|
19788
19788
|
if (justification) {
|
|
19789
|
-
|
|
19789
|
+
table4.justification = justification;
|
|
19790
19790
|
const rtl = onOffElement(first2(tblPr, "bidiVisual")) === true;
|
|
19791
|
-
|
|
19791
|
+
table4.alignment = justification === "start" ? rtl ? "right" : "left" : justification === "end" ? rtl ? "left" : "right" : justification;
|
|
19792
19792
|
}
|
|
19793
19793
|
const indent = parseSignedTwips(getW(first2(tblPr, "tblInd"), "w"));
|
|
19794
|
-
if (indent !== void 0)
|
|
19794
|
+
if (indent !== void 0) table4.indentTwips = indent;
|
|
19795
19795
|
const borders = parseTableBorders(first2(tblPr, "tblBorders"));
|
|
19796
|
-
if (borders)
|
|
19796
|
+
if (borders) table4.borders = borders;
|
|
19797
19797
|
const styleId = getW(first2(tblPr, "tblStyle"), "val");
|
|
19798
|
-
if (styleId)
|
|
19798
|
+
if (styleId) table4.style = styleId;
|
|
19799
19799
|
const look = parseLook(first2(tblPr, "tblLook"));
|
|
19800
|
-
if (look)
|
|
19800
|
+
if (look) table4.look = look;
|
|
19801
19801
|
const cellMargins = parseMargins(first2(tblPr, "tblCellMar"));
|
|
19802
|
-
if (cellMargins)
|
|
19802
|
+
if (cellMargins) table4.cellMargins = cellMargins;
|
|
19803
19803
|
const rowProperties = rowEntries.map(({ element: element2, control }) => {
|
|
19804
19804
|
const properties = parseRowProperties(element2);
|
|
19805
19805
|
if (control) properties.contentControl = control;
|
|
19806
19806
|
return properties;
|
|
19807
19807
|
});
|
|
19808
|
-
if (rowProperties.some((row3) => Object.keys(row3).length))
|
|
19809
|
-
return
|
|
19808
|
+
if (rowProperties.some((row3) => Object.keys(row3).length)) table4.rowProperties = rowProperties;
|
|
19809
|
+
return table4;
|
|
19810
19810
|
}
|
|
19811
19811
|
|
|
19812
19812
|
// docx/hyperlink.ts
|
|
@@ -20860,19 +20860,19 @@ var nextSheetId = (workbook) => workbook.sheets.reduce((max, sheet) => Math.max(
|
|
|
20860
20860
|
var MAX_ROW = 1048575;
|
|
20861
20861
|
var MAX_COL = 16383;
|
|
20862
20862
|
function columnLabel(col) {
|
|
20863
|
-
let
|
|
20863
|
+
let label2 = "";
|
|
20864
20864
|
let n = col + 1;
|
|
20865
20865
|
while (n > 0) {
|
|
20866
20866
|
const rem = (n - 1) % 26;
|
|
20867
|
-
|
|
20867
|
+
label2 = String.fromCharCode(65 + rem) + label2;
|
|
20868
20868
|
n = Math.floor((n - 1) / 26);
|
|
20869
20869
|
}
|
|
20870
|
-
return
|
|
20870
|
+
return label2;
|
|
20871
20871
|
}
|
|
20872
|
-
function columnIndex(
|
|
20873
|
-
if (!/^[A-Za-z]{1,3}$/.test(
|
|
20872
|
+
function columnIndex(label2) {
|
|
20873
|
+
if (!/^[A-Za-z]{1,3}$/.test(label2)) return -1;
|
|
20874
20874
|
let n = 0;
|
|
20875
|
-
for (const ch of
|
|
20875
|
+
for (const ch of label2.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
20876
20876
|
return n - 1;
|
|
20877
20877
|
}
|
|
20878
20878
|
var formatAddress = (address2) => `${columnLabel(address2.col)}${address2.row + 1}`;
|
|
@@ -23243,6 +23243,223 @@ var pivotColumnFields = (pivot) => [
|
|
|
23243
23243
|
...pivot.columnField ? pivot.moreColumnFields ?? [] : []
|
|
23244
23244
|
];
|
|
23245
23245
|
|
|
23246
|
+
// i18n/locale.ts
|
|
23247
|
+
var SUPPORTED_OFFICE_LOCALES = ["en", "fr", "de", "es", "zh-CN"];
|
|
23248
|
+
var DEFAULT_REJECTED_SUBTAGS = ["hant", "tw", "hk", "mo"];
|
|
23249
|
+
function normalizeLocale(input, supported2, fallback, options = {}) {
|
|
23250
|
+
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
23251
|
+
const language = parts[0];
|
|
23252
|
+
if (!language) return fallback;
|
|
23253
|
+
const find3 = (tag) => supported2.find((item) => item.toLowerCase() === tag);
|
|
23254
|
+
const exact = find3(parts.join("-"));
|
|
23255
|
+
if (exact) return exact;
|
|
23256
|
+
const base2 = find3(language);
|
|
23257
|
+
if (base2) return base2;
|
|
23258
|
+
const rejected = options.rejectedSubtags ?? DEFAULT_REJECTED_SUBTAGS;
|
|
23259
|
+
if (parts.slice(1).some((part) => rejected.includes(part))) return fallback;
|
|
23260
|
+
return supported2.find((item) => item.toLowerCase().split("-")[0] === language && item.includes("-")) ?? fallback;
|
|
23261
|
+
}
|
|
23262
|
+
function normalizeOfficeLocale(input) {
|
|
23263
|
+
return normalizeLocale(input, SUPPORTED_OFFICE_LOCALES, "en");
|
|
23264
|
+
}
|
|
23265
|
+
|
|
23266
|
+
// xlsx/pivot/captions-locales.ts
|
|
23267
|
+
var table = (words2, prefix3, rest, functions) => ({
|
|
23268
|
+
...rest,
|
|
23269
|
+
functions,
|
|
23270
|
+
aggregates: Object.fromEntries(
|
|
23271
|
+
Object.keys(words2).map((fn) => [fn, prefix3(words2[fn])])
|
|
23272
|
+
)
|
|
23273
|
+
});
|
|
23274
|
+
var GERMAN = {
|
|
23275
|
+
sum: "Summe",
|
|
23276
|
+
count: "Anzahl",
|
|
23277
|
+
average: "Mittelwert",
|
|
23278
|
+
max: "Max",
|
|
23279
|
+
min: "Min",
|
|
23280
|
+
product: "Produkt",
|
|
23281
|
+
countNums: "Anzahl (Zahlen)",
|
|
23282
|
+
stdDev: "Standardabweichung",
|
|
23283
|
+
stdDevp: "Standardabweichung (Grundgesamtheit)",
|
|
23284
|
+
var: "Varianz",
|
|
23285
|
+
varp: "Varianz (Grundgesamtheit)"
|
|
23286
|
+
};
|
|
23287
|
+
var SPANISH = {
|
|
23288
|
+
sum: "Suma",
|
|
23289
|
+
count: "Cuenta",
|
|
23290
|
+
average: "Promedio",
|
|
23291
|
+
max: "M\xE1x",
|
|
23292
|
+
min: "M\xEDn",
|
|
23293
|
+
product: "Producto",
|
|
23294
|
+
countNums: "Cuenta de n\xFAmeros",
|
|
23295
|
+
stdDev: "Desvest",
|
|
23296
|
+
stdDevp: "Desvestp",
|
|
23297
|
+
var: "Var",
|
|
23298
|
+
varp: "Varp"
|
|
23299
|
+
};
|
|
23300
|
+
var FRENCH = {
|
|
23301
|
+
sum: "Somme",
|
|
23302
|
+
count: "Nombre",
|
|
23303
|
+
average: "Moyenne",
|
|
23304
|
+
max: "Max",
|
|
23305
|
+
min: "Min",
|
|
23306
|
+
product: "Produit",
|
|
23307
|
+
countNums: "Nombre (nombres)",
|
|
23308
|
+
stdDev: "\xC9cartype",
|
|
23309
|
+
stdDevp: "\xC9cartypep",
|
|
23310
|
+
var: "Var",
|
|
23311
|
+
varp: "Varp"
|
|
23312
|
+
};
|
|
23313
|
+
var CHINESE = {
|
|
23314
|
+
sum: "\u6C42\u548C",
|
|
23315
|
+
count: "\u8BA1\u6570",
|
|
23316
|
+
average: "\u5E73\u5747\u503C",
|
|
23317
|
+
max: "\u6700\u5927\u503C",
|
|
23318
|
+
min: "\u6700\u5C0F\u503C",
|
|
23319
|
+
product: "\u4E58\u79EF",
|
|
23320
|
+
countNums: "\u6570\u503C\u8BA1\u6570",
|
|
23321
|
+
stdDev: "\u6807\u51C6\u504F\u5DEE",
|
|
23322
|
+
stdDevp: "\u603B\u4F53\u6807\u51C6\u504F\u5DEE",
|
|
23323
|
+
var: "\u65B9\u5DEE",
|
|
23324
|
+
varp: "\u603B\u4F53\u65B9\u5DEE"
|
|
23325
|
+
};
|
|
23326
|
+
var LOCALIZED_PIVOT_CAPTIONS = {
|
|
23327
|
+
de: table(
|
|
23328
|
+
GERMAN,
|
|
23329
|
+
(word) => `${word} von {0}`,
|
|
23330
|
+
{
|
|
23331
|
+
rowLabels: "Zeilenbeschriftungen",
|
|
23332
|
+
columnLabels: "Spaltenbeschriftungen",
|
|
23333
|
+
grandTotal: "Gesamtergebnis",
|
|
23334
|
+
values: "Werte",
|
|
23335
|
+
all: "(Alle)",
|
|
23336
|
+
blank: "(leer)",
|
|
23337
|
+
subtotal: "{0} Ergebnis",
|
|
23338
|
+
measureTotal: "Gesamt {0}"
|
|
23339
|
+
},
|
|
23340
|
+
GERMAN
|
|
23341
|
+
),
|
|
23342
|
+
es: table(
|
|
23343
|
+
SPANISH,
|
|
23344
|
+
(word) => `${word} de {0}`,
|
|
23345
|
+
{
|
|
23346
|
+
rowLabels: "Etiquetas de fila",
|
|
23347
|
+
columnLabels: "Etiquetas de columna",
|
|
23348
|
+
grandTotal: "Total general",
|
|
23349
|
+
values: "Valores",
|
|
23350
|
+
all: "(Todas)",
|
|
23351
|
+
blank: "(en blanco)",
|
|
23352
|
+
subtotal: "{0} Total",
|
|
23353
|
+
measureTotal: "Total {0}"
|
|
23354
|
+
},
|
|
23355
|
+
SPANISH
|
|
23356
|
+
),
|
|
23357
|
+
fr: table(
|
|
23358
|
+
FRENCH,
|
|
23359
|
+
(word) => `${word} de {0}`,
|
|
23360
|
+
{
|
|
23361
|
+
rowLabels: "\xC9tiquettes de lignes",
|
|
23362
|
+
columnLabels: "\xC9tiquettes de colonnes",
|
|
23363
|
+
grandTotal: "Total g\xE9n\xE9ral",
|
|
23364
|
+
values: "Valeurs",
|
|
23365
|
+
all: "(Tous)",
|
|
23366
|
+
blank: "(vide)",
|
|
23367
|
+
subtotal: "{0} Total",
|
|
23368
|
+
measureTotal: "Total {0}"
|
|
23369
|
+
},
|
|
23370
|
+
FRENCH
|
|
23371
|
+
),
|
|
23372
|
+
"zh-CN": table(
|
|
23373
|
+
CHINESE,
|
|
23374
|
+
(word) => `${word}\u9879:{0}`,
|
|
23375
|
+
{
|
|
23376
|
+
rowLabels: "\u884C\u6807\u7B7E",
|
|
23377
|
+
columnLabels: "\u5217\u6807\u7B7E",
|
|
23378
|
+
grandTotal: "\u603B\u8BA1",
|
|
23379
|
+
values: "\u6570\u503C",
|
|
23380
|
+
all: "(\u5168\u90E8)",
|
|
23381
|
+
blank: "(\u7A7A\u767D)",
|
|
23382
|
+
subtotal: "{0} \u6C47\u603B",
|
|
23383
|
+
measureTotal: "\u603B\u8BA1 {0}"
|
|
23384
|
+
},
|
|
23385
|
+
CHINESE
|
|
23386
|
+
)
|
|
23387
|
+
};
|
|
23388
|
+
|
|
23389
|
+
// xlsx/pivot/captions.ts
|
|
23390
|
+
var FUNCTIONS = {
|
|
23391
|
+
sum: "Sum",
|
|
23392
|
+
count: "Count",
|
|
23393
|
+
average: "Average",
|
|
23394
|
+
max: "Max",
|
|
23395
|
+
min: "Min",
|
|
23396
|
+
product: "Product",
|
|
23397
|
+
countNums: "Count",
|
|
23398
|
+
stdDev: "StdDev",
|
|
23399
|
+
stdDevp: "StdDevp",
|
|
23400
|
+
var: "Var",
|
|
23401
|
+
varp: "Varp"
|
|
23402
|
+
};
|
|
23403
|
+
var aggregateNames = () => Object.fromEntries(
|
|
23404
|
+
Object.keys(FUNCTIONS).map((fn) => [
|
|
23405
|
+
fn,
|
|
23406
|
+
`${fn[0].toUpperCase()}${fn.slice(1)} of {0}`
|
|
23407
|
+
])
|
|
23408
|
+
);
|
|
23409
|
+
var ENGLISH_PIVOT_CAPTIONS = {
|
|
23410
|
+
rowLabels: "Row Labels",
|
|
23411
|
+
columnLabels: "Column Labels",
|
|
23412
|
+
grandTotal: "Grand Total",
|
|
23413
|
+
values: "Values",
|
|
23414
|
+
all: "(All)",
|
|
23415
|
+
blank: "(blank)",
|
|
23416
|
+
subtotal: "{0} Total",
|
|
23417
|
+
measureTotal: "Total {0}",
|
|
23418
|
+
functions: FUNCTIONS,
|
|
23419
|
+
aggregates: aggregateNames()
|
|
23420
|
+
};
|
|
23421
|
+
var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
|
|
23422
|
+
function pivotCaptions(pivot) {
|
|
23423
|
+
const own2 = pivot.captions;
|
|
23424
|
+
if (!own2) return ENGLISH_PIVOT_CAPTIONS;
|
|
23425
|
+
return {
|
|
23426
|
+
...ENGLISH_PIVOT_CAPTIONS,
|
|
23427
|
+
...Object.fromEntries(Object.entries(own2).filter(([, value2]) => typeof value2 === "string")),
|
|
23428
|
+
functions: { ...ENGLISH_PIVOT_CAPTIONS.functions, ...own2.functions },
|
|
23429
|
+
aggregates: { ...ENGLISH_PIVOT_CAPTIONS.aggregates, ...own2.aggregates }
|
|
23430
|
+
};
|
|
23431
|
+
}
|
|
23432
|
+
var pivotMeasureName = (aggregate2, field2, pivot = {}) => fillCaption(pivotCaptions(pivot).aggregates[aggregate2], field2);
|
|
23433
|
+
function localizedPivotCaptions(locale) {
|
|
23434
|
+
const caps = LOCALIZED_PIVOT_CAPTIONS[normalizeOfficeLocale(locale)];
|
|
23435
|
+
return caps ? structuredClone(caps) : void 0;
|
|
23436
|
+
}
|
|
23437
|
+
function trimmedCaptions(caps) {
|
|
23438
|
+
const out = {};
|
|
23439
|
+
for (const key2 of [
|
|
23440
|
+
"rowLabels",
|
|
23441
|
+
"columnLabels",
|
|
23442
|
+
"grandTotal",
|
|
23443
|
+
"values",
|
|
23444
|
+
"all",
|
|
23445
|
+
"blank",
|
|
23446
|
+
"subtotal",
|
|
23447
|
+
"measureTotal"
|
|
23448
|
+
])
|
|
23449
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2]) out[key2] = caps[key2];
|
|
23450
|
+
for (const key2 of ["functions", "aggregates"]) {
|
|
23451
|
+
const changed = Object.keys(caps[key2]).filter(
|
|
23452
|
+
(fn) => caps[key2][fn] !== ENGLISH_PIVOT_CAPTIONS[key2][fn]
|
|
23453
|
+
);
|
|
23454
|
+
if (changed.length) out[key2] = Object.fromEntries(changed.map((fn) => [fn, caps[key2][fn]]));
|
|
23455
|
+
}
|
|
23456
|
+
return Object.keys(out).length ? out : void 0;
|
|
23457
|
+
}
|
|
23458
|
+
function authoredCaptions(options) {
|
|
23459
|
+
const own2 = options.captions ?? localizedPivotCaptions(options.locale);
|
|
23460
|
+
return own2 && Object.keys(own2).length ? structuredClone(own2) : void 0;
|
|
23461
|
+
}
|
|
23462
|
+
|
|
23246
23463
|
// xlsx/formula/date-serial.ts
|
|
23247
23464
|
var DAY_MS = 864e5;
|
|
23248
23465
|
var EPOCH_19002 = Date.UTC(1899, 11, 30);
|
|
@@ -23501,9 +23718,9 @@ function expandDateGroups(pivot) {
|
|
|
23501
23718
|
fields: [...pivot.fields, ...derived.map((entry3) => entry3.name)],
|
|
23502
23719
|
records: pivot.records.map((record2) => [
|
|
23503
23720
|
...record2,
|
|
23504
|
-
...tables.map((
|
|
23505
|
-
const value2 = record2[
|
|
23506
|
-
return typeof value2 === "number" ?
|
|
23721
|
+
...tables.map((table4) => {
|
|
23722
|
+
const value2 = record2[table4.base];
|
|
23723
|
+
return typeof value2 === "number" ? table4.labels[table4.index(value2)] : null;
|
|
23507
23724
|
})
|
|
23508
23725
|
])
|
|
23509
23726
|
};
|
|
@@ -23707,6 +23924,17 @@ function pruneItemFilters(pivot) {
|
|
|
23707
23924
|
return next.length ? next : void 0;
|
|
23708
23925
|
}
|
|
23709
23926
|
|
|
23927
|
+
// xlsx/pivot/item-labels.ts
|
|
23928
|
+
var keyOf = (field2, item) => `${field2}\0${pivotValueKey(item)}`;
|
|
23929
|
+
function pivotItemLabeler(pivot) {
|
|
23930
|
+
const blank = pivotCaptions(pivot).blank;
|
|
23931
|
+
const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
|
|
23932
|
+
return (field2, value2) => names?.get(keyOf(field2, value2)) ?? (value2 === null || value2 === "" ? blank : pivotItemLabel(value2));
|
|
23933
|
+
}
|
|
23934
|
+
var pivotItemName = (pivot, field2, item) => pivot.itemNames?.find(
|
|
23935
|
+
(entry3) => entry3.field === field2 && pivotValueKey(entry3.item) === pivotValueKey(item)
|
|
23936
|
+
)?.name;
|
|
23937
|
+
|
|
23710
23938
|
// xlsx/pivot/page-filter.ts
|
|
23711
23939
|
function validatePivotPageFilter(pivot) {
|
|
23712
23940
|
const filter2 = pivot.pageFilter;
|
|
@@ -23718,8 +23946,8 @@ function validatePivotPageFilter(pivot) {
|
|
|
23718
23946
|
pivot.columnField,
|
|
23719
23947
|
pivot.valueField,
|
|
23720
23948
|
...extras.map((v) => v?.field)
|
|
23721
|
-
].includes(filter2.field)
|
|
23722
|
-
throw new Error("Report filters require
|
|
23949
|
+
].includes(filter2.field))
|
|
23950
|
+
throw new Error("Report filters require a separate source field.");
|
|
23723
23951
|
if (filter2.item !== void 0 && !(filter2.item === null || typeof filter2.item === "string" || typeof filter2.item === "boolean" || typeof filter2.item === "number" && Number.isFinite(filter2.item) || isCellError(filter2.item) && isErrorCode(filter2.item.error) && Object.keys(filter2.item).length === 1))
|
|
23724
23952
|
throw new Error("Choose a cached literal report filter item.");
|
|
23725
23953
|
}
|
|
@@ -23732,10 +23960,10 @@ function pagedProjection(pivot) {
|
|
|
23732
23960
|
if (!filter2) return pivot;
|
|
23733
23961
|
const labels = /* @__PURE__ */ new Map();
|
|
23734
23962
|
for (const item of pivotItems(pivot, filter2.field)) {
|
|
23735
|
-
const
|
|
23736
|
-
if (
|
|
23963
|
+
const label2 = String(pivotItemLabel(item)).toLowerCase(), key3 = pivotValueKey(item);
|
|
23964
|
+
if (label2 === "(all)" || labels.has(label2) && labels.get(label2) !== key3)
|
|
23737
23965
|
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
23738
|
-
labels.set(
|
|
23966
|
+
labels.set(label2, key3);
|
|
23739
23967
|
}
|
|
23740
23968
|
if (filter2.item === void 0) return pivot;
|
|
23741
23969
|
const index3 = pivot.fields.indexOf(filter2.field), key2 = pivotValueKey(filter2.item);
|
|
@@ -23753,7 +23981,7 @@ function prependPivotPage(grid, pivot) {
|
|
|
23753
23981
|
values: [
|
|
23754
23982
|
[
|
|
23755
23983
|
pivot.pageFilter.field,
|
|
23756
|
-
pivot.pageFilter.item === void 0 ?
|
|
23984
|
+
pivot.pageFilter.item === void 0 ? pivotCaptions(pivot).all : pivotItemLabeler(pivot)(pivot.pageFilter.field, pivot.pageFilter.item),
|
|
23757
23985
|
...Array(width - 2).fill(null)
|
|
23758
23986
|
],
|
|
23759
23987
|
Array(width).fill(null),
|
|
@@ -23892,7 +24120,7 @@ function validatePivotFields(pivot) {
|
|
|
23892
24120
|
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
23893
24121
|
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
23894
24122
|
throw new Error("Values on rows require multiple measures.");
|
|
23895
|
-
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !==
|
|
24123
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
|
|
23896
24124
|
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
23897
24125
|
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
23898
24126
|
(measure2) => !measure2 || !pivot.fields.includes(measure2.field) || !PIVOT_AGGREGATES.includes(measure2.aggregate) || typeof measure2.caption !== "string" || !measure2.caption.trim() || measure2.caption.length > 255 || pivot.fields.some((field2) => field2.toLowerCase() === measure2.caption.toLowerCase())
|
|
@@ -23905,8 +24133,8 @@ function validatePivotFields(pivot) {
|
|
|
23905
24133
|
if (pivot.layout !== void 0 && !["tabular", "compact", "outline"].includes(pivot.layout) || pivot.subtotalPosition !== void 0 && !["top", "bottom"].includes(pivot.subtotalPosition) || !PIVOT_AGGREGATES.includes(pivot.aggregate) || !pivot.fields.includes(pivot.valueField) || [...rows, ...columns].some((field2) => !axisNames.includes(field2)) || (/* @__PURE__ */ new Set([...rows, ...columns])).size !== rows.length + columns.length || pivot.subtotals !== void 0 && typeof pivot.subtotals !== "boolean" || pivot.repeatLabels !== void 0 && typeof pivot.repeatLabels !== "boolean")
|
|
23906
24134
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
23907
24135
|
}
|
|
23908
|
-
function pivotCaption(aggregate2, field2) {
|
|
23909
|
-
return
|
|
24136
|
+
function pivotCaption(aggregate2, field2, pivot) {
|
|
24137
|
+
return pivotMeasureName(aggregate2, field2, pivot);
|
|
23910
24138
|
}
|
|
23911
24139
|
|
|
23912
24140
|
// xlsx/write/xml-out.ts
|
|
@@ -23953,7 +24181,7 @@ var pivotMeasures = (pivot) => [
|
|
|
23953
24181
|
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
23954
24182
|
...pivot.additionalValues ?? []
|
|
23955
24183
|
];
|
|
23956
|
-
function normalizedPivotMeasures(values2) {
|
|
24184
|
+
function normalizedPivotMeasures(values2, pivot) {
|
|
23957
24185
|
if (!Array.isArray(values2) || values2.length > 15)
|
|
23958
24186
|
throw new Error("Choose between one and sixteen PivotTable value fields.");
|
|
23959
24187
|
return values2.map((value2) => {
|
|
@@ -23965,7 +24193,7 @@ function normalizedPivotMeasures(values2) {
|
|
|
23965
24193
|
return {
|
|
23966
24194
|
field: value2.field,
|
|
23967
24195
|
aggregate: aggregate2,
|
|
23968
|
-
caption: value2.caption ??
|
|
24196
|
+
caption: value2.caption ?? pivotMeasureName(aggregate2, value2.field, pivot)
|
|
23969
24197
|
};
|
|
23970
24198
|
});
|
|
23971
24199
|
}
|
|
@@ -24000,7 +24228,6 @@ var pivotMeasureNumber = (pivot, records, measure2) => aggregateValues(records,
|
|
|
24000
24228
|
|
|
24001
24229
|
// xlsx/pivot/columns.ts
|
|
24002
24230
|
var SEPARATOR = "";
|
|
24003
|
-
var label = pivotItemLabel;
|
|
24004
24231
|
var columnKey = (keys, depth) => keys.slice(0, depth).join(SEPARATOR);
|
|
24005
24232
|
var recordColumnKeys = (record2, indices) => indices.map((index3) => pivotValueKey(record2[index3] ?? null));
|
|
24006
24233
|
function pivotColumnEntries(pivot) {
|
|
@@ -24075,7 +24302,9 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
|
24075
24302
|
const rows = levels + 1 + Number(count2 > 1);
|
|
24076
24303
|
const grid = Array.from({ length: rows }, () => Array(width).fill(null));
|
|
24077
24304
|
if (count2 === 1 && !valuesOnRows) grid[0][0] = pivot.valueCaption;
|
|
24078
|
-
const
|
|
24305
|
+
const caps = pivotCaptions(pivot);
|
|
24306
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24307
|
+
const titles = compact3 ? [caps.columnLabels] : [...columns.names, ...count2 > 1 ? [caps.values] : []];
|
|
24079
24308
|
titles.forEach((title, i2) => {
|
|
24080
24309
|
grid[0][labelColumns + i2] = title;
|
|
24081
24310
|
});
|
|
@@ -24088,17 +24317,17 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
|
24088
24317
|
if (entry3.kind === "leaf") {
|
|
24089
24318
|
entry3.path.forEach((_index, level) => {
|
|
24090
24319
|
const continued = entry3.path.slice(0, level + 1).every((p, i2) => p === previous[i2]);
|
|
24091
|
-
if (!continued) grid[1 + level][at2] =
|
|
24320
|
+
if (!continued) grid[1 + level][at2] = labelOf(columns.names[level], entry3.values[level]);
|
|
24092
24321
|
});
|
|
24093
24322
|
previous = entry3.path;
|
|
24094
24323
|
if (count2 > 1) measures2.forEach((measure2, m) => grid[rows - 1][at2 + m] = measure2.caption);
|
|
24095
24324
|
return;
|
|
24096
24325
|
}
|
|
24097
24326
|
const row3 = entry3.kind === "grand" ? 1 : entry3.path.length;
|
|
24098
|
-
const name3 = entry3.kind === "grand" ? "" : String(
|
|
24327
|
+
const name3 = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
|
|
24099
24328
|
measures2.forEach((measure2, m) => {
|
|
24100
|
-
const custom = entry3.fn ?
|
|
24101
|
-
grid[row3][at2 + m] = custom ? count2 === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure2.field}` : count2 === 1 ? entry3.kind === "grand" ?
|
|
24329
|
+
const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
|
|
24330
|
+
grid[row3][at2 + m] = custom ? count2 === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure2.field}` : count2 === 1 ? entry3.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name3) : entry3.kind === "grand" ? fillCaption(caps.measureTotal, measure2.caption) : `${name3} ${measure2.caption}`;
|
|
24102
24331
|
});
|
|
24103
24332
|
});
|
|
24104
24333
|
return grid;
|
|
@@ -24131,7 +24360,6 @@ function pivotColumnItemsXml(entries, measures2, remap) {
|
|
|
24131
24360
|
}
|
|
24132
24361
|
|
|
24133
24362
|
// xlsx/pivot/nested.ts
|
|
24134
|
-
var label2 = pivotItemLabel;
|
|
24135
24363
|
var MAX_CELLS = 1e6;
|
|
24136
24364
|
var node = (index3, value2) => ({
|
|
24137
24365
|
index: index3,
|
|
@@ -24161,6 +24389,8 @@ function nestedPivotGrid(pivot) {
|
|
|
24161
24389
|
const labelColumns = compact3 ? 1 : levels;
|
|
24162
24390
|
const measures2 = pivotMeasures(pivot);
|
|
24163
24391
|
const functions = names.map((name3) => fieldSubtotalFunctions(pivot, name3));
|
|
24392
|
+
const caps = pivotCaptions(pivot);
|
|
24393
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
24164
24394
|
const root = node(0, null);
|
|
24165
24395
|
for (const record2 of pivot.records) {
|
|
24166
24396
|
const keys = recordColumnKeys(record2, columnFields);
|
|
@@ -24187,7 +24417,7 @@ function nestedPivotGrid(pivot) {
|
|
|
24187
24417
|
}
|
|
24188
24418
|
const dimensions3 = pivotColumnDimensions(pivot, columns, labelColumns, onRows);
|
|
24189
24419
|
const rowTitles = names.map((name3) => name3);
|
|
24190
|
-
if (onRows) rowTitles.splice(valuesAt, 0,
|
|
24420
|
+
if (onRows) rowTitles.splice(valuesAt, 0, caps.values);
|
|
24191
24421
|
let values2 = [];
|
|
24192
24422
|
let indents = [];
|
|
24193
24423
|
const rowEntries = [];
|
|
@@ -24266,11 +24496,11 @@ function nestedPivotGrid(pivot) {
|
|
|
24266
24496
|
const children4 = [...group.children.values()].sort((a2, b) => a2.index - b.index);
|
|
24267
24497
|
children4.forEach((child7, position2) => {
|
|
24268
24498
|
const here = {
|
|
24269
|
-
labels: [...path2.labels,
|
|
24499
|
+
labels: [...path2.labels, labelOf(names[field2], child7.value)],
|
|
24270
24500
|
indices: [...path2.indices, child7.index],
|
|
24271
24501
|
firsts: [...path2.firsts, position2 === 0]
|
|
24272
24502
|
};
|
|
24273
|
-
const text8 =
|
|
24503
|
+
const text8 = labelOf(names[field2], child7.value);
|
|
24274
24504
|
if (last)
|
|
24275
24505
|
return push3(level, () => [
|
|
24276
24506
|
labelCells(path2, leafShown(here.firsts), level, text8),
|
|
@@ -24293,14 +24523,14 @@ function nestedPivotGrid(pivot) {
|
|
|
24293
24523
|
]);
|
|
24294
24524
|
if (own2 === "auto") {
|
|
24295
24525
|
if (showsValue) return;
|
|
24296
|
-
if (valuesAbove) subtotal(
|
|
24526
|
+
if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure2);
|
|
24297
24527
|
else measures2.forEach((one2, m) => subtotal(`${caption} ${one2.caption}`, void 0, m));
|
|
24298
24528
|
} else
|
|
24299
24529
|
for (const fn of own2)
|
|
24300
|
-
if (valuesAbove) subtotal(`${caption} ${
|
|
24530
|
+
if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure2);
|
|
24301
24531
|
else
|
|
24302
24532
|
measures2.forEach(
|
|
24303
|
-
(one2, m) => subtotal(`${caption} ${
|
|
24533
|
+
(one2, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one2.field}`, fn, m)
|
|
24304
24534
|
);
|
|
24305
24535
|
});
|
|
24306
24536
|
};
|
|
@@ -24311,12 +24541,12 @@ function nestedPivotGrid(pivot) {
|
|
|
24311
24541
|
]);
|
|
24312
24542
|
const build2 = () => {
|
|
24313
24543
|
walk2(0, root, void 0, { labels: [], indices: [], firsts: [] });
|
|
24314
|
-
if (onRows) measures2.forEach((one2, m) => grand(
|
|
24315
|
-
else grand(
|
|
24544
|
+
if (onRows) measures2.forEach((one2, m) => grand(fillCaption(caps.measureTotal, one2.caption), m));
|
|
24545
|
+
else grand(caps.grandTotal);
|
|
24316
24546
|
};
|
|
24317
24547
|
build2();
|
|
24318
24548
|
counting = false;
|
|
24319
|
-
values2 = pivotColumnHeaders(pivot, columns, compact3 ? [
|
|
24549
|
+
values2 = pivotColumnHeaders(pivot, columns, compact3 ? [caps.rowLabels] : rowTitles, onRows);
|
|
24320
24550
|
const firstDataRow = values2.length;
|
|
24321
24551
|
indents = values2.map(() => 0);
|
|
24322
24552
|
build2();
|
|
@@ -24349,14 +24579,14 @@ function pivotTableAt(sheet, at2) {
|
|
|
24349
24579
|
var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
24350
24580
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
24351
24581
|
var TABLE = {
|
|
24352
|
-
pivotTableDefinition: "name cacheId dataCaption dataOnRows dataPosition updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
|
|
24582
|
+
pivotTableDefinition: "name cacheId dataCaption grandTotalCaption rowHeaderCaption colHeaderCaption dataOnRows dataPosition updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
|
|
24353
24583
|
location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
|
|
24354
24584
|
pageFields: "count",
|
|
24355
24585
|
pageField: "fld item hier",
|
|
24356
24586
|
pivotFields: "count",
|
|
24357
24587
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal numFmtId sumSubtotal countASubtotal avgSubtotal maxSubtotal minSubtotal productSubtotal countSubtotal stdDevSubtotal stdDevPSubtotal varSubtotal varPSubtotal",
|
|
24358
24588
|
items: "count",
|
|
24359
|
-
item: "x t h",
|
|
24589
|
+
item: "x t h n",
|
|
24360
24590
|
rowFields: "count",
|
|
24361
24591
|
colFields: "count",
|
|
24362
24592
|
field: "x",
|
|
@@ -24457,8 +24687,8 @@ function inspect(node3, profile, cache3) {
|
|
|
24457
24687
|
}
|
|
24458
24688
|
for (const child7 of elements(node3)) inspect(child7, profile, cache3);
|
|
24459
24689
|
}
|
|
24460
|
-
function assertPivotAdmission(
|
|
24461
|
-
inspect(
|
|
24690
|
+
function assertPivotAdmission(table4, cache3) {
|
|
24691
|
+
inspect(table4, TABLE, false);
|
|
24462
24692
|
inspect(cache3, CACHE, true);
|
|
24463
24693
|
}
|
|
24464
24694
|
function assertPivotRecords(records) {
|
|
@@ -24469,6 +24699,121 @@ function assertPivotRecords(records) {
|
|
|
24469
24699
|
);
|
|
24470
24700
|
}
|
|
24471
24701
|
|
|
24702
|
+
// xlsx/pivot/captions-read.ts
|
|
24703
|
+
var ATTRIBUTES2 = {
|
|
24704
|
+
rowHeaderCaption: "rowLabels",
|
|
24705
|
+
colHeaderCaption: "columnLabels",
|
|
24706
|
+
grandTotalCaption: "grandTotal",
|
|
24707
|
+
dataCaption: "values"
|
|
24708
|
+
};
|
|
24709
|
+
function readPivotCaptionAttributes(root) {
|
|
24710
|
+
const out = {};
|
|
24711
|
+
for (const [attribute4, key2] of Object.entries(ATTRIBUTES2)) {
|
|
24712
|
+
const text8 = att(root, attribute4);
|
|
24713
|
+
if (text8 !== void 0)
|
|
24714
|
+
out[key2] = decodeEscapes(text8);
|
|
24715
|
+
}
|
|
24716
|
+
return out;
|
|
24717
|
+
}
|
|
24718
|
+
function aggregateCaptionsOf(pivot) {
|
|
24719
|
+
const out = {};
|
|
24720
|
+
for (const measure2 of [
|
|
24721
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
24722
|
+
...pivot.additionalValues ?? []
|
|
24723
|
+
]) {
|
|
24724
|
+
const at2 = measure2.caption.indexOf(measure2.field);
|
|
24725
|
+
if (at2 < 0 || measure2.caption === measure2.field) continue;
|
|
24726
|
+
const template = `${measure2.caption.slice(0, at2)}{0}${measure2.caption.slice(at2 + measure2.field.length)}`;
|
|
24727
|
+
if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure2.aggregate])
|
|
24728
|
+
out[measure2.aggregate] = template;
|
|
24729
|
+
}
|
|
24730
|
+
return Object.keys(out).length ? out : void 0;
|
|
24731
|
+
}
|
|
24732
|
+
var MARK = "";
|
|
24733
|
+
var SENTINELS = {
|
|
24734
|
+
rowLabels: `${MARK}R`,
|
|
24735
|
+
columnLabels: `${MARK}C`,
|
|
24736
|
+
grandTotal: `${MARK}G`,
|
|
24737
|
+
values: `${MARK}V`,
|
|
24738
|
+
all: `${MARK}A`,
|
|
24739
|
+
blank: `${MARK}B`,
|
|
24740
|
+
subtotal: `{0}${MARK}S`,
|
|
24741
|
+
measureTotal: `${MARK}M{0}`,
|
|
24742
|
+
functions: Object.fromEntries(
|
|
24743
|
+
Object.keys(ENGLISH_PIVOT_CAPTIONS.functions).map((fn) => [fn, `${MARK}F${fn}`])
|
|
24744
|
+
),
|
|
24745
|
+
aggregates: ENGLISH_PIVOT_CAPTIONS.aggregates
|
|
24746
|
+
};
|
|
24747
|
+
function templateOf(cached6, arg) {
|
|
24748
|
+
if (!arg || !cached6.includes(arg)) return void 0;
|
|
24749
|
+
if (cached6.startsWith(arg)) return `{0}${cached6.slice(arg.length)}`;
|
|
24750
|
+
if (cached6.endsWith(arg)) return `${cached6.slice(0, -arg.length)}{0}`;
|
|
24751
|
+
const at2 = cached6.indexOf(arg);
|
|
24752
|
+
return `${cached6.slice(0, at2)}{0}${cached6.slice(at2 + arg.length)}`;
|
|
24753
|
+
}
|
|
24754
|
+
function inferPivotCaptions(pivot, sheet, named3) {
|
|
24755
|
+
const known = pivotCaptions({ captions: named3 });
|
|
24756
|
+
const probe = { ...SENTINELS };
|
|
24757
|
+
for (const key2 of Object.keys(named3))
|
|
24758
|
+
if (typeof named3[key2] === "string")
|
|
24759
|
+
probe[key2] = known[key2];
|
|
24760
|
+
const grid = pivotGrid({ ...pivot, captions: probe });
|
|
24761
|
+
const found = /* @__PURE__ */ new Map();
|
|
24762
|
+
const set = (key2, value2) => {
|
|
24763
|
+
if (value2 === void 0) return;
|
|
24764
|
+
const before = found.get(key2);
|
|
24765
|
+
found.set(key2, before === void 0 || before === value2 ? value2 : null);
|
|
24766
|
+
};
|
|
24767
|
+
grid.values.forEach(
|
|
24768
|
+
(line3, r) => line3.forEach((expected, c2) => {
|
|
24769
|
+
if (typeof expected !== "string" || !expected.includes(MARK)) return;
|
|
24770
|
+
const cached6 = getCell(
|
|
24771
|
+
sheet,
|
|
24772
|
+
pivot.location.start.row + r,
|
|
24773
|
+
pivot.location.start.col + c2
|
|
24774
|
+
)?.value;
|
|
24775
|
+
if (typeof cached6 !== "string") return;
|
|
24776
|
+
const kind = /\u0001([RCGVASMFB])(\w*)/.exec(expected);
|
|
24777
|
+
if (!kind) return;
|
|
24778
|
+
const at2 = kind.index;
|
|
24779
|
+
switch (kind[1]) {
|
|
24780
|
+
case "R":
|
|
24781
|
+
return set("rowLabels", cached6);
|
|
24782
|
+
case "C":
|
|
24783
|
+
return set("columnLabels", cached6);
|
|
24784
|
+
case "G":
|
|
24785
|
+
return set("grandTotal", cached6);
|
|
24786
|
+
case "V":
|
|
24787
|
+
return set("values", cached6);
|
|
24788
|
+
case "A":
|
|
24789
|
+
return set("all", cached6);
|
|
24790
|
+
case "B":
|
|
24791
|
+
return set("blank", cached6);
|
|
24792
|
+
case "S":
|
|
24793
|
+
return set("subtotal", templateOf(cached6, expected.slice(0, at2)));
|
|
24794
|
+
case "M":
|
|
24795
|
+
return set("measureTotal", templateOf(cached6, expected.slice(at2 + 2)));
|
|
24796
|
+
case "F": {
|
|
24797
|
+
const item = expected.slice(0, at2 - 1);
|
|
24798
|
+
const of = / of (.*)$/.exec(expected.slice(at2));
|
|
24799
|
+
const word = cached6.slice(item.length + 1, of ? cached6.length - of[0].length : void 0);
|
|
24800
|
+
if (cached6.startsWith(`${item} `) && (!of || cached6.endsWith(of[0])))
|
|
24801
|
+
set(`function:${kind[2]}`, word);
|
|
24802
|
+
}
|
|
24803
|
+
}
|
|
24804
|
+
})
|
|
24805
|
+
);
|
|
24806
|
+
const out = pivotCaptions({ captions: named3 });
|
|
24807
|
+
const functions = { ...out.functions };
|
|
24808
|
+
for (const [key2, value2] of found) {
|
|
24809
|
+
if (value2 === null) continue;
|
|
24810
|
+
if (key2.startsWith("function:")) functions[key2.slice(9)] = value2;
|
|
24811
|
+
else out[key2] = value2;
|
|
24812
|
+
}
|
|
24813
|
+
out.functions = functions;
|
|
24814
|
+
return trimmedCaptions(out);
|
|
24815
|
+
}
|
|
24816
|
+
|
|
24472
24817
|
// xlsx/slicer/read-slicers.ts
|
|
24473
24818
|
var TABLE_SLICER_URI = "{2F2917AC-EB37-4324-AD4E-5DD8C200BD13}";
|
|
24474
24819
|
var X152 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
@@ -24544,12 +24889,12 @@ function parseSlicerCache(xml, partName) {
|
|
|
24544
24889
|
if (data) return void 0;
|
|
24545
24890
|
const list2 = byLocal(root, "extLst");
|
|
24546
24891
|
const ext = list2 ? elements(list2).find((node3) => node3.getAttribute("uri") === TABLE_SLICER_URI) : void 0;
|
|
24547
|
-
const
|
|
24548
|
-
const tableId = numAttr(
|
|
24549
|
-
const column2 = numAttr(
|
|
24550
|
-
if (!
|
|
24892
|
+
const table4 = ext ? first(ext, "tableSlicerCache", X152) : void 0;
|
|
24893
|
+
const tableId = numAttr(table4, "tableId");
|
|
24894
|
+
const column2 = numAttr(table4, "column");
|
|
24895
|
+
if (!table4 || tableId === void 0 || column2 === void 0) return void 0;
|
|
24551
24896
|
const cache3 = { ...common, source: { kind: "table", tableId, column: column2 } };
|
|
24552
|
-
if (att(
|
|
24897
|
+
if (att(table4, "sortOrder") === "descending") cache3.sortOrder = "descending";
|
|
24553
24898
|
if (elements(root).some((node3) => node3.localName === "pivotTables")) return void 0;
|
|
24554
24899
|
return cache3;
|
|
24555
24900
|
}
|
|
@@ -24634,14 +24979,14 @@ function parseTimelineCache(xml, partName) {
|
|
|
24634
24979
|
}
|
|
24635
24980
|
|
|
24636
24981
|
// xlsx/slicer/table-filter.ts
|
|
24637
|
-
function tableFilterBounds(
|
|
24982
|
+
function tableFilterBounds(table4) {
|
|
24638
24983
|
return {
|
|
24639
|
-
start:
|
|
24640
|
-
end: { ...
|
|
24984
|
+
start: table4.range.start,
|
|
24985
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
24641
24986
|
};
|
|
24642
24987
|
}
|
|
24643
|
-
function tableAutoFilter(
|
|
24644
|
-
const columns =
|
|
24988
|
+
function tableAutoFilter(table4) {
|
|
24989
|
+
const columns = table4.columns.flatMap(
|
|
24645
24990
|
(column2, offset2) => column2.filter ? [
|
|
24646
24991
|
{
|
|
24647
24992
|
offset: offset2,
|
|
@@ -24651,12 +24996,12 @@ function tableAutoFilter(table3) {
|
|
|
24651
24996
|
] : []
|
|
24652
24997
|
);
|
|
24653
24998
|
if (!columns.length) return void 0;
|
|
24654
|
-
return { range: tableFilterBounds(
|
|
24999
|
+
return { range: tableFilterBounds(table4), columns };
|
|
24655
25000
|
}
|
|
24656
|
-
function applyTableFilter(workbook, sheet,
|
|
24657
|
-
if (!
|
|
24658
|
-
const bounds2 = tableFilterBounds(
|
|
24659
|
-
const filter2 = tableAutoFilter(
|
|
25001
|
+
function applyTableFilter(workbook, sheet, table4) {
|
|
25002
|
+
if (!table4.headerRow) return;
|
|
25003
|
+
const bounds2 = tableFilterBounds(table4);
|
|
25004
|
+
const filter2 = tableAutoFilter(table4);
|
|
24660
25005
|
for (let row3 = bounds2.start.row + 1; row3 <= bounds2.end.row; row3++) {
|
|
24661
25006
|
const visible = !filter2 || rowMatchesFilter(workbook, sheet, row3, filter2);
|
|
24662
25007
|
setRowFiltered(sheet, row3, !visible, !!filter2);
|
|
@@ -24664,8 +25009,8 @@ function applyTableFilter(workbook, sheet, table3) {
|
|
|
24664
25009
|
}
|
|
24665
25010
|
function readTableFilteredRows(workbook) {
|
|
24666
25011
|
for (const sheet of workbook.sheets)
|
|
24667
|
-
for (const
|
|
24668
|
-
const filter2 = tableAutoFilter(
|
|
25012
|
+
for (const table4 of sheet.tables) {
|
|
25013
|
+
const filter2 = tableAutoFilter(table4);
|
|
24669
25014
|
if (!filter2) continue;
|
|
24670
25015
|
for (let row3 = filter2.range.start.row + 1; row3 <= filter2.range.end.row; row3++) {
|
|
24671
25016
|
const info = sheet.rowInfo.get(row3);
|
|
@@ -24784,9 +25129,9 @@ function settleSlicers(workbook, warn) {
|
|
|
24784
25129
|
if (cache3.source.kind === "table") {
|
|
24785
25130
|
const { tableId, column: column2 } = cache3.source;
|
|
24786
25131
|
for (const sheet of workbook.sheets) {
|
|
24787
|
-
const
|
|
24788
|
-
if (
|
|
24789
|
-
return
|
|
25132
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === tableId);
|
|
25133
|
+
if (table4)
|
|
25134
|
+
return table4.headerRow && !table4.filterNotModeled && table4.columns.some((entry3) => entry3.sourceId === column2);
|
|
24790
25135
|
}
|
|
24791
25136
|
return false;
|
|
24792
25137
|
}
|
|
@@ -24964,7 +25309,7 @@ function readFieldGroups(fields, names) {
|
|
|
24964
25309
|
throw new Error("Unsupported pivot field group");
|
|
24965
25310
|
const labels = children(list2, "s", NS.x).map((node3) => decodeEscapes(att(node3, "v") ?? ""));
|
|
24966
25311
|
const expected = numberGroupLabels({ start, end, by });
|
|
24967
|
-
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((
|
|
25312
|
+
if (elements(list2).length !== labels.length || labels.length !== expected.length || labels.some((label2, i2) => label2 !== expected[i2]))
|
|
24968
25313
|
throw new Error("Unsupported pivot group items");
|
|
24969
25314
|
groups.push({ field: names[index3] ?? "", start, end, by });
|
|
24970
25315
|
});
|
|
@@ -25048,7 +25393,7 @@ function readDateGroups(fields, count2, names, dateFields, records, date1904) {
|
|
|
25048
25393
|
const node3 = first(first(entry3.node, "fieldGroup", NS.x), "groupItems", NS.x);
|
|
25049
25394
|
const actual = children(node3, "s", NS.x).map((item) => decodeEscapes(att(item, "v") ?? ""));
|
|
25050
25395
|
const name3 = decodeEscapes(att(entry3.node, "name") ?? "");
|
|
25051
|
-
if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((
|
|
25396
|
+
if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((label2) => !label2) || new Set(actual).size !== actual.length)
|
|
25052
25397
|
throw unsupported("group items");
|
|
25053
25398
|
if (name3 !== dateGroupFieldName(entry3.unit, field2) || actual.some((l, i2) => l !== labels[i2]))
|
|
25054
25399
|
localized[entry3.unit] = { name: name3, labels: actual };
|
|
@@ -25106,6 +25451,25 @@ function readItemFilters(fields, names, shared) {
|
|
|
25106
25451
|
return filters.length ? filters : void 0;
|
|
25107
25452
|
}
|
|
25108
25453
|
|
|
25454
|
+
// xlsx/pivot/item-names-read.ts
|
|
25455
|
+
function readItemNames(tableFields, names, shared) {
|
|
25456
|
+
const out = [];
|
|
25457
|
+
tableFields.forEach((field2, index3) => {
|
|
25458
|
+
const list2 = first(field2, "items", NS.x);
|
|
25459
|
+
if (!list2 || index3 >= names.length) return;
|
|
25460
|
+
for (const item of children(list2, "item", NS.x)) {
|
|
25461
|
+
const name3 = att(item, "n");
|
|
25462
|
+
if (name3 === void 0) continue;
|
|
25463
|
+
const at2 = Number(att(item, "x"));
|
|
25464
|
+
const value2 = shared[index3]?.[at2];
|
|
25465
|
+
if (att(item, "t") !== void 0 || !Number.isInteger(at2) || value2 === void 0)
|
|
25466
|
+
throw new Error("Unsupported pivot item name");
|
|
25467
|
+
out.push({ field: names[index3], item: value2, name: decodeEscapes(name3) });
|
|
25468
|
+
}
|
|
25469
|
+
});
|
|
25470
|
+
return out;
|
|
25471
|
+
}
|
|
25472
|
+
|
|
25109
25473
|
// xlsx/pivot/values-axis.ts
|
|
25110
25474
|
function remapPivotRowEntries(entries, axes2) {
|
|
25111
25475
|
return entries.map(
|
|
@@ -25228,7 +25592,10 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25228
25592
|
};
|
|
25229
25593
|
const rowAxes = pivotRowFields(pivot).map((name3) => axisValues(name3, "axisRow")), rowItems = read("rowItems");
|
|
25230
25594
|
const grid = pivotGrid(pivot);
|
|
25231
|
-
const
|
|
25595
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
25596
|
+
const levelAxes = [...rowAxes];
|
|
25597
|
+
if (valuesAt >= 0) levelAxes.splice(valuesAt, 0, null);
|
|
25598
|
+
const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, levelAxes) : [
|
|
25232
25599
|
...rowAxes[0].map((index3) => ({ indices: [index3] })),
|
|
25233
25600
|
{ indices: [0], type: "grand" }
|
|
25234
25601
|
];
|
|
@@ -25238,11 +25605,11 @@ function assertPageAxisItems(root, pivot, shared, cache3, recordRoot) {
|
|
|
25238
25605
|
const expected2 = entries[i2];
|
|
25239
25606
|
const xs = children(item, "x", NS.x).map((x) => integer3(x.getAttribute("v"), 0)), prefix3 = integer3(item.getAttribute("r"), 0);
|
|
25240
25607
|
const type = expected2.type === void 0 || expected2.type === "default" || expected2.type === "grand" ? expected2.type : PIVOT_SUBTOTALS[expected2.type].item;
|
|
25241
|
-
if (item.getAttribute("t") !== (type ?? null) || !Number.isInteger(prefix3) || prefix3 < 0 || prefix3 > previousRow.length || prefix3 >= expected2.indices.length || expected2.type === "grand" && prefix3 !== 0 || integer3(item.getAttribute("i"), 0) !== 0 || JSON.stringify([...previousRow.slice(0, prefix3), ...xs]) !== JSON.stringify(expected2.indices))
|
|
25608
|
+
if (item.getAttribute("t") !== (type ?? null) || !Number.isInteger(prefix3) || prefix3 < 0 || prefix3 > previousRow.length || prefix3 >= expected2.indices.length || expected2.type === "grand" && prefix3 !== 0 || integer3(item.getAttribute("i"), 0) !== (expected2.measure ?? 0) || JSON.stringify([...previousRow.slice(0, prefix3), ...xs]) !== JSON.stringify(expected2.indices))
|
|
25242
25609
|
throw new Error("Unmodeled page row item");
|
|
25243
25610
|
previousRow = expected2.type === "grand" ? [] : expected2.indices;
|
|
25244
25611
|
});
|
|
25245
|
-
const measures2 = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25612
|
+
const measures2 = valuesAt >= 0 ? 1 : 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
|
|
25246
25613
|
if (columns)
|
|
25247
25614
|
for (const col of columns)
|
|
25248
25615
|
for (let m = 0; m < measures2; m++) expected.push(measures2 > 1 ? [col, m] : [col]);
|
|
@@ -25284,6 +25651,10 @@ function value(node3, date1904 = false) {
|
|
|
25284
25651
|
if (node3.localName === "e" && isErrorCode(v)) return { error: v };
|
|
25285
25652
|
throw new Error("Unsupported pivot cache item");
|
|
25286
25653
|
}
|
|
25654
|
+
var namedAggregates = (pivot) => {
|
|
25655
|
+
const aggregates = aggregateCaptionsOf(pivot);
|
|
25656
|
+
return aggregates ? { aggregates } : {};
|
|
25657
|
+
};
|
|
25287
25658
|
function readOne(workbook, source2, part) {
|
|
25288
25659
|
const xml = source2.text(part);
|
|
25289
25660
|
const root = parseXml(xml).documentElement;
|
|
@@ -25430,6 +25801,7 @@ function readOne(workbook, source2, part) {
|
|
|
25430
25801
|
location.start.row -= 2;
|
|
25431
25802
|
}
|
|
25432
25803
|
const itemFilters = readItemFilters(tableFields, names, shared);
|
|
25804
|
+
const itemNames = readItemNames(tableFields, names, shared);
|
|
25433
25805
|
const slicerCacheId = readSlicerCacheId(cache3);
|
|
25434
25806
|
const fieldGroups = readFieldGroups(fields, names);
|
|
25435
25807
|
const dateFields = readDateFields(fields, names);
|
|
@@ -25468,6 +25840,7 @@ function readOne(workbook, source2, part) {
|
|
|
25468
25840
|
const pivot = {
|
|
25469
25841
|
...pageFilter ? { pageFilter } : {},
|
|
25470
25842
|
...itemFilters ? { itemFilters } : {},
|
|
25843
|
+
...itemNames.length ? { itemNames } : {},
|
|
25471
25844
|
...fieldGroups.length ? { fieldGroups } : {},
|
|
25472
25845
|
...dateFields.length ? { dateFields } : {},
|
|
25473
25846
|
...dateGroups.length ? { dateGroups } : {},
|
|
@@ -25510,6 +25883,12 @@ function readOne(workbook, source2, part) {
|
|
|
25510
25883
|
...col ? { columnField: col } : {},
|
|
25511
25884
|
...moreColumns.length ? { moreColumnFields: moreColumns } : {}
|
|
25512
25885
|
};
|
|
25886
|
+
const captions = trimmedCaptions(
|
|
25887
|
+
pivotCaptions({
|
|
25888
|
+
captions: { ...readPivotCaptionAttributes(root), ...namedAggregates(pivot) }
|
|
25889
|
+
})
|
|
25890
|
+
);
|
|
25891
|
+
if (captions) pivot.captions = captions;
|
|
25513
25892
|
if (pageFilter && moreColumns.length) throw new Error("Report filters support one column field");
|
|
25514
25893
|
assertPageAxisItems(root, pivot, shared, cache3, recordRoot);
|
|
25515
25894
|
return pivot;
|
|
@@ -25537,6 +25916,12 @@ function readPivotTables(workbook, source2, warn, slicers) {
|
|
|
25537
25916
|
if (slicers.blocked.has(pivotKey(sheet.sheetId, name3)) || cache3 && (caches2.get(cache3) ?? 0) > 1)
|
|
25538
25917
|
throw new Error("Shared pivot cache or unsupported slicer connection");
|
|
25539
25918
|
const pivot = readOne(workbook, source2, part);
|
|
25919
|
+
const inferred = inferPivotCaptions(pivot, sheet, {
|
|
25920
|
+
...readPivotCaptionAttributes(parseXml(pivot.sourceXml).documentElement),
|
|
25921
|
+
...namedAggregates(pivot)
|
|
25922
|
+
});
|
|
25923
|
+
if (inferred) pivot.captions = inferred;
|
|
25924
|
+
else delete pivot.captions;
|
|
25540
25925
|
const grid = pivotGrid(pivot);
|
|
25541
25926
|
if (grid.values.length !== pivot.location.end.row - pivot.location.start.row + 1 || grid.values[0].length !== pivot.location.end.col - pivot.location.start.col + 1 || grid.values.some(
|
|
25542
25927
|
(line3, r) => line3.some(
|
|
@@ -26176,7 +26561,7 @@ function mergeSpacedAreas(tokens3) {
|
|
|
26176
26561
|
}
|
|
26177
26562
|
return out;
|
|
26178
26563
|
}
|
|
26179
|
-
function
|
|
26564
|
+
function templateOf2(formula) {
|
|
26180
26565
|
const cached6 = templates.get(formula);
|
|
26181
26566
|
if (cached6 !== void 0) return cached6;
|
|
26182
26567
|
const raw2 = safeTokens(formula);
|
|
@@ -26206,7 +26591,7 @@ function templateOf(formula) {
|
|
|
26206
26591
|
return template;
|
|
26207
26592
|
}
|
|
26208
26593
|
function rewriteTemplate(formula, rewrite2) {
|
|
26209
|
-
const template =
|
|
26594
|
+
const template = templateOf2(formula);
|
|
26210
26595
|
if (!template) return formula;
|
|
26211
26596
|
let next;
|
|
26212
26597
|
for (let i2 = 0; i2 < template.length; i2++) {
|
|
@@ -27507,14 +27892,14 @@ function readDataTable(f6) {
|
|
|
27507
27892
|
const ref = parseRange(att(f6, "ref") ?? "");
|
|
27508
27893
|
const r1 = att(f6, "r1");
|
|
27509
27894
|
if (!ref || !r1) return void 0;
|
|
27510
|
-
const
|
|
27895
|
+
const table4 = { ref, r1 };
|
|
27511
27896
|
const r2 = att(f6, "r2");
|
|
27512
|
-
if (r2)
|
|
27513
|
-
if (boolAttr(f6, "dt2D"))
|
|
27514
|
-
if (boolAttr(f6, "dtr"))
|
|
27515
|
-
if (boolAttr(f6, "del1"))
|
|
27516
|
-
if (boolAttr(f6, "del2"))
|
|
27517
|
-
return
|
|
27897
|
+
if (r2) table4.r2 = r2;
|
|
27898
|
+
if (boolAttr(f6, "dt2D")) table4.dt2D = true;
|
|
27899
|
+
if (boolAttr(f6, "dtr")) table4.dtr = true;
|
|
27900
|
+
if (boolAttr(f6, "del1")) table4.del1 = true;
|
|
27901
|
+
if (boolAttr(f6, "del2")) table4.del2 = true;
|
|
27902
|
+
return table4;
|
|
27518
27903
|
}
|
|
27519
27904
|
function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet) {
|
|
27520
27905
|
const kind = att(f6, "t") ?? "normal";
|
|
@@ -27538,8 +27923,8 @@ function readFormula(ctx, f6, row3, col, cell, masters, dynamic2, anchors, sheet
|
|
|
27538
27923
|
}
|
|
27539
27924
|
if (kind === "dataTable") {
|
|
27540
27925
|
delete cell.legacyFormula;
|
|
27541
|
-
const
|
|
27542
|
-
if (
|
|
27926
|
+
const table4 = readDataTable(f6);
|
|
27927
|
+
if (table4) (sheet.dataTables ??= []).push(table4);
|
|
27543
27928
|
else ctx.warn("A what-if data table formula could not be read; its cached values were kept.");
|
|
27544
27929
|
return;
|
|
27545
27930
|
}
|
|
@@ -27731,14 +28116,14 @@ function parseTable3(xml, partName) {
|
|
|
27731
28116
|
if (id3 !== void 0 && Number.isInteger(id3) && id3 >= 0) column2.sourceId = id3;
|
|
27732
28117
|
const fn = att(node3, "totalsRowFunction");
|
|
27733
28118
|
if (fn && fn !== "none") column2.totalsRowFunction = fn;
|
|
27734
|
-
const
|
|
27735
|
-
if (
|
|
28119
|
+
const label2 = att(node3, "totalsRowLabel");
|
|
28120
|
+
if (label2 !== void 0) column2.totalsRowLabel = label2;
|
|
27736
28121
|
const calculated = xFirst(node3, "calculatedColumnFormula");
|
|
27737
28122
|
if (calculated) column2.calculatedColumnFormula = stripFuturePrefixes(xText(calculated));
|
|
27738
28123
|
return column2;
|
|
27739
28124
|
}
|
|
27740
28125
|
);
|
|
27741
|
-
const
|
|
28126
|
+
const table4 = {
|
|
27742
28127
|
id: numAttr(root, "id") ?? 1,
|
|
27743
28128
|
name: name3,
|
|
27744
28129
|
displayName: att(root, "displayName") ?? name3,
|
|
@@ -27748,26 +28133,26 @@ function parseTable3(xml, partName) {
|
|
|
27748
28133
|
columns,
|
|
27749
28134
|
partName
|
|
27750
28135
|
};
|
|
27751
|
-
readColumnFilters(root,
|
|
28136
|
+
readColumnFilters(root, table4);
|
|
27752
28137
|
const info = xFirst(root, "tableStyleInfo");
|
|
27753
28138
|
if (info) {
|
|
27754
28139
|
const style3 = att(info, "name");
|
|
27755
|
-
if (style3)
|
|
27756
|
-
|
|
27757
|
-
|
|
27758
|
-
|
|
27759
|
-
|
|
28140
|
+
if (style3) table4.styleName = style3;
|
|
28141
|
+
table4.showRowStripes = boolAttr(info, "showRowStripes", false);
|
|
28142
|
+
table4.showColumnStripes = boolAttr(info, "showColumnStripes", false);
|
|
28143
|
+
table4.showFirstColumn = boolAttr(info, "showFirstColumn", false);
|
|
28144
|
+
table4.showLastColumn = boolAttr(info, "showLastColumn", false);
|
|
27760
28145
|
}
|
|
27761
|
-
return
|
|
28146
|
+
return table4;
|
|
27762
28147
|
}
|
|
27763
|
-
function readColumnFilters(root,
|
|
28148
|
+
function readColumnFilters(root, table4) {
|
|
27764
28149
|
const filter2 = xFirst(root, "autoFilter");
|
|
27765
28150
|
for (const node3 of filter2 ? xChildren(filter2, "filterColumn") : []) {
|
|
27766
|
-
const column2 =
|
|
28151
|
+
const column2 = table4.columns[numAttr(node3, "colId") ?? -1];
|
|
27767
28152
|
const filters = xChildren(node3, "filters");
|
|
27768
28153
|
const simple = column2 && isValueListFilterColumn(node3);
|
|
27769
28154
|
if (!simple) {
|
|
27770
|
-
|
|
28155
|
+
table4.filterNotModeled = true;
|
|
27771
28156
|
continue;
|
|
27772
28157
|
}
|
|
27773
28158
|
const values2 = xChildren(filters[0], "filter").map((child7) => att(child7, "val") ?? "");
|
|
@@ -27846,8 +28231,8 @@ function readTables(ctx, partName, node3, sheet) {
|
|
|
27846
28231
|
const rel = rels.get(relAttr(part, "id") ?? "");
|
|
27847
28232
|
const target2 = rel ? ctx.source.target(partName, rel) : void 0;
|
|
27848
28233
|
const xml = target2 ? ctx.source.text(target2) : void 0;
|
|
27849
|
-
const
|
|
27850
|
-
if (
|
|
28234
|
+
const table4 = target2 && xml ? parseTable3(xml, target2) : void 0;
|
|
28235
|
+
if (table4) sheet.tables.push(table4);
|
|
27851
28236
|
else ctx.warn("A table part could not be read and was dropped.");
|
|
27852
28237
|
}
|
|
27853
28238
|
}
|
|
@@ -30317,14 +30702,14 @@ function unique(args, ctx) {
|
|
|
30317
30702
|
const byCol = args.length > 1 && args[1] !== null && toBool(ctx.toScalar(args[1] ?? null));
|
|
30318
30703
|
const once = args.length > 2 && args[2] !== null && toBool(ctx.toScalar(args[2] ?? null));
|
|
30319
30704
|
if (byCol) m = transpose(m);
|
|
30320
|
-
const
|
|
30705
|
+
const keyOf3 = (row3) => JSON.stringify(
|
|
30321
30706
|
row3.map(
|
|
30322
30707
|
(v) => isError(v) ? `#${v.error}` : typeof v === "string" ? `s${v.toLowerCase()}` : v
|
|
30323
30708
|
)
|
|
30324
30709
|
);
|
|
30325
30710
|
const counts = /* @__PURE__ */ new Map();
|
|
30326
30711
|
for (const row3 of m.data) {
|
|
30327
|
-
const key2 =
|
|
30712
|
+
const key2 = keyOf3(row3);
|
|
30328
30713
|
const entry3 = counts.get(key2);
|
|
30329
30714
|
if (entry3) entry3.count++;
|
|
30330
30715
|
else counts.set(key2, { row: row3, count: 1 });
|
|
@@ -30609,30 +30994,30 @@ function gammaLn(z) {
|
|
|
30609
30994
|
|
|
30610
30995
|
// xlsx/formula/functions/database.ts
|
|
30611
30996
|
var C3 = "Database";
|
|
30612
|
-
var
|
|
30997
|
+
var label = (value2) => value2 === null ? "" : typeof value2 === "string" ? value2 : String(value2);
|
|
30613
30998
|
function tableOf(ctx, value2) {
|
|
30614
30999
|
const [head, ...records] = ctx.toMatrix(value2 ?? null).data;
|
|
30615
31000
|
if (!head || records.length === 0) fail(ERR.VALUE);
|
|
30616
|
-
return { headers: head.map((v) =>
|
|
31001
|
+
return { headers: head.map((v) => label(v).toLowerCase()), records };
|
|
30617
31002
|
}
|
|
30618
|
-
function fieldIndex(
|
|
31003
|
+
function fieldIndex(table4, field2) {
|
|
30619
31004
|
const value2 = scalar2(field2);
|
|
30620
31005
|
if (isError(value2)) fail(value2);
|
|
30621
31006
|
if (typeof value2 === "number") {
|
|
30622
31007
|
const index4 = Math.trunc(value2) - 1;
|
|
30623
|
-
if (index4 < 0 || index4 >=
|
|
31008
|
+
if (index4 < 0 || index4 >= table4.headers.length) fail(ERR.VALUE);
|
|
30624
31009
|
return index4;
|
|
30625
31010
|
}
|
|
30626
|
-
const index3 =
|
|
31011
|
+
const index3 = table4.headers.indexOf(label(value2).toLowerCase());
|
|
30627
31012
|
if (index3 < 0) fail(ERR.VALUE);
|
|
30628
31013
|
return index3;
|
|
30629
31014
|
}
|
|
30630
|
-
function recordFilter(
|
|
31015
|
+
function recordFilter(table4, criteria) {
|
|
30631
31016
|
const [head, ...rows] = criteria;
|
|
30632
31017
|
if (!head || rows.length === 0) fail(ERR.VALUE);
|
|
30633
31018
|
const columns = head.map((name3) => {
|
|
30634
31019
|
if (name3 === null || name3 === "") return -1;
|
|
30635
|
-
return
|
|
31020
|
+
return table4.headers.indexOf(label(name3).toLowerCase());
|
|
30636
31021
|
});
|
|
30637
31022
|
const alternatives = rows.map(
|
|
30638
31023
|
(row3) => row3.flatMap((cell, c2) => {
|
|
@@ -30646,10 +31031,10 @@ function recordFilter(table3, criteria) {
|
|
|
30646
31031
|
return (record2) => alternatives.some((tests) => tests.every((test) => test(record2)));
|
|
30647
31032
|
}
|
|
30648
31033
|
function selected(ctx, args) {
|
|
30649
|
-
const
|
|
30650
|
-
const column2 = fieldIndex(
|
|
30651
|
-
const matches2 = recordFilter(
|
|
30652
|
-
return
|
|
31034
|
+
const table4 = tableOf(ctx, args[0]);
|
|
31035
|
+
const column2 = fieldIndex(table4, args[1]);
|
|
31036
|
+
const matches2 = recordFilter(table4, ctx.toMatrix(args[2] ?? null).data);
|
|
31037
|
+
return table4.records.filter(matches2).map((record2) => record2[column2] ?? null);
|
|
30653
31038
|
}
|
|
30654
31039
|
var numbers = (values2) => {
|
|
30655
31040
|
for (const v of values2) if (isError(v)) fail(v);
|
|
@@ -31477,9 +31862,9 @@ var BESSEL_FUNCTIONS = [
|
|
|
31477
31862
|
];
|
|
31478
31863
|
|
|
31479
31864
|
// xlsx/formula/functions/convert.ts
|
|
31480
|
-
var
|
|
31865
|
+
var table2 = /* @__PURE__ */ new Map();
|
|
31481
31866
|
var add3 = (dimension3, names, factor, extra = {}) => {
|
|
31482
|
-
for (const name3 of names)
|
|
31867
|
+
for (const name3 of names) table2.set(name3, { dimension: dimension3, factor, ...extra });
|
|
31483
31868
|
};
|
|
31484
31869
|
add3("mass", ["g"], 1, { prefix: "metric" });
|
|
31485
31870
|
add3("mass", ["sg"], 14593.9029372064);
|
|
@@ -31610,10 +31995,10 @@ var BINARY2 = {
|
|
|
31610
31995
|
ki: 2 ** 10
|
|
31611
31996
|
};
|
|
31612
31997
|
function resolve(name3) {
|
|
31613
|
-
const direct =
|
|
31998
|
+
const direct = table2.get(name3);
|
|
31614
31999
|
if (direct) return { dimension: direct.dimension, factor: direct.factor };
|
|
31615
32000
|
for (const length of [2, 1]) {
|
|
31616
|
-
const unit3 =
|
|
32001
|
+
const unit3 = table2.get(name3.slice(length));
|
|
31617
32002
|
const prefix3 = name3.slice(0, length);
|
|
31618
32003
|
if (!unit3?.prefix) continue;
|
|
31619
32004
|
const scale2 = (unit3.prefix === "binary" ? BINARY2[prefix3] : void 0) ?? METRIC[prefix3];
|
|
@@ -32948,30 +33333,30 @@ function findTable(host, name3, sheet, row3, col) {
|
|
|
32948
33333
|
if (name3) {
|
|
32949
33334
|
const lower3 = name3.toLowerCase();
|
|
32950
33335
|
for (let s = 0; s < sheets.length; s++) {
|
|
32951
|
-
const
|
|
33336
|
+
const table5 = sheets[s]?.tables.find(
|
|
32952
33337
|
(t) => t.displayName.toLowerCase() === lower3 || t.name.toLowerCase() === lower3
|
|
32953
33338
|
);
|
|
32954
|
-
if (
|
|
33339
|
+
if (table5) return { table: table5, sheet: s };
|
|
32955
33340
|
}
|
|
32956
33341
|
return void 0;
|
|
32957
33342
|
}
|
|
32958
|
-
const
|
|
33343
|
+
const table4 = sheets[sheet]?.tables.find(
|
|
32959
33344
|
(t) => row3 >= t.range.start.row && row3 <= t.range.end.row && col >= t.range.start.col && col <= t.range.end.col
|
|
32960
33345
|
);
|
|
32961
|
-
return
|
|
33346
|
+
return table4 ? { table: table4, sheet } : void 0;
|
|
32962
33347
|
}
|
|
32963
33348
|
function resolveStructured(ref, frame2) {
|
|
32964
33349
|
const found = findTable(frame2.host, ref.table, frame2.sheet, frame2.row, frame2.col);
|
|
32965
33350
|
if (!found) return ref.table ? ERR.NAME : ERR.REF;
|
|
32966
|
-
const { table:
|
|
32967
|
-
const range2 = normalizeRange(
|
|
32968
|
-
const headerRow =
|
|
32969
|
-
const dataStart = range2.start.row + (
|
|
32970
|
-
const dataEnd = range2.end.row - (
|
|
32971
|
-
const totalsRow =
|
|
33351
|
+
const { table: table4, sheet } = found;
|
|
33352
|
+
const range2 = normalizeRange(table4.range);
|
|
33353
|
+
const headerRow = table4.headerRow ? range2.start.row : -1;
|
|
33354
|
+
const dataStart = range2.start.row + (table4.headerRow ? 1 : 0);
|
|
33355
|
+
const dataEnd = range2.end.row - (table4.totalsRow ? 1 : 0);
|
|
33356
|
+
const totalsRow = table4.totalsRow ? range2.end.row : -1;
|
|
32972
33357
|
const columnOf = (name3) => {
|
|
32973
33358
|
const lower3 = name3.toLowerCase();
|
|
32974
|
-
const index3 =
|
|
33359
|
+
const index3 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === lower3);
|
|
32975
33360
|
return index3 < 0 ? -1 : range2.start.col + index3;
|
|
32976
33361
|
};
|
|
32977
33362
|
let c1 = range2.start.col;
|
|
@@ -34283,16 +34668,16 @@ function lookupArray(value2) {
|
|
|
34283
34668
|
}
|
|
34284
34669
|
function vhlookup(args, ctx, vertical2) {
|
|
34285
34670
|
const lookup2 = blankAsZero(args);
|
|
34286
|
-
const
|
|
34671
|
+
const table4 = lookupArray(args[1] ?? null);
|
|
34287
34672
|
const index3 = int3(args[2]);
|
|
34288
34673
|
const approximate2 = args.length < 4 ? true : bool(args[3]);
|
|
34289
|
-
const { rows, cols } = shape(
|
|
34674
|
+
const { rows, cols } = shape(table4);
|
|
34290
34675
|
if (index3 < 1) fail(ERR.VALUE);
|
|
34291
34676
|
if (index3 > (vertical2 ? cols : rows)) fail(ERR.REF);
|
|
34292
|
-
const keys = line2(ctx,
|
|
34677
|
+
const keys = line2(ctx, table4, vertical2 ? "col" : "row", 0);
|
|
34293
34678
|
const at2 = approximate2 ? findAscending(keys, lookup2) : findExact(keys, lookup2, true);
|
|
34294
34679
|
if (at2 < 0) fail(ERR.NA);
|
|
34295
|
-
return vertical2 ? cellOf(
|
|
34680
|
+
return vertical2 ? cellOf(table4, at2, index3 - 1) : cellOf(table4, index3 - 1, at2);
|
|
34296
34681
|
}
|
|
34297
34682
|
function match(args, ctx) {
|
|
34298
34683
|
const lookup2 = blankAsZero(args);
|
|
@@ -35736,10 +36121,10 @@ var REGRESSION_FUNCTIONS = [
|
|
|
35736
36121
|
const lay = logs(layout2(ctx, args));
|
|
35737
36122
|
const fit3 = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
|
|
35738
36123
|
const stats = !omitted(args, 3) && bool(args[3]);
|
|
35739
|
-
const
|
|
35740
|
-
if (!stats) return
|
|
36124
|
+
const table4 = coefficientTable(fit3, stats, Math.exp);
|
|
36125
|
+
if (!stats) return table4;
|
|
35741
36126
|
const plain5 = coefficientTable(fit3, true, (v) => v).data;
|
|
35742
|
-
return new Matrix([
|
|
36127
|
+
return new Matrix([table4.data[0] ?? [], ...plain5.slice(1)]);
|
|
35743
36128
|
},
|
|
35744
36129
|
ARGS
|
|
35745
36130
|
),
|
|
@@ -38125,7 +38510,7 @@ function headerMode(args, i2, ctx, firstRow) {
|
|
|
38125
38510
|
if (mode === 1 || mode === 3) return true;
|
|
38126
38511
|
return fail(ERR.VALUE);
|
|
38127
38512
|
}
|
|
38128
|
-
var
|
|
38513
|
+
var keyOf2 = (values2) => JSON.stringify(values2);
|
|
38129
38514
|
var plain2 = (v) => v === void 0 || isError(v) ? null : v;
|
|
38130
38515
|
function compareBy(keys, rows) {
|
|
38131
38516
|
return (a2, b) => {
|
|
@@ -38165,12 +38550,12 @@ function groupby(args, ctx) {
|
|
|
38165
38550
|
if (rows.length === 0) fail(ERR.CALC);
|
|
38166
38551
|
const groups = /* @__PURE__ */ new Map();
|
|
38167
38552
|
for (const r of rows) {
|
|
38168
|
-
const key2 =
|
|
38553
|
+
const key2 = keyOf2(keysM.data[r]);
|
|
38169
38554
|
const found = groups.get(key2);
|
|
38170
38555
|
if (found) found.push(r);
|
|
38171
38556
|
else groups.set(key2, [r]);
|
|
38172
38557
|
}
|
|
38173
|
-
const
|
|
38558
|
+
const table4 = [...groups.values()].map((members3) => {
|
|
38174
38559
|
const key2 = keysM.data[members3[0]];
|
|
38175
38560
|
const cells3 = Array.from(
|
|
38176
38561
|
{ length: vCols },
|
|
@@ -38182,8 +38567,8 @@ function groupby(args, ctx) {
|
|
|
38182
38567
|
return [...key2, ...cells3];
|
|
38183
38568
|
});
|
|
38184
38569
|
for (const key2 of sort2) if (Math.abs(key2) > kCols + vCols) fail(ERR.VALUE);
|
|
38185
|
-
const order =
|
|
38186
|
-
const out = order.map((i2) =>
|
|
38570
|
+
const order = table4.map((_, i2) => i2).sort(compareBy(sort2, table4));
|
|
38571
|
+
const out = order.map((i2) => table4[i2]);
|
|
38187
38572
|
if (depth !== 0) {
|
|
38188
38573
|
const total2 = [
|
|
38189
38574
|
"Total",
|
|
@@ -38232,8 +38617,8 @@ function pivotby(args, ctx) {
|
|
|
38232
38617
|
const colKeys = /* @__PURE__ */ new Map();
|
|
38233
38618
|
for (const r of used) {
|
|
38234
38619
|
for (const [map, key2] of [
|
|
38235
|
-
[rowKeys,
|
|
38236
|
-
[colKeys,
|
|
38620
|
+
[rowKeys, keyOf2(rowsM.data[r])],
|
|
38621
|
+
[colKeys, keyOf2(colsM.data[r])]
|
|
38237
38622
|
]) {
|
|
38238
38623
|
const found = map.get(key2);
|
|
38239
38624
|
if (found) found.push(r);
|
|
@@ -38966,8 +39351,8 @@ function resolveName(node3, frame2) {
|
|
|
38966
39351
|
const value2 = evaluateDefinedName(node3.name, sheet, node3.prefix !== void 0, frame2);
|
|
38967
39352
|
if (value2 !== void 0) return value2;
|
|
38968
39353
|
if (!node3.prefix) {
|
|
38969
|
-
const
|
|
38970
|
-
if (!(isError(
|
|
39354
|
+
const table4 = resolveStructured({ table: node3.name, specials: [] }, frame2);
|
|
39355
|
+
if (!(isError(table4) && table4.error === "#NAME?")) return table4;
|
|
38971
39356
|
}
|
|
38972
39357
|
return ERR.NAME;
|
|
38973
39358
|
}
|
|
@@ -40617,8 +41002,8 @@ function deleteSheetInFormula(formula, sheetName, tableNames = []) {
|
|
|
40617
41002
|
for (const token of tokens3) {
|
|
40618
41003
|
const prefix3 = token.prefix;
|
|
40619
41004
|
const onSheet = prefix3 !== void 0 && prefix3.book === void 0 && prefix3.sheet2 === void 0 && same5(prefix3.sheet, sheetName);
|
|
40620
|
-
const
|
|
40621
|
-
if ((token.kind === "ref" || token.kind === "name") && onSheet ||
|
|
41005
|
+
const table4 = typeof token.value === "string" && tables.has(token.value.toLowerCase()) && (token.kind === "structured" || token.kind === "name" && !prefix3);
|
|
41006
|
+
if ((token.kind === "ref" || token.kind === "name") && onSheet || table4) {
|
|
40622
41007
|
token.text = "#REF!";
|
|
40623
41008
|
changed = true;
|
|
40624
41009
|
}
|
|
@@ -40681,11 +41066,11 @@ function renameTableColumnInFormula(formula, tableName, oldName, newName, inside
|
|
|
40681
41066
|
// xlsx/formula/structured-to-a1.ts
|
|
40682
41067
|
var abs = (row3, col, rowAbs = true) => `$${columnLabel(col)}${rowAbs ? "$" : ""}${row3 + 1}`;
|
|
40683
41068
|
function a1For(ref, t) {
|
|
40684
|
-
const { table:
|
|
40685
|
-
const { start, end } =
|
|
41069
|
+
const { table: table4 } = t;
|
|
41070
|
+
const { start, end } = table4.range;
|
|
40686
41071
|
const index3 = (name3) => {
|
|
40687
41072
|
if (name3 === void 0) return void 0;
|
|
40688
|
-
const i2 =
|
|
41073
|
+
const i2 = table4.columns.findIndex((c3) => c3.name.toLowerCase() === name3.toLowerCase());
|
|
40689
41074
|
return i2 < 0 ? -1 : start.col + i2;
|
|
40690
41075
|
};
|
|
40691
41076
|
const c1 = index3(ref.column);
|
|
@@ -40693,10 +41078,10 @@ function a1For(ref, t) {
|
|
|
40693
41078
|
if (c1 === -1 || c2 === -1) return "#REF!";
|
|
40694
41079
|
const colLo = c1 ?? start.col;
|
|
40695
41080
|
const colHi = c2 ?? end.col;
|
|
40696
|
-
const headerRow =
|
|
40697
|
-
const totalsRow =
|
|
40698
|
-
const dataLo = start.row + (
|
|
40699
|
-
const dataHi = end.row - (
|
|
41081
|
+
const headerRow = table4.headerRow ? start.row : void 0;
|
|
41082
|
+
const totalsRow = table4.totalsRow ? end.row : void 0;
|
|
41083
|
+
const dataLo = start.row + (table4.headerRow ? 1 : 0);
|
|
41084
|
+
const dataHi = end.row - (table4.totalsRow ? 1 : 0);
|
|
40700
41085
|
const specials = new Set(ref.specials);
|
|
40701
41086
|
let rowLo;
|
|
40702
41087
|
let rowHi;
|
|
@@ -42129,8 +42514,8 @@ function sheetDataXml(ctx, sheet) {
|
|
|
42129
42514
|
].sort((a2, b) => a2 - b);
|
|
42130
42515
|
const spills = new SpillPlan(sheet);
|
|
42131
42516
|
const tables = /* @__PURE__ */ new Map();
|
|
42132
|
-
for (const
|
|
42133
|
-
tables.set(`${
|
|
42517
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
42518
|
+
tables.set(`${table4.ref.start.row}:${table4.ref.start.col}`, table4);
|
|
42134
42519
|
let out = "";
|
|
42135
42520
|
for (const row3 of rows) {
|
|
42136
42521
|
const cells3 = sheet.rows.get(row3);
|
|
@@ -42612,29 +42997,29 @@ function setChildText(doc, parent, local, text8, before) {
|
|
|
42612
42997
|
node3.textContent = text8;
|
|
42613
42998
|
if (!existing) insertBefore(parent, node3, before);
|
|
42614
42999
|
}
|
|
42615
|
-
function tableFilterRange(
|
|
43000
|
+
function tableFilterRange(table4) {
|
|
42616
43001
|
return {
|
|
42617
|
-
start:
|
|
42618
|
-
end: { ...
|
|
43002
|
+
start: table4.range.start,
|
|
43003
|
+
end: { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) }
|
|
42619
43004
|
};
|
|
42620
43005
|
}
|
|
42621
|
-
function sourceColumnsForPatch(root,
|
|
43006
|
+
function sourceColumnsForPatch(root, table4, names) {
|
|
42622
43007
|
const list2 = xKid(root, "tableColumns");
|
|
42623
43008
|
const source2 = list2 ? xKids(list2, "tableColumn") : [];
|
|
42624
43009
|
const byId2 = new Map(source2.map((c2) => [Number(c2.getAttribute("id")), c2]));
|
|
42625
43010
|
const byName2 = new Map(source2.map((c2) => [(c2.getAttribute("name") ?? "").toLowerCase(), c2]));
|
|
42626
|
-
const tracked =
|
|
43011
|
+
const tracked = table4.partName !== void 0 || table4.columns.some((c2) => c2.sourceId !== void 0);
|
|
42627
43012
|
const used = /* @__PURE__ */ new Set();
|
|
42628
43013
|
return names.map((name3, index3) => {
|
|
42629
|
-
const id3 =
|
|
43014
|
+
const id3 = table4.columns[index3]?.sourceId;
|
|
42630
43015
|
const match2 = id3 !== void 0 ? byId2.get(id3) : tracked ? void 0 : source2.length === names.length ? source2[index3] : byName2.get(name3.toLowerCase());
|
|
42631
43016
|
if (!match2 || used.has(match2)) return void 0;
|
|
42632
43017
|
used.add(match2);
|
|
42633
43018
|
return match2;
|
|
42634
43019
|
});
|
|
42635
43020
|
}
|
|
42636
|
-
function syncColumnFilters(doc, filter2,
|
|
42637
|
-
|
|
43021
|
+
function syncColumnFilters(doc, filter2, table4) {
|
|
43022
|
+
table4.columns.forEach((column2, index3) => {
|
|
42638
43023
|
const node3 = xKids(filter2, "filterColumn").find(
|
|
42639
43024
|
(n) => Number(n.getAttribute("colId")) === index3
|
|
42640
43025
|
);
|
|
@@ -42656,29 +43041,29 @@ function syncColumnFilters(doc, filter2, table3) {
|
|
|
42656
43041
|
}
|
|
42657
43042
|
});
|
|
42658
43043
|
}
|
|
42659
|
-
function patchAutoFilter(doc, root,
|
|
43044
|
+
function patchAutoFilter(doc, root, table4, before, names) {
|
|
42660
43045
|
const existing = xKid(root, "autoFilter");
|
|
42661
|
-
if (!
|
|
43046
|
+
if (!table4.headerRow) {
|
|
42662
43047
|
if (existing) root.removeChild(existing);
|
|
42663
43048
|
return;
|
|
42664
43049
|
}
|
|
42665
43050
|
const filter2 = existing ?? doc.createElementNS(NS.x, "autoFilter");
|
|
42666
|
-
const range2 = tableFilterRange(
|
|
43051
|
+
const range2 = tableFilterRange(table4);
|
|
42667
43052
|
filter2.setAttribute("ref", formatRange(range2));
|
|
42668
43053
|
const list2 = xKid(root, "tableColumns");
|
|
42669
43054
|
const original = list2 ? xKids(list2, "tableColumn") : [];
|
|
42670
|
-
const current = new Map(sourceColumnsForPatch(root,
|
|
43055
|
+
const current = new Map(sourceColumnsForPatch(root, table4, names).map((c2, index3) => [c2, index3]));
|
|
42671
43056
|
for (const column2 of xKids(filter2, "filterColumn")) {
|
|
42672
43057
|
const old = original[Number(column2.getAttribute("colId") ?? "0")];
|
|
42673
43058
|
const index3 = old ? current.get(old) : void 0;
|
|
42674
43059
|
if (index3 === void 0) filter2.removeChild(column2);
|
|
42675
43060
|
else column2.setAttribute("colId", num(index3));
|
|
42676
43061
|
}
|
|
42677
|
-
syncColumnFilters(doc, filter2,
|
|
43062
|
+
syncColumnFilters(doc, filter2, table4);
|
|
42678
43063
|
if (!existing) insertBefore(root, filter2, ["sortState", "tableColumns"]);
|
|
42679
43064
|
const sort2 = xKid(filter2, "sortState") ?? xKid(root, "sortState");
|
|
42680
43065
|
if (!sort2) return;
|
|
42681
|
-
const moved = before.start.row !==
|
|
43066
|
+
const moved = before.start.row !== table4.range.start.row || before.start.col !== table4.range.start.col || before.end.col !== table4.range.end.col;
|
|
42682
43067
|
if (moved) {
|
|
42683
43068
|
sort2.parentNode?.removeChild(sort2);
|
|
42684
43069
|
return;
|
|
@@ -42700,7 +43085,7 @@ function patchAutoFilter(doc, root, table3, before, names) {
|
|
|
42700
43085
|
}
|
|
42701
43086
|
}
|
|
42702
43087
|
var COLUMN_CHILD_ORDER = ["calculatedColumnFormula", "totalsRowFormula", "xmlColumnPr", "extLst"];
|
|
42703
|
-
function patchColumns(doc, root, sheet,
|
|
43088
|
+
function patchColumns(doc, root, sheet, table4, names) {
|
|
42704
43089
|
let list2 = xKid(root, "tableColumns");
|
|
42705
43090
|
if (!list2) {
|
|
42706
43091
|
list2 = doc.createElementNS(NS.x, "tableColumns");
|
|
@@ -42708,7 +43093,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42708
43093
|
}
|
|
42709
43094
|
const sourceColumns = xKids(list2, "tableColumn");
|
|
42710
43095
|
const ids = /* @__PURE__ */ new Set();
|
|
42711
|
-
const picked = sourceColumnsForPatch(root,
|
|
43096
|
+
const picked = sourceColumnsForPatch(root, table4, names).map((match2) => {
|
|
42712
43097
|
if (!match2) return void 0;
|
|
42713
43098
|
const id3 = Number(match2.getAttribute("id"));
|
|
42714
43099
|
if (Number.isInteger(id3) && id3 >= 0 && !ids.has(id3)) ids.add(id3);
|
|
@@ -42717,15 +43102,15 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42717
43102
|
});
|
|
42718
43103
|
for (const column2 of sourceColumns) list2.removeChild(column2);
|
|
42719
43104
|
let nextId3 = Math.max(0, ...ids) + 1;
|
|
42720
|
-
const totalsRow =
|
|
43105
|
+
const totalsRow = table4.range.end.row;
|
|
42721
43106
|
names.forEach((name3, index3) => {
|
|
42722
43107
|
const column2 = picked[index3] ?? doc.createElementNS(NS.x, "tableColumn");
|
|
42723
43108
|
if (!column2.getAttribute("id")) column2.setAttribute("id", num(nextId3++));
|
|
42724
43109
|
column2.setAttribute("name", name3);
|
|
42725
|
-
const model =
|
|
42726
|
-
const fn =
|
|
43110
|
+
const model = table4.columns[index3];
|
|
43111
|
+
const fn = table4.totalsRow ? model?.totalsRowFunction : void 0;
|
|
42727
43112
|
setOrRemove(column2, "totalsRowFunction", fn);
|
|
42728
|
-
setOrRemove(column2, "totalsRowLabel",
|
|
43113
|
+
setOrRemove(column2, "totalsRowLabel", table4.totalsRow ? model?.totalsRowLabel : void 0);
|
|
42729
43114
|
const calculated = model?.calculatedColumnFormula;
|
|
42730
43115
|
setChildText(
|
|
42731
43116
|
doc,
|
|
@@ -42736,7 +43121,7 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42736
43121
|
);
|
|
42737
43122
|
if (fn !== "custom") setChildText(doc, column2, "totalsRowFormula", void 0, []);
|
|
42738
43123
|
else {
|
|
42739
|
-
const cellFormula = sheet.rows.get(totalsRow)?.get(
|
|
43124
|
+
const cellFormula = sheet.rows.get(totalsRow)?.get(table4.range.start.col + index3)?.formula;
|
|
42740
43125
|
if (cellFormula)
|
|
42741
43126
|
setChildText(
|
|
42742
43127
|
doc,
|
|
@@ -42750,19 +43135,19 @@ function patchColumns(doc, root, sheet, table3, names) {
|
|
|
42750
43135
|
});
|
|
42751
43136
|
list2.setAttribute("count", num(names.length));
|
|
42752
43137
|
}
|
|
42753
|
-
function patchStyleInfo(doc, root,
|
|
43138
|
+
function patchStyleInfo(doc, root, table4) {
|
|
42754
43139
|
let info = xKid(root, "tableStyleInfo");
|
|
42755
43140
|
if (!info) {
|
|
42756
43141
|
info = doc.createElementNS(NS.x, "tableStyleInfo");
|
|
42757
43142
|
insertBefore(root, info, ["extLst"]);
|
|
42758
43143
|
}
|
|
42759
|
-
setOrRemove(info, "name",
|
|
42760
|
-
info.setAttribute("showFirstColumn", flag2(
|
|
42761
|
-
info.setAttribute("showLastColumn", flag2(
|
|
42762
|
-
info.setAttribute("showRowStripes", flag2(
|
|
42763
|
-
info.setAttribute("showColumnStripes", flag2(
|
|
43144
|
+
setOrRemove(info, "name", table4.styleName);
|
|
43145
|
+
info.setAttribute("showFirstColumn", flag2(table4.showFirstColumn, false));
|
|
43146
|
+
info.setAttribute("showLastColumn", flag2(table4.showLastColumn, false));
|
|
43147
|
+
info.setAttribute("showRowStripes", flag2(table4.showRowStripes, true));
|
|
43148
|
+
info.setAttribute("showColumnStripes", flag2(table4.showColumnStripes, false));
|
|
42764
43149
|
}
|
|
42765
|
-
function patchTableXml(sourceXml, sheet,
|
|
43150
|
+
function patchTableXml(sourceXml, sheet, table4, id3, names) {
|
|
42766
43151
|
let doc;
|
|
42767
43152
|
try {
|
|
42768
43153
|
doc = parseXml(sourceXml, { label: "XLSX table" });
|
|
@@ -42771,80 +43156,80 @@ function patchTableXml(sourceXml, sheet, table3, id3, names) {
|
|
|
42771
43156
|
}
|
|
42772
43157
|
const root = doc.documentElement;
|
|
42773
43158
|
if (root.localName !== "table") return void 0;
|
|
42774
|
-
const before = parseRange(root.getAttribute("ref") ?? "") ??
|
|
43159
|
+
const before = parseRange(root.getAttribute("ref") ?? "") ?? table4.range;
|
|
42775
43160
|
root.setAttribute("id", num(id3));
|
|
42776
|
-
root.setAttribute("name",
|
|
42777
|
-
root.setAttribute("displayName",
|
|
42778
|
-
root.setAttribute("ref", formatRange(
|
|
42779
|
-
setOrRemove(root, "headerRowCount",
|
|
42780
|
-
if (
|
|
43161
|
+
root.setAttribute("name", table4.name);
|
|
43162
|
+
root.setAttribute("displayName", table4.displayName || table4.name);
|
|
43163
|
+
root.setAttribute("ref", formatRange(table4.range));
|
|
43164
|
+
setOrRemove(root, "headerRowCount", table4.headerRow ? void 0 : "0");
|
|
43165
|
+
if (table4.totalsRow) {
|
|
42781
43166
|
root.setAttribute("totalsRowCount", "1");
|
|
42782
43167
|
root.removeAttribute("totalsRowShown");
|
|
42783
43168
|
} else {
|
|
42784
43169
|
root.removeAttribute("totalsRowCount");
|
|
42785
43170
|
if (!root.hasAttribute("totalsRowShown")) root.setAttribute("totalsRowShown", "0");
|
|
42786
43171
|
}
|
|
42787
|
-
patchAutoFilter(doc, root,
|
|
42788
|
-
patchColumns(doc, root, sheet,
|
|
42789
|
-
patchStyleInfo(doc, root,
|
|
43172
|
+
patchAutoFilter(doc, root, table4, before, names);
|
|
43173
|
+
patchColumns(doc, root, sheet, table4, names);
|
|
43174
|
+
patchStyleInfo(doc, root, table4);
|
|
42790
43175
|
return buildXml(doc);
|
|
42791
43176
|
}
|
|
42792
43177
|
|
|
42793
43178
|
// xlsx/write/tables.ts
|
|
42794
43179
|
var headerTextOf = (value2) => typeof value2 === "string" ? value2 : typeof value2 === "number" || typeof value2 === "boolean" ? String(value2).toUpperCase() : void 0;
|
|
42795
|
-
function resolveTableColumns(sheet,
|
|
43180
|
+
function resolveTableColumns(sheet, table4) {
|
|
42796
43181
|
const headerText = /* @__PURE__ */ new Map();
|
|
42797
43182
|
const used = /* @__PURE__ */ new Set();
|
|
42798
|
-
const width =
|
|
43183
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
42799
43184
|
const names = [];
|
|
42800
43185
|
for (let i2 = 0; i2 < width; i2++) {
|
|
42801
|
-
const col =
|
|
42802
|
-
const row3 =
|
|
42803
|
-
const fromCell =
|
|
42804
|
-
let name3 = (fromCell?.trim() ? fromCell : void 0) ??
|
|
43186
|
+
const col = table4.range.start.col + i2;
|
|
43187
|
+
const row3 = table4.range.start.row;
|
|
43188
|
+
const fromCell = table4.headerRow ? headerTextOf(sheet.rows.get(row3)?.get(col)?.value) : void 0;
|
|
43189
|
+
let name3 = (fromCell?.trim() ? fromCell : void 0) ?? table4.columns[i2]?.name ?? `Column${i2 + 1}`;
|
|
42805
43190
|
if (!name3.trim()) name3 = `Column${i2 + 1}`;
|
|
42806
43191
|
let unique4 = name3;
|
|
42807
43192
|
for (let n = 2; used.has(unique4.toLowerCase()); n++) unique4 = `${name3}${n}`;
|
|
42808
43193
|
used.add(unique4.toLowerCase());
|
|
42809
43194
|
names.push(unique4);
|
|
42810
43195
|
const cell = sheet.rows.get(row3)?.get(col);
|
|
42811
|
-
if (
|
|
43196
|
+
if (table4.headerRow && (typeof cell?.value !== "string" || cell.value !== unique4))
|
|
42812
43197
|
headerText.set(`${row3}:${col}`, unique4);
|
|
42813
43198
|
}
|
|
42814
43199
|
return { names, headerText };
|
|
42815
43200
|
}
|
|
42816
|
-
function tableXml(
|
|
42817
|
-
const range2 = formatRange(
|
|
42818
|
-
const filterEnd = { ...
|
|
42819
|
-
const criteria =
|
|
42820
|
-
const filterRef = formatRange({ start:
|
|
42821
|
-
const filter2 =
|
|
43201
|
+
function tableXml(table4, id3, names) {
|
|
43202
|
+
const range2 = formatRange(table4.range);
|
|
43203
|
+
const filterEnd = { ...table4.range.end, row: table4.range.end.row - (table4.totalsRow ? 1 : 0) };
|
|
43204
|
+
const criteria = table4.columns.map((column2, index3) => column2.filter ? filterColumnXml(index3, column2.filter) : "").join("");
|
|
43205
|
+
const filterRef = formatRange({ start: table4.range.start, end: filterEnd });
|
|
43206
|
+
const filter2 = table4.headerRow ? criteria ? `<autoFilter ref="${filterRef}">${criteria}</autoFilter>` : `<autoFilter ref="${filterRef}"/>` : "";
|
|
42822
43207
|
const columns = names.map((name3, index3) => {
|
|
42823
|
-
const column2 =
|
|
43208
|
+
const column2 = table4.columns[index3];
|
|
42824
43209
|
const calculated = column2?.calculatedColumnFormula ? `<calculatedColumnFormula>${escapeText3(addFuturePrefixes(column2.calculatedColumnFormula))}</calculatedColumnFormula>` : "";
|
|
42825
43210
|
const values2 = attrs2({
|
|
42826
43211
|
id: index3 + 1,
|
|
42827
43212
|
name: name3,
|
|
42828
|
-
totalsRowFunction:
|
|
42829
|
-
totalsRowLabel:
|
|
43213
|
+
totalsRowFunction: table4.totalsRow ? column2?.totalsRowFunction : void 0,
|
|
43214
|
+
totalsRowLabel: table4.totalsRow ? column2?.totalsRowLabel : void 0
|
|
42830
43215
|
});
|
|
42831
43216
|
return calculated ? `<tableColumn${values2}>${calculated}</tableColumn>` : `<tableColumn${values2}/>`;
|
|
42832
43217
|
}).join("");
|
|
42833
43218
|
const style3 = attrs2({
|
|
42834
|
-
name:
|
|
42835
|
-
showFirstColumn:
|
|
42836
|
-
showLastColumn:
|
|
42837
|
-
showRowStripes:
|
|
42838
|
-
showColumnStripes:
|
|
43219
|
+
name: table4.styleName,
|
|
43220
|
+
showFirstColumn: table4.showFirstColumn ?? false,
|
|
43221
|
+
showLastColumn: table4.showLastColumn ?? false,
|
|
43222
|
+
showRowStripes: table4.showRowStripes ?? true,
|
|
43223
|
+
showColumnStripes: table4.showColumnStripes ?? false
|
|
42839
43224
|
});
|
|
42840
43225
|
const head = attrs2({
|
|
42841
43226
|
id: id3,
|
|
42842
|
-
name:
|
|
42843
|
-
displayName:
|
|
43227
|
+
name: table4.name,
|
|
43228
|
+
displayName: table4.displayName || table4.name,
|
|
42844
43229
|
ref: range2,
|
|
42845
|
-
headerRowCount:
|
|
42846
|
-
totalsRowCount:
|
|
42847
|
-
totalsRowShown:
|
|
43230
|
+
headerRowCount: table4.headerRow ? void 0 : 0,
|
|
43231
|
+
totalsRowCount: table4.totalsRow ? 1 : void 0,
|
|
43232
|
+
totalsRowShown: table4.totalsRow ? void 0 : false
|
|
42848
43233
|
});
|
|
42849
43234
|
return `${XML_HEADER}<table xmlns="${NS.x}"${head}>${filter2}<tableColumns count="${names.length}">${columns}</tableColumns><tableStyleInfo${style3}/></table>`;
|
|
42850
43235
|
}
|
|
@@ -42858,24 +43243,24 @@ var SUBTOTAL_CODES = {
|
|
|
42858
43243
|
sum: 109,
|
|
42859
43244
|
var: 110
|
|
42860
43245
|
};
|
|
42861
|
-
function totalsRowFormulas(sheet,
|
|
43246
|
+
function totalsRowFormulas(sheet, table4, names) {
|
|
42862
43247
|
const out = /* @__PURE__ */ new Map();
|
|
42863
|
-
if (!
|
|
42864
|
-
const row3 =
|
|
43248
|
+
if (!table4.totalsRow) return out;
|
|
43249
|
+
const row3 = table4.range.end.row;
|
|
42865
43250
|
names.forEach((name3, index3) => {
|
|
42866
|
-
const code = SUBTOTAL_CODES[
|
|
43251
|
+
const code = SUBTOTAL_CODES[table4.columns[index3]?.totalsRowFunction ?? ""];
|
|
42867
43252
|
if (code === void 0) return;
|
|
42868
|
-
const col =
|
|
43253
|
+
const col = table4.range.start.col + index3;
|
|
42869
43254
|
const escaped = name3.replace(/['#[\]]/g, "'$&");
|
|
42870
|
-
const formula = `SUBTOTAL(${code},${
|
|
43255
|
+
const formula = `SUBTOTAL(${code},${table4.displayName || table4.name}[${escaped}])`;
|
|
42871
43256
|
if (sheet.rows.get(row3)?.get(col)?.formula !== formula) out.set(`${row3}:${col}`, formula);
|
|
42872
43257
|
});
|
|
42873
43258
|
return out;
|
|
42874
43259
|
}
|
|
42875
|
-
function resolveTableNames(
|
|
42876
|
-
const display =
|
|
43260
|
+
function resolveTableNames(table4, before, index3) {
|
|
43261
|
+
const display = table4.displayName || table4.name;
|
|
42877
43262
|
const displayName = before && before.displayName === display ? display : safeTableName(display, index3);
|
|
42878
|
-
const name3 = before && before.name ===
|
|
43263
|
+
const name3 = before && before.name === table4.name ? table4.name : table4.name === display ? displayName : safeTableName(table4.name, index3);
|
|
42879
43264
|
return { name: name3, displayName };
|
|
42880
43265
|
}
|
|
42881
43266
|
function safeTableName(name3, index3) {
|
|
@@ -42968,21 +43353,21 @@ function writeTables(ctx, sheet, partName, rels, headerText, formulas) {
|
|
|
42968
43353
|
const sourceXml = original.partName ? source2?.text(original.partName) : void 0;
|
|
42969
43354
|
const before = sourceXml && original.partName ? parseTable3(sourceXml, original.partName) : void 0;
|
|
42970
43355
|
const { name: name3, displayName } = resolveTableNames(original, before, index3 + 1);
|
|
42971
|
-
const
|
|
42972
|
-
const { names, headerText: forced } = resolveTableColumns(sheet,
|
|
43356
|
+
const table4 = name3 === original.name && displayName === original.displayName ? original : { ...original, name: name3, displayName };
|
|
43357
|
+
const { names, headerText: forced } = resolveTableColumns(sheet, table4);
|
|
42973
43358
|
for (const [key2, text8] of forced) headerText.set(key2, text8);
|
|
42974
|
-
const totals = totalsRowFormulas(sheet,
|
|
43359
|
+
const totals = totalsRowFormulas(sheet, table4, names);
|
|
42975
43360
|
for (const [key2, formula] of totals) formulas.set(key2, formula);
|
|
42976
|
-
let id3 =
|
|
42977
|
-
const unchanged =
|
|
43361
|
+
let id3 = table4.id;
|
|
43362
|
+
const unchanged = table4.partName && sourceXml && !writer.has(table4.partName) && !ctx.tableIds.has(id3) && forced.size === 0 && totals.size === 0 && table4 === original && sameModel(before, table4);
|
|
42978
43363
|
let part;
|
|
42979
|
-
if (unchanged &&
|
|
42980
|
-
part =
|
|
43364
|
+
if (unchanged && table4.partName) {
|
|
43365
|
+
part = table4.partName;
|
|
42981
43366
|
writer.carry(part);
|
|
42982
43367
|
} else {
|
|
42983
43368
|
while (ctx.tableIds.has(id3) || id3 < 1) id3++;
|
|
42984
|
-
part =
|
|
42985
|
-
const xml = (sourceXml && patchTableXml(sourceXml, sheet,
|
|
43369
|
+
part = table4.partName && !writer.has(table4.partName) ? table4.partName : writer.uniqueName((n) => `xl/tables/table${n}.xml`, ctx.reserved);
|
|
43370
|
+
const xml = (sourceXml && patchTableXml(sourceXml, sheet, table4, id3, names)) ?? tableXml(table4, id3, names);
|
|
42986
43371
|
writer.add(part, xml, CONTENT_TYPES.table);
|
|
42987
43372
|
}
|
|
42988
43373
|
ctx.tableIds.add(id3);
|
|
@@ -43427,13 +43812,13 @@ function derivedFieldXml(pivot, entry3, date1904) {
|
|
|
43427
43812
|
const days = dateGroupDays(entry3.group);
|
|
43428
43813
|
const labels = dateUnitLabels(entry3.unit, range2, days, date1904, entry3.group);
|
|
43429
43814
|
const base2 = pivot.fields.indexOf(entry3.group.field);
|
|
43430
|
-
return `<cacheField${attrs2({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base2}"><rangePr${attrs2({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range2.start, date1904), endDate: serialToIso(range2.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((
|
|
43815
|
+
return `<cacheField${attrs2({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base2}"><rangePr${attrs2({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range2.start, date1904), endDate: serialToIso(range2.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup></cacheField>`;
|
|
43431
43816
|
}
|
|
43432
43817
|
function groupXml2(pivot, name3, index3) {
|
|
43433
43818
|
const group = groupOf(pivot, name3);
|
|
43434
43819
|
if (!group) return "";
|
|
43435
43820
|
const labels = numberGroupLabels(group);
|
|
43436
|
-
return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((
|
|
43821
|
+
return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup>`;
|
|
43437
43822
|
}
|
|
43438
43823
|
function slicerExt(pivot) {
|
|
43439
43824
|
if (pivot.slicerCacheId === void 0) return "";
|
|
@@ -43493,6 +43878,10 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43493
43878
|
const compact3 = pivot.layout === "compact";
|
|
43494
43879
|
const outline2 = pivot.layout === "compact" || pivot.layout === "outline";
|
|
43495
43880
|
const top = (pivot.subtotalPosition ?? (outline2 ? "top" : "bottom")) === "top";
|
|
43881
|
+
const named3 = (field2, item) => {
|
|
43882
|
+
const text8 = pivotItemName(pivot, field2, item);
|
|
43883
|
+
return text8 === void 0 ? "" : attrs2({ n: encodeEscapes(text8) });
|
|
43884
|
+
};
|
|
43496
43885
|
const fields = pivot.fields.map((name3, index3) => {
|
|
43497
43886
|
const isDate = pivot.dateFields?.includes(name3) ?? false;
|
|
43498
43887
|
const at2 = rowIdx.indexOf(index3);
|
|
@@ -43507,7 +43896,7 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43507
43896
|
custom.map((fn) => [PIVOT_SUBTOTALS[fn].attr, true])
|
|
43508
43897
|
);
|
|
43509
43898
|
const entries = automatic ? '<item t="default"/>' : custom.map((fn) => `<item t="${PIVOT_SUBTOTALS[fn].item}"/>`).join("");
|
|
43510
|
-
return `<pivotField${attrs2({ axis: index3 === page ? "axisPage" : at2 >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures2.some((measure2) => pivot.fields.indexOf(measure2.field) === index3) ? true : void 0, compact: compact3, outline: outline2, showAll: false, subtotalTop: at2 >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""} x="${itemX(index3, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
|
|
43899
|
+
return `<pivotField${attrs2({ axis: index3 === page ? "axisPage" : at2 >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures2.some((measure2) => pivot.fields.indexOf(measure2.field) === index3) ? true : void 0, compact: compact3, outline: outline2, showAll: false, subtotalTop: at2 >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""}${named3(name3, item)} x="${itemX(index3, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
|
|
43511
43900
|
}).join("");
|
|
43512
43901
|
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
43513
43902
|
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
@@ -43537,6 +43926,15 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
43537
43926
|
const root = doc.documentElement;
|
|
43538
43927
|
root.setAttribute("name", pivot.name);
|
|
43539
43928
|
root.setAttribute("cacheId", String(cacheId));
|
|
43929
|
+
const caps = pivotCaptions(pivot);
|
|
43930
|
+
root.setAttribute("dataCaption", caps.values);
|
|
43931
|
+
for (const [attribute4, key2] of [
|
|
43932
|
+
["rowHeaderCaption", "rowLabels"],
|
|
43933
|
+
["colHeaderCaption", "columnLabels"],
|
|
43934
|
+
["grandTotalCaption", "grandTotal"]
|
|
43935
|
+
])
|
|
43936
|
+
if (caps[key2] !== ENGLISH_PIVOT_CAPTIONS[key2] || root.hasAttribute(attribute4))
|
|
43937
|
+
root.setAttribute(attribute4, caps[key2]);
|
|
43540
43938
|
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
43541
43939
|
if (rowsAxis && valuesAt < rowIdx.length) root.setAttribute("dataPosition", String(valuesAt));
|
|
43542
43940
|
else root.removeAttribute("dataPosition");
|
|
@@ -43660,7 +44058,7 @@ var PivotWritePlan = class {
|
|
|
43660
44058
|
this.tableParts.set(pivot, pivot.partName);
|
|
43661
44059
|
continue;
|
|
43662
44060
|
}
|
|
43663
|
-
const
|
|
44061
|
+
const table4 = pivot.partName ?? writer.uniqueName((n) => `xl/pivotTables/pivotTable${n}.xml`, reserved);
|
|
43664
44062
|
const definition = writer.uniqueName(
|
|
43665
44063
|
(n) => `xl/pivotCache/pivotCacheDefinition${n}.xml`,
|
|
43666
44064
|
reserved
|
|
@@ -43682,24 +44080,24 @@ var PivotWritePlan = class {
|
|
|
43682
44080
|
TYPES2.definition
|
|
43683
44081
|
);
|
|
43684
44082
|
writer.rels(definition, cacheRels);
|
|
43685
|
-
writer.add(
|
|
44083
|
+
writer.add(table4, pivotTableXml(pivot, cacheId, cache3), TYPES2.table);
|
|
43686
44084
|
const tableRels = new RelationshipSet();
|
|
43687
|
-
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(
|
|
43688
|
-
writer.rels(
|
|
44085
|
+
tableRels.add(RELATIONSHIP_TYPES.pivotCacheDefinition, relativeTarget(table4, definition));
|
|
44086
|
+
writer.rels(table4, tableRels);
|
|
43689
44087
|
const rid2 = bookRels.add(
|
|
43690
44088
|
RELATIONSHIP_TYPES.pivotCacheDefinition,
|
|
43691
44089
|
relativeTarget(bookPart, definition)
|
|
43692
44090
|
);
|
|
43693
44091
|
entries.push(`<pivotCache cacheId="${cacheId++}" r:id="${rid2}"/>`);
|
|
43694
|
-
this.tableParts.set(pivot,
|
|
44092
|
+
this.tableParts.set(pivot, table4);
|
|
43695
44093
|
}
|
|
43696
44094
|
this.cachesXml = owns ? entries.length ? `<pivotCaches>${entries.join("")}</pivotCaches>` : "" : void 0;
|
|
43697
44095
|
}
|
|
43698
44096
|
writeSheet(writer, sheet, part, rels) {
|
|
43699
44097
|
for (const pivot of sheet.pivotTables ?? []) {
|
|
43700
|
-
const
|
|
43701
|
-
writer.carry(
|
|
43702
|
-
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part,
|
|
44098
|
+
const table4 = this.tableParts.get(pivot);
|
|
44099
|
+
writer.carry(table4);
|
|
44100
|
+
rels.add(RELATIONSHIP_TYPES.pivotTable, relativeTarget(part, table4));
|
|
43703
44101
|
}
|
|
43704
44102
|
}
|
|
43705
44103
|
};
|
|
@@ -43869,9 +44267,9 @@ function slicerTarget(workbook, cache3) {
|
|
|
43869
44267
|
const source2 = cache3.source;
|
|
43870
44268
|
for (const [sheetIndex2, sheet] of workbook.sheets.entries()) {
|
|
43871
44269
|
if (source2.kind === "table") {
|
|
43872
|
-
const
|
|
43873
|
-
const offset2 =
|
|
43874
|
-
if (
|
|
44270
|
+
const table4 = sheet.tables.find((entry3) => entry3.id === source2.tableId);
|
|
44271
|
+
const offset2 = table4?.columns.findIndex((column2) => column2.sourceId === source2.column) ?? -1;
|
|
44272
|
+
if (table4 && offset2 >= 0) return { kind: "table", sheet, sheetIndex: sheetIndex2, table: table4, offset: offset2 };
|
|
43875
44273
|
} else {
|
|
43876
44274
|
const first3 = source2.pivots[0];
|
|
43877
44275
|
const pivot = first3 && sheet.sheetId === first3.tabId ? sheet.pivotTables?.find((entry3) => entry3.name === first3.name) : void 0;
|
|
@@ -44060,12 +44458,12 @@ function slicerCacheXml(cache3, facts) {
|
|
|
44060
44458
|
ext.setAttribute("xmlns:x15", X153);
|
|
44061
44459
|
list2.appendChild(ext);
|
|
44062
44460
|
}
|
|
44063
|
-
let
|
|
44064
|
-
if (!
|
|
44065
|
-
|
|
44066
|
-
|
|
44067
|
-
if (cache3.sortOrder === "descending")
|
|
44068
|
-
else
|
|
44461
|
+
let table4 = first(ext, "tableSlicerCache", X153);
|
|
44462
|
+
if (!table4) table4 = ext.appendChild(make2(X153, "x15:tableSlicerCache"));
|
|
44463
|
+
table4.setAttribute("tableId", String(source2.tableId));
|
|
44464
|
+
table4.setAttribute("column", String(source2.column));
|
|
44465
|
+
if (cache3.sortOrder === "descending") table4.setAttribute("sortOrder", "descending");
|
|
44466
|
+
else table4.removeAttribute("sortOrder");
|
|
44069
44467
|
return XML_HEADER + buildXml(root);
|
|
44070
44468
|
}
|
|
44071
44469
|
|
|
@@ -44618,12 +45016,12 @@ function rewriteSheetFormulas(sheet, rewrite2, formulaCells) {
|
|
|
44618
45016
|
}
|
|
44619
45017
|
{
|
|
44620
45018
|
const name3 = sheet.name;
|
|
44621
|
-
for (const
|
|
44622
|
-
for (const [index3, column2] of
|
|
45019
|
+
for (const table4 of sheet.tables)
|
|
45020
|
+
for (const [index3, column2] of table4.columns.entries())
|
|
44623
45021
|
if (column2.calculatedColumnFormula !== void 0)
|
|
44624
45022
|
column2.calculatedColumnFormula = safe(rewrite2, column2.calculatedColumnFormula, name3, {
|
|
44625
|
-
row:
|
|
44626
|
-
col:
|
|
45023
|
+
row: table4.range.start.row + (table4.headerRow ? 1 : 0),
|
|
45024
|
+
col: table4.range.start.col + index3
|
|
44627
45025
|
});
|
|
44628
45026
|
if (formulaCells) {
|
|
44629
45027
|
for (const at2 of formulaCells) {
|
|
@@ -44688,14 +45086,14 @@ function tableHeaderAt(sheet, row3, col) {
|
|
|
44688
45086
|
);
|
|
44689
45087
|
}
|
|
44690
45088
|
function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
44691
|
-
const
|
|
44692
|
-
if (!
|
|
44693
|
-
const column2 =
|
|
45089
|
+
const table4 = tableHeaderAt(sheet, row3, col);
|
|
45090
|
+
if (!table4) return;
|
|
45091
|
+
const column2 = table4.columns[col - table4.range.start.col];
|
|
44694
45092
|
if (!column2) return;
|
|
44695
45093
|
const text8 = displayText(ctx.workbook, getCell(sheet, row3, col)).trim();
|
|
44696
45094
|
if (!text8 || column2.name === text8) return;
|
|
44697
45095
|
const oldName = column2.name;
|
|
44698
|
-
const others =
|
|
45096
|
+
const others = table4.columns.filter((entry3) => entry3 !== column2).map((entry3) => entry3.name);
|
|
44699
45097
|
const newName = uniqueHeaders([...others, text8]).at(-1);
|
|
44700
45098
|
column2.name = newName;
|
|
44701
45099
|
if (newName !== text8) writeValue(sheet, row3, col, newName);
|
|
@@ -44705,10 +45103,10 @@ function syncTableHeader(ctx, sheet, row3, col, formulaCells) {
|
|
|
44705
45103
|
ctx.workbook,
|
|
44706
45104
|
(formula, formulaSheet, at2) => renameTableColumnInFormula(
|
|
44707
45105
|
formula,
|
|
44708
|
-
|
|
45106
|
+
table4.name,
|
|
44709
45107
|
oldName,
|
|
44710
45108
|
newName,
|
|
44711
|
-
formulaSheet === sheet.name && !!at2 && rangeContains(
|
|
45109
|
+
formulaSheet === sheet.name && !!at2 && rangeContains(table4.range, at2)
|
|
44712
45110
|
),
|
|
44713
45111
|
cells3
|
|
44714
45112
|
);
|
|
@@ -45832,11 +46230,11 @@ function uniqueColumnName(columns) {
|
|
|
45832
46230
|
const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
|
|
45833
46231
|
for (let n = 1; ; n++) if (!taken.has(`column${n}`)) return `Column${n}`;
|
|
45834
46232
|
}
|
|
45835
|
-
function shiftTable(sheet,
|
|
45836
|
-
const old =
|
|
46233
|
+
function shiftTable(sheet, table4, shift2, moveRange) {
|
|
46234
|
+
const old = table4.range;
|
|
45837
46235
|
const range2 = moveRange(old);
|
|
45838
46236
|
if (!range2) return [];
|
|
45839
|
-
const next = { ...
|
|
46237
|
+
const next = { ...table4, range: range2, columns: [...table4.columns] };
|
|
45840
46238
|
const widened = range2.end.col - range2.start.col !== old.end.col - old.start.col;
|
|
45841
46239
|
if (shift2.axis === "col" && widened) {
|
|
45842
46240
|
if (shift2.count > 0) {
|
|
@@ -46312,8 +46710,8 @@ function cellText(inner2) {
|
|
|
46312
46710
|
).replace(/ /g, " ").trim();
|
|
46313
46711
|
}
|
|
46314
46712
|
function parseHtmlTable(html, base2) {
|
|
46315
|
-
const
|
|
46316
|
-
if (
|
|
46713
|
+
const table4 = /<table\b[^>]*>([\s\S]*?)<\/table>/i.exec(html)?.[1];
|
|
46714
|
+
if (table4 === void 0) return void 0;
|
|
46317
46715
|
const classes = /* @__PURE__ */ new Map();
|
|
46318
46716
|
for (const block of html.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi))
|
|
46319
46717
|
for (const rule2 of removeAll(block[1] ?? "", ["<!--", "-->"]).matchAll(
|
|
@@ -46326,7 +46724,7 @@ function parseHtmlTable(html, base2) {
|
|
|
46326
46724
|
const hyperlinks = [];
|
|
46327
46725
|
let r = 0;
|
|
46328
46726
|
let spanned = 0;
|
|
46329
|
-
for (const tr of
|
|
46727
|
+
for (const tr of table4.matchAll(/<tr\b[^>]*>([\s\S]*?)(?=<tr\b|<\/tbody|<\/table|$)/gi)) {
|
|
46330
46728
|
const row3 = grid[r] ??= [];
|
|
46331
46729
|
let c2 = 0;
|
|
46332
46730
|
for (const td of (tr[1] ?? "").matchAll(
|
|
@@ -47178,9 +47576,9 @@ function filterColumn(ctx, s, col, values2) {
|
|
|
47178
47576
|
}
|
|
47179
47577
|
function sortByColumn(ctx, s, col, descending) {
|
|
47180
47578
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47181
|
-
const
|
|
47579
|
+
const table4 = sheet.tables.find((t) => col >= t.range.start.col && col <= t.range.end.col);
|
|
47182
47580
|
const filter2 = sheet.autoFilter;
|
|
47183
|
-
const target2 =
|
|
47581
|
+
const target2 = table4 ? { range: table4.range, header: table4.headerRow, totals: table4.totalsRow } : filter2 && rangeContains(filter2.range, { row: filter2.range.start.row, col }) ? { range: filter2.range, header: true, totals: false } : void 0;
|
|
47184
47582
|
if (!target2) throw new Error("The column is not inside a table or an auto-filter range.");
|
|
47185
47583
|
const range2 = target2.totals ? { start: target2.range.start, end: { ...target2.range.end, row: target2.range.end.row - 1 } } : target2.range;
|
|
47186
47584
|
ctx.run(
|
|
@@ -47240,12 +47638,12 @@ function restore(sheet, saved) {
|
|
|
47240
47638
|
Object.assign(cell, saved.fields);
|
|
47241
47639
|
}
|
|
47242
47640
|
var valueAt = (sheet, row3, col) => getCell(sheet, row3, col)?.value ?? null;
|
|
47243
|
-
function computeDataTable(workbook, calc, sheetIndex2,
|
|
47641
|
+
function computeDataTable(workbook, calc, sheetIndex2, table4) {
|
|
47244
47642
|
const sheet = sheetAt(workbook, sheetIndex2);
|
|
47245
|
-
const { ref } =
|
|
47246
|
-
const first3 = parseInputCell(sheet,
|
|
47247
|
-
const second =
|
|
47248
|
-
if (!first3 ||
|
|
47643
|
+
const { ref } = table4;
|
|
47644
|
+
const first3 = parseInputCell(sheet, table4.r1);
|
|
47645
|
+
const second = table4.dt2D && table4.r2 ? parseInputCell(sheet, table4.r2) : void 0;
|
|
47646
|
+
if (!first3 || table4.dt2D && !second || table4.del1 || table4.del2) return [];
|
|
47249
47647
|
const inputs = [first3, ...second ? [second] : []];
|
|
47250
47648
|
const saved = inputs.map((p) => save(sheet, p.row, p.col));
|
|
47251
47649
|
const top = ref.start.row - 1;
|
|
@@ -47264,11 +47662,11 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47264
47662
|
for (let row3 = ref.start.row; row3 <= ref.end.row; row3++) {
|
|
47265
47663
|
for (let col = ref.start.col; col <= ref.end.col; col++) {
|
|
47266
47664
|
let formulaAt;
|
|
47267
|
-
if (
|
|
47665
|
+
if (table4.dt2D) {
|
|
47268
47666
|
set(first3, valueAt(sheet, top, col));
|
|
47269
47667
|
if (second) set(second, valueAt(sheet, row3, left2));
|
|
47270
47668
|
formulaAt = { row: top, col: left2 };
|
|
47271
|
-
} else if (
|
|
47669
|
+
} else if (table4.dtr) {
|
|
47272
47670
|
set(first3, valueAt(sheet, top, col));
|
|
47273
47671
|
formulaAt = { row: row3, col: left2 };
|
|
47274
47672
|
} else {
|
|
@@ -47293,8 +47691,8 @@ function computeDataTable(workbook, calc, sheetIndex2, table3) {
|
|
|
47293
47691
|
function refreshDataTables(workbook, calc) {
|
|
47294
47692
|
const changed = [];
|
|
47295
47693
|
workbook.sheets.forEach((sheet, index3) => {
|
|
47296
|
-
for (const
|
|
47297
|
-
changed.push(...computeDataTable(workbook, calc, index3,
|
|
47694
|
+
for (const table4 of sheet.dataTables ?? [])
|
|
47695
|
+
changed.push(...computeDataTable(workbook, calc, index3, table4));
|
|
47298
47696
|
});
|
|
47299
47697
|
if (changed.length) calc.recalculateFrom(changed);
|
|
47300
47698
|
}
|
|
@@ -47317,23 +47715,23 @@ function resolve2(sheet, request) {
|
|
|
47317
47715
|
const ref = cellRange(range2.start.row + 1, range2.start.col + 1, range2.end.row, range2.end.col);
|
|
47318
47716
|
if ([row3, col].some((p) => p && rangeContains(ref, p))) return { problem: "input-inside" };
|
|
47319
47717
|
const name3 = (p) => formatAddress(p);
|
|
47320
|
-
const
|
|
47718
|
+
const table4 = { ref, r1: "" };
|
|
47321
47719
|
if (row3 && col) {
|
|
47322
|
-
|
|
47323
|
-
|
|
47324
|
-
|
|
47325
|
-
|
|
47720
|
+
table4.dt2D = true;
|
|
47721
|
+
table4.dtr = true;
|
|
47722
|
+
table4.r1 = name3(row3);
|
|
47723
|
+
table4.r2 = name3(col);
|
|
47326
47724
|
} else if (row3) {
|
|
47327
|
-
|
|
47328
|
-
|
|
47329
|
-
} else if (col)
|
|
47330
|
-
return { table:
|
|
47725
|
+
table4.dtr = true;
|
|
47726
|
+
table4.r1 = name3(row3);
|
|
47727
|
+
} else if (col) table4.r1 = name3(col);
|
|
47728
|
+
return { table: table4 };
|
|
47331
47729
|
}
|
|
47332
47730
|
function createDataTable(ctx, s, request) {
|
|
47333
47731
|
const sheet = sheetAt(ctx.workbook, s);
|
|
47334
47732
|
const result2 = resolve2(sheet, request);
|
|
47335
47733
|
if ("problem" in result2) throw new Error(MESSAGES[result2.problem]);
|
|
47336
|
-
const { table:
|
|
47734
|
+
const { table: table4 } = result2;
|
|
47337
47735
|
const range2 = normalizeRange(request.range);
|
|
47338
47736
|
ctx.run(
|
|
47339
47737
|
"Data Table",
|
|
@@ -47344,16 +47742,16 @@ function createDataTable(ctx, s, request) {
|
|
|
47344
47742
|
],
|
|
47345
47743
|
() => {
|
|
47346
47744
|
sheet.dataTables = (sheet.dataTables ?? []).filter((t) => !rangesIntersect(t.ref, range2));
|
|
47347
|
-
sheet.dataTables.push(
|
|
47348
|
-
for (let row3 =
|
|
47349
|
-
for (let col =
|
|
47745
|
+
sheet.dataTables.push(table4);
|
|
47746
|
+
for (let row3 = table4.ref.start.row; row3 <= table4.ref.end.row; row3++)
|
|
47747
|
+
for (let col = table4.ref.start.col; col <= table4.ref.end.col; col++) {
|
|
47350
47748
|
const cell = ensureCell(sheet, row3, col);
|
|
47351
47749
|
delete cell.formula;
|
|
47352
47750
|
delete cell.arrayRange;
|
|
47353
47751
|
delete cell.legacyFormula;
|
|
47354
47752
|
delete cell.dynamicArray;
|
|
47355
47753
|
}
|
|
47356
|
-
computeDataTable(ctx.workbook, ctx.calc, s,
|
|
47754
|
+
computeDataTable(ctx.workbook, ctx.calc, s, table4);
|
|
47357
47755
|
},
|
|
47358
47756
|
{ sheet: s, ranges: [range2] }
|
|
47359
47757
|
);
|
|
@@ -48670,7 +49068,7 @@ function plan(ctx, s, pivot, old) {
|
|
|
48670
49068
|
if (![start.row, start.col].every(Number.isInteger) || start.row < 0 || start.col < 0 || location.end.row > MAX_ROW || location.end.col > MAX_COL)
|
|
48671
49069
|
throw new Error("The PivotTable result does not fit on the worksheet.");
|
|
48672
49070
|
const source2 = sparklineDataRange(ctx.workbook, s, pivot.source);
|
|
48673
|
-
if (source2.sheet === s && rangesIntersect(source2.range, location) || sheet.merges.some((range2) => rangesIntersect(range2, location)) || sheet.tables.some((
|
|
49071
|
+
if (source2.sheet === s && rangesIntersect(source2.range, location) || sheet.merges.some((range2) => rangesIntersect(range2, location)) || sheet.tables.some((table4) => rangesIntersect(table4.range, location)) || sheet.pivotTables?.some((other) => other !== old && rangesIntersect(other.location, location)))
|
|
48674
49072
|
throw new Error("The PivotTable would overlap source data, another table or merged cells.");
|
|
48675
49073
|
let occupied = false;
|
|
48676
49074
|
forEachCellInRange(sheet, location, (cell, row3, col) => {
|
|
@@ -48680,12 +49078,12 @@ function plan(ctx, s, pivot, old) {
|
|
|
48680
49078
|
if (occupied) throw new Error("The PivotTable would overwrite existing cell content.");
|
|
48681
49079
|
return { grid, location };
|
|
48682
49080
|
}
|
|
48683
|
-
function writePivot(ctx, s, pivot, old,
|
|
49081
|
+
function writePivot(ctx, s, pivot, old, label2, inside2) {
|
|
48684
49082
|
const sheet = sheetAt(ctx.workbook, s);
|
|
48685
49083
|
const { grid, location } = plan(ctx, s, pivot, old);
|
|
48686
49084
|
const ranges = [...old ? [old.location] : [], location];
|
|
48687
49085
|
ctx.run(
|
|
48688
|
-
|
|
49086
|
+
label2 ?? (old ? "Refresh PivotTable" : "Create PivotTable"),
|
|
48689
49087
|
"annotations",
|
|
48690
49088
|
[
|
|
48691
49089
|
{ kind: "parts", sheet: s, parts: ["pivotTables"] },
|
|
@@ -48742,8 +49140,10 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
48742
49140
|
const name3 = options.name ?? uniqueName(ctx);
|
|
48743
49141
|
checkName2(ctx, name3);
|
|
48744
49142
|
const aggregate2 = options.aggregate ?? "sum";
|
|
49143
|
+
const captions = authoredCaptions(options);
|
|
48745
49144
|
const pivot = {
|
|
48746
49145
|
...data,
|
|
49146
|
+
...captions ? { captions } : {},
|
|
48747
49147
|
name: name3,
|
|
48748
49148
|
rowField: options.rowField,
|
|
48749
49149
|
layout: options.layout ?? "tabular",
|
|
@@ -48757,12 +49157,12 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
48757
49157
|
...options.repeatLabels !== void 0 ? { repeatLabels: options.repeatLabels } : {},
|
|
48758
49158
|
valueField: options.valueField,
|
|
48759
49159
|
aggregate: aggregate2,
|
|
48760
|
-
valueCaption: pivotCaption(aggregate2, options.valueField),
|
|
49160
|
+
valueCaption: pivotCaption(aggregate2, options.valueField, { captions }),
|
|
48761
49161
|
...options.pageFilter !== void 0 ? { pageFilter: structuredClone(options.pageFilter) } : {},
|
|
48762
49162
|
...options.fieldGroups?.length ? { fieldGroups: structuredClone(options.fieldGroups) } : {},
|
|
48763
49163
|
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
48764
49164
|
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
48765
|
-
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
49165
|
+
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues, { captions }) } : {},
|
|
48766
49166
|
location: { start: { ...destination }, end: { ...destination } },
|
|
48767
49167
|
...options.columnField ? { columnField: options.columnField } : {},
|
|
48768
49168
|
...options.columnField && options.moreColumnFields?.length ? { moreColumnFields: [...options.moreColumnFields] } : {}
|
|
@@ -48785,7 +49185,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
48785
49185
|
rowField: patch2.rowField ?? old.rowField,
|
|
48786
49186
|
valueField,
|
|
48787
49187
|
aggregate: aggregate2,
|
|
48788
|
-
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField)
|
|
49188
|
+
valueCaption: aggregate2 === old.aggregate && valueField === old.valueField ? old.valueCaption : pivotCaption(aggregate2, valueField, old)
|
|
48789
49189
|
};
|
|
48790
49190
|
if (patch2.columnField !== void 0) {
|
|
48791
49191
|
if (patch2.columnField) next.columnField = patch2.columnField;
|
|
@@ -48835,7 +49235,7 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
48835
49235
|
else if (patch2.valuesAxis === "columns" || patch2.secondRowField === "")
|
|
48836
49236
|
delete next.valuesPosition;
|
|
48837
49237
|
if (patch2.additionalValues !== void 0) {
|
|
48838
|
-
const measures2 = normalizedPivotMeasures(patch2.additionalValues);
|
|
49238
|
+
const measures2 = normalizedPivotMeasures(patch2.additionalValues, old);
|
|
48839
49239
|
if (measures2.length) next.additionalValues = measures2;
|
|
48840
49240
|
else delete next.additionalValues;
|
|
48841
49241
|
}
|
|
@@ -49305,10 +49705,10 @@ function validatePatch(group, patch2) {
|
|
|
49305
49705
|
delete next.manualMax;
|
|
49306
49706
|
validateSettings(next);
|
|
49307
49707
|
}
|
|
49308
|
-
function save2(ctx, s, next,
|
|
49708
|
+
function save2(ctx, s, next, label2, ranges) {
|
|
49309
49709
|
const sheet = sheetAt(ctx.workbook, s);
|
|
49310
49710
|
ctx.run(
|
|
49311
|
-
|
|
49711
|
+
label2,
|
|
49312
49712
|
"annotations",
|
|
49313
49713
|
[{ kind: "parts", sheet: s, parts: ["preserved"] }],
|
|
49314
49714
|
() => sheet.preserved.set("extLst", next),
|
|
@@ -49426,20 +49826,20 @@ function setSlicerSelection(ctx, cacheName, keys) {
|
|
|
49426
49826
|
const target2 = slicerTarget(ctx.workbook, cache3);
|
|
49427
49827
|
if (!target2) throw new Error("The slicer has no data source.");
|
|
49428
49828
|
if (target2.kind === "table") {
|
|
49429
|
-
const { sheet, table:
|
|
49829
|
+
const { sheet, table: table4, offset: offset2 } = target2;
|
|
49430
49830
|
ctx.run(
|
|
49431
49831
|
keys === null ? "Clear slicer filter" : "Filter slicer",
|
|
49432
49832
|
"view",
|
|
49433
49833
|
[{ kind: "sheet", sheet: target2.sheetIndex }],
|
|
49434
49834
|
() => {
|
|
49435
|
-
const column2 =
|
|
49835
|
+
const column2 = table4.columns[offset2];
|
|
49436
49836
|
if (keys === null) delete column2.filter;
|
|
49437
49837
|
else
|
|
49438
49838
|
column2.filter = {
|
|
49439
49839
|
values: keys.filter((key2) => key2 !== ""),
|
|
49440
49840
|
...keys.includes("") ? { blank: true } : {}
|
|
49441
49841
|
};
|
|
49442
|
-
applyTableFilter(ctx.workbook, sheet,
|
|
49842
|
+
applyTableFilter(ctx.workbook, sheet, table4);
|
|
49443
49843
|
},
|
|
49444
49844
|
{ sheet: target2.sheetIndex, structural: true }
|
|
49445
49845
|
);
|
|
@@ -49510,17 +49910,17 @@ function unique2(base2, taken) {
|
|
|
49510
49910
|
function insertSlicer(ctx, s, ref) {
|
|
49511
49911
|
const { workbook } = ctx;
|
|
49512
49912
|
const sheet = sheetAt(workbook, s);
|
|
49513
|
-
let
|
|
49913
|
+
let table4;
|
|
49514
49914
|
let pivot;
|
|
49515
49915
|
let field2;
|
|
49516
49916
|
if (ref.kind === "table") {
|
|
49517
|
-
|
|
49917
|
+
table4 = sheet.tables.find(
|
|
49518
49918
|
(entry3) => entry3.name === ref.table || entry3.displayName === ref.table
|
|
49519
49919
|
);
|
|
49520
|
-
if (!
|
|
49920
|
+
if (!table4?.headerRow || table4.filterNotModeled)
|
|
49521
49921
|
throw new Error("Choose a table with a header row and value filters.");
|
|
49522
49922
|
field2 = ref.column;
|
|
49523
|
-
if (!
|
|
49923
|
+
if (!table4.columns.some((column2) => column2.name === field2))
|
|
49524
49924
|
throw new Error("Choose a column of the table.");
|
|
49525
49925
|
} else {
|
|
49526
49926
|
pivot = sheet.pivotTables?.find((entry3) => entry3.name === ref.pivot);
|
|
@@ -49540,7 +49940,7 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49540
49940
|
(c2) => names.has(c2.toLowerCase())
|
|
49541
49941
|
).replace(/ /g, "_");
|
|
49542
49942
|
const metrics = createGridMetrics(sheet, { zoom: 100 });
|
|
49543
|
-
const anchorCell =
|
|
49943
|
+
const anchorCell = table4 ? { row: table4.range.start.row, col: table4.range.end.col + 2 } : { row: pivot.location.start.row, col: pivot.location.end.col + 2 };
|
|
49544
49944
|
const x = Math.max(metrics.colLeft(anchorCell.col), frameBounds(sheet) + 10);
|
|
49545
49945
|
const box5 = { x, y: metrics.rowTop(anchorCell.row), ...SLICER_BOX };
|
|
49546
49946
|
const anchor = pixelBoxToAnchor(sheet, box5, metrics, "twoCell");
|
|
@@ -49557,13 +49957,13 @@ function insertSlicer(ctx, s, ref) {
|
|
|
49557
49957
|
() => {
|
|
49558
49958
|
const book = cloneBook(workbook);
|
|
49559
49959
|
let source2;
|
|
49560
|
-
if (
|
|
49561
|
-
if (
|
|
49562
|
-
|
|
49960
|
+
if (table4) {
|
|
49961
|
+
if (table4.columns.some((column2) => column2.sourceId === void 0))
|
|
49962
|
+
table4.columns.forEach((column2, index3) => column2.sourceId ??= index3 + 1);
|
|
49563
49963
|
source2 = {
|
|
49564
49964
|
kind: "table",
|
|
49565
|
-
tableId:
|
|
49566
|
-
column:
|
|
49965
|
+
tableId: table4.id,
|
|
49966
|
+
column: table4.columns.find((column2) => column2.name === field2).sourceId
|
|
49567
49967
|
};
|
|
49568
49968
|
} else {
|
|
49569
49969
|
const target2 = pivot;
|
|
@@ -50049,9 +50449,9 @@ var SUBTOTAL = {
|
|
|
50049
50449
|
var: 110
|
|
50050
50450
|
};
|
|
50051
50451
|
var escapeColumn = (name3) => name3.replace(/['#[\]]/g, "'$&");
|
|
50052
|
-
function applyTotalsRow(sheet,
|
|
50053
|
-
const row3 =
|
|
50054
|
-
const { columns } =
|
|
50452
|
+
function applyTotalsRow(sheet, table4) {
|
|
50453
|
+
const row3 = table4.range.end.row;
|
|
50454
|
+
const { columns } = table4;
|
|
50055
50455
|
if (!columns.some((c2) => c2.totalsRowFunction || c2.totalsRowLabel)) {
|
|
50056
50456
|
const first3 = columns[0];
|
|
50057
50457
|
const last = columns[columns.length - 1];
|
|
@@ -50059,12 +50459,12 @@ function applyTotalsRow(sheet, table3) {
|
|
|
50059
50459
|
if (last) last.totalsRowFunction = "sum";
|
|
50060
50460
|
}
|
|
50061
50461
|
columns.forEach((column2, i2) => {
|
|
50062
|
-
const col =
|
|
50462
|
+
const col = table4.range.start.col + i2;
|
|
50063
50463
|
const code = SUBTOTAL[column2.totalsRowFunction ?? ""];
|
|
50064
50464
|
if (code !== void 0) {
|
|
50065
50465
|
const cell = ensureCell(sheet, row3, col);
|
|
50066
50466
|
clearContents(cell);
|
|
50067
|
-
cell.formula = `SUBTOTAL(${code},${
|
|
50467
|
+
cell.formula = `SUBTOTAL(${code},${table4.name}[${escapeColumn(column2.name)}])`;
|
|
50068
50468
|
} else if (column2.totalsRowLabel && column2.totalsRowFunction !== "custom")
|
|
50069
50469
|
writeValue(sheet, row3, col, column2.totalsRowLabel);
|
|
50070
50470
|
});
|
|
@@ -50088,8 +50488,8 @@ function validateTableName(workbook, name3, self) {
|
|
|
50088
50488
|
) || workbook.definedNames.some((n) => n.name.toLowerCase() === lower3);
|
|
50089
50489
|
return taken ? "That name is already used by another table or name." : void 0;
|
|
50090
50490
|
}
|
|
50091
|
-
function renameTableIn(workbook,
|
|
50092
|
-
const old =
|
|
50491
|
+
function renameTableIn(workbook, table4, name3) {
|
|
50492
|
+
const old = table4.name;
|
|
50093
50493
|
if (old === name3) return;
|
|
50094
50494
|
const rename = (f6) => renameTableInFormula(f6, old, name3);
|
|
50095
50495
|
rewriteFormulas(workbook, rename);
|
|
@@ -50098,73 +50498,73 @@ function renameTableIn(workbook, table3, name3) {
|
|
|
50098
50498
|
for (const column2 of t.columns)
|
|
50099
50499
|
if (column2.calculatedColumnFormula)
|
|
50100
50500
|
column2.calculatedColumnFormula = rename(column2.calculatedColumnFormula);
|
|
50101
|
-
|
|
50102
|
-
|
|
50501
|
+
table4.name = name3;
|
|
50502
|
+
table4.displayName = name3;
|
|
50103
50503
|
}
|
|
50104
50504
|
var byId = (sheet, id3) => {
|
|
50105
|
-
const
|
|
50106
|
-
if (!
|
|
50107
|
-
return
|
|
50505
|
+
const table4 = sheet.tables.find((t) => t.id === id3);
|
|
50506
|
+
if (!table4) throw new Error("The table disappeared during the edit.");
|
|
50507
|
+
return table4;
|
|
50108
50508
|
};
|
|
50109
|
-
function insertBandRow(workbook, sheet,
|
|
50509
|
+
function insertBandRow(workbook, sheet, table4, row3) {
|
|
50110
50510
|
const shift2 = { axis: "row", at: row3, count: 1 };
|
|
50111
|
-
const band2 = { lo:
|
|
50511
|
+
const band2 = { lo: table4.range.start.col, hi: table4.range.end.col };
|
|
50112
50512
|
assertInsertFits(sheet, shift2, band2);
|
|
50113
50513
|
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band2));
|
|
50114
50514
|
shiftSheetContent(sheet, shift2, band2);
|
|
50115
50515
|
}
|
|
50116
50516
|
function setHeaderRow(workbook, sheet, id3, on) {
|
|
50117
|
-
let
|
|
50118
|
-
if (
|
|
50119
|
-
const { start, end } =
|
|
50517
|
+
let table4 = byId(sheet, id3);
|
|
50518
|
+
if (table4.headerRow === on) return;
|
|
50519
|
+
const { start, end } = table4.range;
|
|
50120
50520
|
if (!on) {
|
|
50121
50521
|
if (start.row === end.row) throw new Error("A table needs at least one row.");
|
|
50122
50522
|
clearRow(sheet, start.row, start.col, end.col);
|
|
50123
|
-
|
|
50124
|
-
|
|
50523
|
+
table4.range = { start: { row: start.row + 1, col: start.col }, end };
|
|
50524
|
+
table4.headerRow = false;
|
|
50125
50525
|
return;
|
|
50126
50526
|
}
|
|
50127
50527
|
if (start.row === 0 || !rowIsEmpty(sheet, start.row - 1, start.col, end.col)) {
|
|
50128
|
-
insertBandRow(workbook, sheet,
|
|
50129
|
-
|
|
50130
|
-
}
|
|
50131
|
-
const top =
|
|
50132
|
-
const left2 =
|
|
50133
|
-
|
|
50134
|
-
|
|
50135
|
-
uniqueHeaders(
|
|
50136
|
-
const column2 =
|
|
50528
|
+
insertBandRow(workbook, sheet, table4, start.row);
|
|
50529
|
+
table4 = byId(sheet, id3);
|
|
50530
|
+
}
|
|
50531
|
+
const top = table4.range.start.row - 1;
|
|
50532
|
+
const left2 = table4.range.start.col;
|
|
50533
|
+
table4.range = { start: { row: top, col: left2 }, end: table4.range.end };
|
|
50534
|
+
table4.headerRow = true;
|
|
50535
|
+
uniqueHeaders(table4.columns.map((c2) => c2.name)).forEach((name3, i2) => {
|
|
50536
|
+
const column2 = table4.columns[i2];
|
|
50137
50537
|
if (column2) column2.name = name3;
|
|
50138
50538
|
writeValue(sheet, top, left2 + i2, name3);
|
|
50139
50539
|
});
|
|
50140
50540
|
}
|
|
50141
50541
|
function setTotalsRow(workbook, sheet, id3, on) {
|
|
50142
|
-
let
|
|
50143
|
-
if (
|
|
50144
|
-
const { start, end } =
|
|
50542
|
+
let table4 = byId(sheet, id3);
|
|
50543
|
+
if (table4.totalsRow === on) return;
|
|
50544
|
+
const { start, end } = table4.range;
|
|
50145
50545
|
if (!on) {
|
|
50146
50546
|
clearRow(sheet, end.row, start.col, end.col);
|
|
50147
|
-
|
|
50148
|
-
|
|
50547
|
+
table4.range = { start, end: { row: end.row - 1, col: end.col } };
|
|
50548
|
+
table4.totalsRow = false;
|
|
50149
50549
|
return;
|
|
50150
50550
|
}
|
|
50151
50551
|
if (end.row === MAX_ROW) throw new RangeError("The insert area extends beyond the sheet.");
|
|
50152
50552
|
if (!rowIsEmpty(sheet, end.row + 1, start.col, end.col)) {
|
|
50153
|
-
insertBandRow(workbook, sheet,
|
|
50154
|
-
|
|
50553
|
+
insertBandRow(workbook, sheet, table4, end.row + 1);
|
|
50554
|
+
table4 = byId(sheet, id3);
|
|
50155
50555
|
}
|
|
50156
|
-
|
|
50157
|
-
|
|
50158
|
-
applyTotalsRow(sheet,
|
|
50556
|
+
table4.range = { start: table4.range.start, end: { row: table4.range.end.row + 1, col: end.col } };
|
|
50557
|
+
table4.totalsRow = true;
|
|
50558
|
+
applyTotalsRow(sheet, table4);
|
|
50159
50559
|
}
|
|
50160
|
-
function resizedColumns(workbook, sheet,
|
|
50560
|
+
function resizedColumns(workbook, sheet, table4, range2) {
|
|
50161
50561
|
const width = range2.end.col - range2.start.col + 1;
|
|
50162
|
-
const oldAt = (col) => col >=
|
|
50562
|
+
const oldAt = (col) => col >= table4.range.start.col && col <= table4.range.end.col ? table4.columns[col - table4.range.start.col] : void 0;
|
|
50163
50563
|
const texts = Array.from({ length: width }, (_v, i2) => {
|
|
50164
50564
|
const col = range2.start.col + i2;
|
|
50165
50565
|
const old = oldAt(col);
|
|
50166
50566
|
if (old) return old.name;
|
|
50167
|
-
return
|
|
50567
|
+
return table4.headerRow ? displayText(workbook, getCell(sheet, range2.start.row, col)) : "";
|
|
50168
50568
|
});
|
|
50169
50569
|
return uniqueHeaders(texts).map((name3, i2) => {
|
|
50170
50570
|
const old = oldAt(range2.start.col + i2);
|
|
@@ -50172,30 +50572,30 @@ function resizedColumns(workbook, sheet, table3, range2) {
|
|
|
50172
50572
|
});
|
|
50173
50573
|
}
|
|
50174
50574
|
function resizeTableIn(workbook, sheet, id3, range2) {
|
|
50175
|
-
const
|
|
50575
|
+
const table4 = byId(sheet, id3);
|
|
50176
50576
|
const r = normalizeRange(range2);
|
|
50177
|
-
if (
|
|
50577
|
+
if (table4.headerRow && r.start.row !== table4.range.start.row)
|
|
50178
50578
|
throw new Error("The table headers must remain in the same row.");
|
|
50179
|
-
if (!rangesIntersect(r,
|
|
50180
|
-
if (r.end.row - r.start.row + 1 < (
|
|
50579
|
+
if (!rangesIntersect(r, table4.range)) throw new Error("The new range must overlap the table.");
|
|
50580
|
+
if (r.end.row - r.start.row + 1 < (table4.headerRow ? 2 : 1) + (table4.totalsRow ? 1 : 0))
|
|
50181
50581
|
throw new Error("The table range is too small.");
|
|
50182
|
-
if (sheet.tables.some((t) => t !==
|
|
50582
|
+
if (sheet.tables.some((t) => t !== table4 && rangesIntersect(t.range, r)))
|
|
50183
50583
|
throw new Error("A table cannot overlap another table.");
|
|
50184
50584
|
if (sheet.pivotTables?.some((pivot) => rangesIntersect(pivot.location, r)))
|
|
50185
50585
|
throw new Error("A table cannot overlap a PivotTable.");
|
|
50186
50586
|
if (sheet.merges.some((m) => rangesIntersect(m, r)))
|
|
50187
50587
|
throw new Error("A table cannot contain merged cells.");
|
|
50188
|
-
const oldEnd =
|
|
50189
|
-
|
|
50190
|
-
|
|
50191
|
-
if (
|
|
50192
|
-
|
|
50588
|
+
const oldEnd = table4.range.end.row;
|
|
50589
|
+
table4.columns = resizedColumns(workbook, sheet, table4, r);
|
|
50590
|
+
table4.range = r;
|
|
50591
|
+
if (table4.headerRow)
|
|
50592
|
+
table4.columns.forEach((column2, i2) => {
|
|
50193
50593
|
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
50194
50594
|
if (cell?.value !== column2.name) writeValue(sheet, r.start.row, r.start.col + i2, column2.name);
|
|
50195
50595
|
});
|
|
50196
|
-
if (
|
|
50596
|
+
if (table4.totalsRow) {
|
|
50197
50597
|
if (oldEnd !== r.end.row) clearRow(sheet, oldEnd, r.start.col, r.end.col);
|
|
50198
|
-
applyTotalsRow(sheet,
|
|
50598
|
+
applyTotalsRow(sheet, table4);
|
|
50199
50599
|
}
|
|
50200
50600
|
}
|
|
50201
50601
|
var STYLE_KEYS = [
|
|
@@ -50223,20 +50623,20 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50223
50623
|
"structure",
|
|
50224
50624
|
[scope],
|
|
50225
50625
|
() => {
|
|
50226
|
-
const
|
|
50227
|
-
if (renaming) renameTableIn(workbook,
|
|
50626
|
+
const table4 = byId(sheet, id3);
|
|
50627
|
+
if (renaming) renameTableIn(workbook, table4, name3);
|
|
50228
50628
|
for (const key2 of STYLE_KEYS) {
|
|
50229
50629
|
if (!(key2 in patch2)) continue;
|
|
50230
50630
|
const value2 = patch2[key2];
|
|
50231
|
-
if (value2 === void 0) delete
|
|
50232
|
-
else
|
|
50631
|
+
if (value2 === void 0) delete table4[key2];
|
|
50632
|
+
else table4[key2] = value2;
|
|
50233
50633
|
}
|
|
50234
50634
|
if (patch2.columns) {
|
|
50235
|
-
const width =
|
|
50635
|
+
const width = table4.range.end.col - table4.range.start.col + 1;
|
|
50236
50636
|
if (patch2.columns.length !== width) throw new Error("Give one column per table column.");
|
|
50237
|
-
const before =
|
|
50238
|
-
|
|
50239
|
-
for (const [index3, column2] of
|
|
50637
|
+
const before = table4.columns;
|
|
50638
|
+
table4.columns = structuredClone(patch2.columns);
|
|
50639
|
+
for (const [index3, column2] of table4.columns.entries()) {
|
|
50240
50640
|
const sourceId = before[index3]?.sourceId;
|
|
50241
50641
|
if (column2.sourceId === void 0 && sourceId !== void 0) column2.sourceId = sourceId;
|
|
50242
50642
|
const filter2 = before[index3]?.filter;
|
|
@@ -50245,7 +50645,7 @@ function updateTable(ctx, s, ref, patch2) {
|
|
|
50245
50645
|
}
|
|
50246
50646
|
if (patch2.headerRow !== void 0) setHeaderRow(workbook, sheet, id3, patch2.headerRow);
|
|
50247
50647
|
if (patch2.totalsRow !== void 0) setTotalsRow(workbook, sheet, id3, patch2.totalsRow);
|
|
50248
|
-
else if (patch2.columns &&
|
|
50648
|
+
else if (patch2.columns && table4.totalsRow) applyTotalsRow(sheet, byId(sheet, id3));
|
|
50249
50649
|
if (patch2.range) resizeTableIn(workbook, sheet, id3, patch2.range);
|
|
50250
50650
|
},
|
|
50251
50651
|
{ sheet: s, ranges: [current.range], structural: true }
|
|
@@ -50265,13 +50665,13 @@ function resizeTable(ctx, s, ref, range2) {
|
|
|
50265
50665
|
function convertTableToRange(ctx, s, ref) {
|
|
50266
50666
|
const { workbook } = ctx;
|
|
50267
50667
|
const sheet = sheetAt(workbook, s);
|
|
50268
|
-
const
|
|
50668
|
+
const table4 = sheet.tables[tableIndex(sheet, ref)];
|
|
50269
50669
|
ctx.run(
|
|
50270
50670
|
"Convert to range",
|
|
50271
50671
|
"structure",
|
|
50272
50672
|
[{ kind: "workbook" }],
|
|
50273
50673
|
() => {
|
|
50274
|
-
const live2 = byId(sheet,
|
|
50674
|
+
const live2 = byId(sheet, table4.id);
|
|
50275
50675
|
const base2 = { table: live2, tableSheet: sheet.name };
|
|
50276
50676
|
const { start, end } = live2.range;
|
|
50277
50677
|
for (const ws of workbook.sheets)
|
|
@@ -50296,7 +50696,7 @@ function convertTableToRange(ctx, s, ref) {
|
|
|
50296
50696
|
});
|
|
50297
50697
|
sheet.tables = sheet.tables.filter((t) => t.id !== live2.id);
|
|
50298
50698
|
},
|
|
50299
|
-
{ sheet: s, ranges: [
|
|
50699
|
+
{ sheet: s, ranges: [table4.range], structural: true }
|
|
50300
50700
|
);
|
|
50301
50701
|
}
|
|
50302
50702
|
|
|
@@ -53202,7 +53602,7 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53202
53602
|
});
|
|
53203
53603
|
const name3 = nextTableName(workbook);
|
|
53204
53604
|
const id3 = Math.max(0, ...workbook.sheets.flatMap((ws) => ws.tables.map((t) => t.id))) + 1;
|
|
53205
|
-
const
|
|
53605
|
+
const table4 = {
|
|
53206
53606
|
id: id3,
|
|
53207
53607
|
name: name3,
|
|
53208
53608
|
displayName: name3,
|
|
@@ -53216,8 +53616,8 @@ function createTable2(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2"
|
|
|
53216
53616
|
showFirstColumn: false,
|
|
53217
53617
|
showLastColumn: false
|
|
53218
53618
|
};
|
|
53219
|
-
sheet.tables.push(
|
|
53220
|
-
return
|
|
53619
|
+
sheet.tables.push(table4);
|
|
53620
|
+
return table4;
|
|
53221
53621
|
},
|
|
53222
53622
|
{ sheet: s, ranges: [r], structural: !hasHeader }
|
|
53223
53623
|
);
|
|
@@ -53421,8 +53821,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
53421
53821
|
if (!workbook.warnings.includes(message)) workbook.warnings.push(message);
|
|
53422
53822
|
}
|
|
53423
53823
|
};
|
|
53424
|
-
const begin = (
|
|
53425
|
-
const step2 = { label:
|
|
53824
|
+
const begin = (label2, kind, info) => {
|
|
53825
|
+
const step2 = { label: label2, entries: [], structural: info.structural ?? false };
|
|
53426
53826
|
if (info.calc) step2.calc = info.calc;
|
|
53427
53827
|
return { step: step2, kind, sheet: info.sheet, ranges: [...info.ranges ?? []] };
|
|
53428
53828
|
};
|
|
@@ -53446,7 +53846,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53446
53846
|
}
|
|
53447
53847
|
current.step.entries.length = from;
|
|
53448
53848
|
};
|
|
53449
|
-
const run2 = (
|
|
53849
|
+
const run2 = (label2, kind, scopes, fn, info = {}) => {
|
|
53450
53850
|
if (kind === "cells") {
|
|
53451
53851
|
for (const scope of scopes)
|
|
53452
53852
|
if (scope.kind === "cells" && workbook.sheets[scope.sheet]?.pivotTables?.some(
|
|
@@ -53463,7 +53863,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
53463
53863
|
}))
|
|
53464
53864
|
throw new Error(DATA_TABLE_PART_ERROR);
|
|
53465
53865
|
const outer = !open;
|
|
53466
|
-
const current = open ?? begin(
|
|
53866
|
+
const current = open ?? begin(label2, kind, info);
|
|
53467
53867
|
if (!outer) {
|
|
53468
53868
|
delete current.step.calc;
|
|
53469
53869
|
if (info.structural) current.step.structural = true;
|
|
@@ -53594,9 +53994,9 @@ function createEditSession(workbook, options = {}) {
|
|
|
53594
53994
|
removeConditionalFormat: (s, index3) => removeConditionalFormat(ctx, s, index3),
|
|
53595
53995
|
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
53596
53996
|
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
53597
|
-
updateTable: (s,
|
|
53598
|
-
resizeTable: (s,
|
|
53599
|
-
convertTableToRange: (s,
|
|
53997
|
+
updateTable: (s, table4, patch2) => updateTable(ctx, s, table4, patch2),
|
|
53998
|
+
resizeTable: (s, table4, range2) => resizeTable(ctx, s, table4, range2),
|
|
53999
|
+
convertTableToRange: (s, table4) => convertTableToRange(ctx, s, table4),
|
|
53600
54000
|
applyCellStyle: (s, ranges, name3) => applyCellStyle(ctx, s, ranges, name3),
|
|
53601
54001
|
setPageSetup: (s, patch2) => setPageSetup(ctx, s, patch2),
|
|
53602
54002
|
setPageBreak: (s, axis, before, present) => setPageBreak(ctx, s, axis, before, present),
|
|
@@ -53633,12 +54033,12 @@ function createEditSession(workbook, options = {}) {
|
|
|
53633
54033
|
validate: (s, r, c2, value2) => validateCellInput(workbook, s, r, c2, value2, {
|
|
53634
54034
|
evaluate: (formula, at2) => calc.evaluate(formula, at2)
|
|
53635
54035
|
}),
|
|
53636
|
-
batch(
|
|
54036
|
+
batch(label2, fn) {
|
|
53637
54037
|
if (open) {
|
|
53638
54038
|
fn();
|
|
53639
54039
|
return;
|
|
53640
54040
|
}
|
|
53641
|
-
const current = begin(
|
|
54041
|
+
const current = begin(label2, "batch", {});
|
|
53642
54042
|
open = current;
|
|
53643
54043
|
try {
|
|
53644
54044
|
fn();
|
|
@@ -54318,9 +54718,9 @@ var VisioPackage = class _VisioPackage {
|
|
|
54318
54718
|
};
|
|
54319
54719
|
|
|
54320
54720
|
// visio/metadata.ts
|
|
54321
|
-
function metadata(value2, max,
|
|
54721
|
+
function metadata(value2, max, label2) {
|
|
54322
54722
|
if (value2.length > max)
|
|
54323
|
-
throw new VisioPackageError("METADATA_LIMIT", `${
|
|
54723
|
+
throw new VisioPackageError("METADATA_LIMIT", `${label2} exceeds its metadata length limit.`);
|
|
54324
54724
|
return value2;
|
|
54325
54725
|
}
|
|
54326
54726
|
function metadataAttributes(node3) {
|
|
@@ -58272,15 +58672,15 @@ function legacyFillGradient(cells3, width, height, resolve3) {
|
|
|
58272
58672
|
|
|
58273
58673
|
// ../../node_modules/.bun/@christophervr+ole2@0.13.0/node_modules/@christophervr/ole2/dist/utils/png-encoder.js
|
|
58274
58674
|
var CRC_TABLE = (() => {
|
|
58275
|
-
const
|
|
58675
|
+
const table4 = new Uint32Array(256);
|
|
58276
58676
|
for (let n = 0; n < 256; n++) {
|
|
58277
58677
|
let c2 = n;
|
|
58278
58678
|
for (let k = 0; k < 8; k++) {
|
|
58279
58679
|
c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
|
|
58280
58680
|
}
|
|
58281
|
-
|
|
58681
|
+
table4[n] = c2 >>> 0;
|
|
58282
58682
|
}
|
|
58283
|
-
return
|
|
58683
|
+
return table4;
|
|
58284
58684
|
})();
|
|
58285
58685
|
function crc322(bytes) {
|
|
58286
58686
|
let crc = 4294967295;
|
|
@@ -60954,7 +61354,7 @@ function property(row3, budget, report) {
|
|
|
60954
61354
|
"Shape data has no supported current cached typed value; original cached text is retained."
|
|
60955
61355
|
);
|
|
60956
61356
|
}
|
|
60957
|
-
const
|
|
61357
|
+
const label2 = get("Label"), format5 = get("Format"), prompt = get("Prompt"), sortKey = get("SortKey");
|
|
60958
61358
|
const invisible = boolean(row3.cells, "Invisible", budget, report);
|
|
60959
61359
|
const dataLinked = row3.cells.has("DataLinked") ? boolean(row3.cells, "DataLinked", budget, report) : void 0;
|
|
60960
61360
|
const unit3 = row3.cells.get("Value")?.unit, error = row3.cells.get("Value")?.error;
|
|
@@ -60966,7 +61366,7 @@ function property(row3, budget, report) {
|
|
|
60966
61366
|
...rawType === void 0 ? {} : { rawType },
|
|
60967
61367
|
...rawValue === void 0 ? {} : { rawValue },
|
|
60968
61368
|
...value2 === void 0 ? {} : { value: value2 },
|
|
60969
|
-
...
|
|
61369
|
+
...label2 === void 0 ? {} : { label: label2 },
|
|
60970
61370
|
...format5 === void 0 ? {} : { format: format5 },
|
|
60971
61371
|
...prompt === void 0 ? {} : { prompt },
|
|
60972
61372
|
...sortKey === void 0 ? {} : { sortKey },
|
|
@@ -61199,9 +61599,9 @@ async function readDataRecordsets(pkg, documentPart, check3) {
|
|
|
61199
61599
|
const declared = children3(children3(set, "DataColumns")[0], "DataColumn");
|
|
61200
61600
|
const columns = (declared.length ? declared : []).map((node3) => {
|
|
61201
61601
|
const name4 = attribute3(node3, "ColumnNameID") ?? attribute3(node3, "Name") ?? "";
|
|
61202
|
-
const
|
|
61203
|
-
if (!name4 || name4.length > 255 ||
|
|
61204
|
-
return { name: name4, label:
|
|
61602
|
+
const label2 = attribute3(node3, "Label") ?? attribute3(node3, "Name") ?? name4;
|
|
61603
|
+
if (!name4 || name4.length > 255 || label2.length > 255) invalid2("Invalid data column.");
|
|
61604
|
+
return { name: name4, label: label2, type: typeFromCode(attribute3(node3, "DataType")) };
|
|
61205
61605
|
});
|
|
61206
61606
|
if (!columns.length)
|
|
61207
61607
|
for (const column2 of ado.columns)
|
|
@@ -67864,18 +68264,18 @@ function advances(family, bold) {
|
|
|
67864
68264
|
const key2 = `${name3}|${bold ? "b" : "r"}`;
|
|
67865
68265
|
const known = decoded.get(key2);
|
|
67866
68266
|
if (known) return known;
|
|
67867
|
-
const
|
|
67868
|
-
if (!
|
|
67869
|
-
const values2 = (bold ?
|
|
68267
|
+
const table4 = Object.hasOwn(DESIGN_ADVANCES, name3) ? DESIGN_ADVANCES[name3] : void 0;
|
|
68268
|
+
if (!table4) return void 0;
|
|
68269
|
+
const values2 = (bold ? table4.bold : table4.regular).split(" ").map(Number);
|
|
67870
68270
|
decoded.set(key2, values2);
|
|
67871
68271
|
return values2;
|
|
67872
68272
|
}
|
|
67873
68273
|
function designTextWidthEm(text8, family, bold = false) {
|
|
67874
|
-
const
|
|
67875
|
-
if (!
|
|
68274
|
+
const table4 = advances(family, bold);
|
|
68275
|
+
if (!table4) return void 0;
|
|
67876
68276
|
let units2 = 0;
|
|
67877
68277
|
for (let index3 = 0; index3 < text8.length; ++index3) {
|
|
67878
|
-
const advance =
|
|
68278
|
+
const advance = table4[text8.charCodeAt(index3) - FIRST];
|
|
67879
68279
|
if (advance === void 0 || Number.isNaN(advance)) return void 0;
|
|
67880
68280
|
units2 += advance;
|
|
67881
68281
|
}
|
|
@@ -71086,9 +71486,9 @@ function visioBorderShapes(style3, width, height, title = VISIO_DEFAULT_TITLE) {
|
|
|
71086
71486
|
// visio/edit-page-setup-commands.ts
|
|
71087
71487
|
var VISIO_SCALE_UNITS = Object.freeze(["IN", "FT", "MM", "CM", "M"]);
|
|
71088
71488
|
var isVisioPageSetupEdit = (edit) => edit.type === "set-page-alt-text" || edit.type === "set-page-setup" || edit.type === "set-page-properties" || edit.type === "set-page-decoration" || edit.type === "set-page-layout" || edit.type === "set-snap-glue";
|
|
71089
|
-
var pageId = (value2,
|
|
71489
|
+
var pageId = (value2, label2) => {
|
|
71090
71490
|
if (typeof value2 !== "string" || !value2 || value2.length > 256)
|
|
71091
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71491
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71092
71492
|
return value2;
|
|
71093
71493
|
};
|
|
71094
71494
|
var newPageId = (value2) => {
|
|
@@ -71195,11 +71595,11 @@ var VISIO_SHAPE_DATA_TYPES = [
|
|
|
71195
71595
|
"date"
|
|
71196
71596
|
];
|
|
71197
71597
|
var invalidText2 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71198
|
-
function shapeDataText(value2,
|
|
71598
|
+
function shapeDataText(value2, label2) {
|
|
71199
71599
|
if (typeof value2 !== "string" || value2.length > VISIO_METADATA_TEXT_LIMIT)
|
|
71200
|
-
fail2("INVALID_EDIT", `${
|
|
71600
|
+
fail2("INVALID_EDIT", `${label2} must be a string within the length limit.`);
|
|
71201
71601
|
if (invalidText2.test(value2) || /[\r\n\t]/.test(value2))
|
|
71202
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71602
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid characters.`);
|
|
71203
71603
|
return value2;
|
|
71204
71604
|
}
|
|
71205
71605
|
function shapeDataRowName(value2) {
|
|
@@ -71207,9 +71607,9 @@ function shapeDataRowName(value2) {
|
|
|
71207
71607
|
fail2("INVALID_EDIT", "Shape Data row names use letters, digits and underscores.");
|
|
71208
71608
|
return value2;
|
|
71209
71609
|
}
|
|
71210
|
-
function visioShapeDataRowName(
|
|
71610
|
+
function visioShapeDataRowName(label2, taken = []) {
|
|
71211
71611
|
const used = new Set([...taken].map((name4) => name4.toLowerCase()));
|
|
71212
|
-
let base2 =
|
|
71612
|
+
let base2 = label2.normalize("NFKD").replace(/[^\w]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 48);
|
|
71213
71613
|
if (!base2) base2 = "Property";
|
|
71214
71614
|
if (/^\d/.test(base2)) base2 = `_${base2}`;
|
|
71215
71615
|
let name3 = base2;
|
|
@@ -71281,18 +71681,18 @@ var TYPES3 = [
|
|
|
71281
71681
|
"unlink-data-rows"
|
|
71282
71682
|
];
|
|
71283
71683
|
var isVisioDataEdit = (edit) => TYPES3.includes(edit.type);
|
|
71284
|
-
var id = (value2,
|
|
71684
|
+
var id = (value2, label2) => {
|
|
71285
71685
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71286
|
-
fail2("INVALID_EDIT", `Invalid ${
|
|
71686
|
+
fail2("INVALID_EDIT", `Invalid ${label2}.`);
|
|
71287
71687
|
return value2;
|
|
71288
71688
|
};
|
|
71289
|
-
var name = (value2,
|
|
71290
|
-
const text8 = shapeDataText(value2,
|
|
71689
|
+
var name = (value2, label2) => {
|
|
71690
|
+
const text8 = shapeDataText(value2, label2);
|
|
71291
71691
|
if (!text8.trim() || text8.length > 255)
|
|
71292
|
-
fail2("INVALID_EDIT", `${
|
|
71692
|
+
fail2("INVALID_EDIT", `${label2} must be 1 to 255 characters.`);
|
|
71293
71693
|
return text8;
|
|
71294
71694
|
};
|
|
71295
|
-
function
|
|
71695
|
+
function table3(columns, rows) {
|
|
71296
71696
|
if (!Array.isArray(columns) || !columns.length || columns.length > VISIO_DATA_LIMITS.maxColumns)
|
|
71297
71697
|
fail2("INVALID_EDIT", `A recordset needs 1 to ${VISIO_DATA_LIMITS.maxColumns} columns.`);
|
|
71298
71698
|
if (!Array.isArray(rows) || rows.length > VISIO_DATA_LIMITS.maxRows)
|
|
@@ -71338,14 +71738,14 @@ function snapshotDataEdit(edit) {
|
|
|
71338
71738
|
type: edit.type,
|
|
71339
71739
|
pageId: pageId2,
|
|
71340
71740
|
name: name(edit.name, "The recordset name"),
|
|
71341
|
-
...
|
|
71741
|
+
...table3(edit.columns, edit.rows)
|
|
71342
71742
|
};
|
|
71343
71743
|
case "refresh-data-recordset":
|
|
71344
71744
|
return {
|
|
71345
71745
|
type: edit.type,
|
|
71346
71746
|
pageId: pageId2,
|
|
71347
71747
|
recordsetId: id(edit.recordsetId, "recordset"),
|
|
71348
|
-
...
|
|
71748
|
+
...table3(edit.columns, edit.rows)
|
|
71349
71749
|
};
|
|
71350
71750
|
case "delete-data-recordset":
|
|
71351
71751
|
return { type: edit.type, pageId: pageId2, recordsetId: id(edit.recordsetId, "recordset") };
|
|
@@ -71404,16 +71804,16 @@ function snapshotPageTheme(edit) {
|
|
|
71404
71804
|
var isVisioCommentEdit = (edit) => edit.type === "add-comment" || edit.type === "edit-comment" || edit.type === "delete-comment";
|
|
71405
71805
|
var invalidText3 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
71406
71806
|
var dateTime = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?(?:Z|[+-]\d{2}:\d{2})?$/;
|
|
71407
|
-
function string(value2, limit3,
|
|
71807
|
+
function string(value2, limit3, label2, required = true) {
|
|
71408
71808
|
if (typeof value2 !== "string" || value2.length > limit3 || required && !value2.trim())
|
|
71409
|
-
fail2("INVALID_EDIT", `${
|
|
71809
|
+
fail2("INVALID_EDIT", `${label2} must be a non-empty string within its length limit.`);
|
|
71410
71810
|
if (invalidText3.test(value2))
|
|
71411
|
-
fail2("INVALID_EDIT_TEXT", `${
|
|
71811
|
+
fail2("INVALID_EDIT_TEXT", `${label2} contains invalid XML characters.`);
|
|
71412
71812
|
return value2;
|
|
71413
71813
|
}
|
|
71414
|
-
var id2 = (value2,
|
|
71814
|
+
var id2 = (value2, label2) => {
|
|
71415
71815
|
if (typeof value2 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value2) || Number(value2) > 4294967295)
|
|
71416
|
-
fail2("INVALID_EDIT", `${
|
|
71816
|
+
fail2("INVALID_EDIT", `${label2} must be a canonical unsigned integer.`);
|
|
71417
71817
|
return value2;
|
|
71418
71818
|
};
|
|
71419
71819
|
var date = (value2) => {
|
|
@@ -71936,7 +72336,7 @@ async function editVsdxMasterInstance(pkg, parts, pages, edit, limits, maxOutput
|
|
|
71936
72336
|
|
|
71937
72337
|
// visio/paper-sizes.ts
|
|
71938
72338
|
var mm = (value2) => value2 / 25.4;
|
|
71939
|
-
var size = (id3,
|
|
72339
|
+
var size = (id3, label2, width, height, paperKind) => Object.freeze({ id: id3, label: label2, width, height, ...paperKind === void 0 ? {} : { paperKind } });
|
|
71940
72340
|
var VISIO_PAPER_SIZES = Object.freeze([
|
|
71941
72341
|
size("letter", "Letter", 8.5, 11, 1),
|
|
71942
72342
|
size("tabloid", "Tabloid", 11, 17, 3),
|
|
@@ -73306,7 +73706,7 @@ function snapshotFormatting(edit) {
|
|
|
73306
73706
|
if (!Number.isInteger(value2)) fail2("INVALID_EDIT", "Paint patterns require integers.");
|
|
73307
73707
|
result2[name3] = value2;
|
|
73308
73708
|
}
|
|
73309
|
-
for (const [name3, maximum,
|
|
73709
|
+
for (const [name3, maximum, label2] of [
|
|
73310
73710
|
["beginArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73311
73711
|
["endArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
73312
73712
|
["beginArrowSize", 6, "Arrowhead sizes are numbered 0 to 6."],
|
|
@@ -73320,7 +73720,7 @@ function snapshotFormatting(edit) {
|
|
|
73320
73720
|
const value2 = edit[name3];
|
|
73321
73721
|
if (value2 === void 0) continue;
|
|
73322
73722
|
if (typeof value2 !== "number" || !Number.isInteger(value2) || value2 < 0 || value2 > maximum)
|
|
73323
|
-
fail2("INVALID_EDIT",
|
|
73723
|
+
fail2("INVALID_EDIT", label2);
|
|
73324
73724
|
result2[name3] = value2;
|
|
73325
73725
|
}
|
|
73326
73726
|
if (edit.rounding !== void 0) result2.rounding = points(edit.rounding, 0, 720);
|