ooxml-core 1.9.0 → 1.10.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-5UURGJEV.mjs +2 -0
- package/dist/{PptxHandler-EX4WBIQQ.mjs → PptxHandler-ADEFY476.mjs} +2 -2
- package/dist/PptxHandler-U5XB2HUE.cjs +11 -0
- package/dist/automation/index.cjs +744 -192
- package/dist/automation/index.mjs +744 -192
- package/dist/{chunk-SWF7KVL5.cjs → chunk-3N6XMMTT.cjs} +1365 -1062
- package/dist/{chunk-FIELY5PI.mjs → chunk-5NVJN4E6.mjs} +30 -2
- package/dist/{chunk-IGOA57LE.mjs → chunk-A6P7G3UK.mjs} +1 -1
- package/dist/{chunk-CPKNMQLX.cjs → chunk-AWIDASUW.cjs} +25 -2
- package/dist/{chunk-SVQZXP3F.mjs → chunk-CBNKBVX5.mjs} +25 -2
- package/dist/{chunk-OXHMZS7B.mjs → chunk-CCHYFCPD.mjs} +649 -172
- package/dist/{chunk-OB277ZGE.mjs → chunk-R6KSBNKX.mjs} +27 -1
- package/dist/{chunk-AT66SA5M.cjs → chunk-S6DOCMQC.cjs} +28 -0
- package/dist/{chunk-WSO4T2LJ.mjs → chunk-WUE5ZHU3.mjs} +26 -3
- package/dist/{chunk-LCS3J3QI.mjs → chunk-ZE53K7DH.mjs} +474 -171
- package/dist/{chunk-M76PHYRR.mjs → chunk-ZOUGMAZG.mjs} +1 -1
- package/dist/docx/layout/adapt-table.d.ts +2 -2
- package/dist/docx/layout/adapt-table.d.ts.map +1 -1
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +477 -75
- package/dist/docx/layout/index.mjs +477 -76
- package/dist/docx/layout/nested-frame-profile.d.ts +9 -0
- package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -0
- package/dist/docx/layout/page-cursor.d.ts +2 -0
- package/dist/docx/layout/page-cursor.d.ts.map +1 -1
- package/dist/docx/layout/result.d.ts +13 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/table-border-layout.d.ts +16 -0
- package/dist/docx/layout/table-border-layout.d.ts.map +1 -0
- package/dist/docx/layout/table-cell-layout.d.ts +2 -1
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-content.d.ts +4 -0
- package/dist/docx/layout/table-content.d.ts.map +1 -0
- package/dist/docx/layout/table-footnotes.d.ts +5 -0
- package/dist/docx/layout/table-footnotes.d.ts.map +1 -1
- package/dist/docx/layout/table-frames.d.ts +4 -0
- package/dist/docx/layout/table-frames.d.ts.map +1 -0
- package/dist/docx/layout/table-layout.d.ts +8 -3
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/layout/table-note-completion.d.ts +5 -0
- package/dist/docx/layout/table-note-completion.d.ts.map +1 -0
- package/dist/docx/layout/table-note-stories.d.ts +6 -0
- package/dist/docx/layout/table-note-stories.d.ts.map +1 -0
- package/dist/pptx/automation/index.cjs +535 -182
- package/dist/pptx/automation/index.d.ts +4 -4
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-BZh-IMkN.d.ts → index-Cuxtr76Y.d.ts} +17 -3
- package/dist/pptx/chunks/index-Cuxtr76Y.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-B4cnSPNz.d.ts → index-DUCGeZh7.d.ts} +65 -5
- package/dist/pptx/chunks/index-DUCGeZh7.d.ts.map +1 -0
- package/dist/pptx/chunks/{smart-art-Q2kZQtHh.d.ts → smart-art-D-sXa_Nb.d.ts} +11 -1
- package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-BLodkuXE.d.ts → text-operations-BqHmLaLA.d.ts} +26 -2
- package/dist/pptx/chunks/text-operations-BqHmLaLA.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +535 -182
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +1 -0
- 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 +2 -2
- package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +18 -18
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +2 -2
- package/dist/pptx/editor/render/remap-text.cjs +2 -2
- package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
- package/dist/pptx/editor/render/remap-text.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/index.cjs +762 -182
- package/dist/pptx/index.d.ts +5 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/smartart-layouts/index.d.ts +1 -1
- package/dist/teams/index.cjs +486 -114
- package/dist/teams/index.mjs +486 -114
- package/dist/visio/date-cache.d.ts +3 -0
- package/dist/visio/date-cache.d.ts.map +1 -0
- package/dist/visio/edit-text-field.d.ts.map +1 -1
- package/dist/visio/index.cjs +131 -22
- package/dist/visio/index.mjs +131 -22
- package/dist/visio/shape-metadata.d.ts.map +1 -1
- package/dist/visio/text-field-display.d.ts.map +1 -1
- package/dist/visio/text-field-fraction.d.ts +3 -0
- package/dist/visio/text-field-fraction.d.ts.map +1 -0
- package/dist/visio/text-field-numeric.d.ts +1 -1
- package/dist/visio/text-field-numeric.d.ts.map +1 -1
- package/dist/visio/text-field-system-date.d.ts +4 -0
- package/dist/visio/text-field-system-date.d.ts.map +1 -0
- package/dist/visio/text-fields.d.ts +1 -0
- package/dist/visio/text-fields.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +132 -22
- package/dist/visio/ui/index.mjs +132 -22
- package/dist/visio/ui/text-field-catalog.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +614 -170
- package/dist/xlsx/index.mjs +614 -170
- package/dist/xlsx/load/index.cjs +575 -163
- package/dist/xlsx/load/index.mjs +575 -163
- package/dist/xlsx/model-pivots.d.ts +23 -2
- package/dist/xlsx/model-pivots.d.ts.map +1 -1
- package/dist/xlsx/pivot/admission.d.ts.map +1 -1
- package/dist/xlsx/pivot/aggregate.d.ts +3 -1
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
- package/dist/xlsx/pivot/data.d.ts +1 -1
- package/dist/xlsx/pivot/data.d.ts.map +1 -1
- package/dist/xlsx/pivot/hierarchy-first.d.ts +21 -0
- package/dist/xlsx/pivot/hierarchy-first.d.ts.map +1 -0
- package/dist/xlsx/pivot/hierarchy.d.ts +2 -4
- package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -1
- package/dist/xlsx/pivot/measures.d.ts +13 -0
- package/dist/xlsx/pivot/measures.d.ts.map +1 -0
- package/dist/xlsx/pivot/read.d.ts.map +1 -1
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
- package/dist/xlsx/pivot/values-axis.d.ts +9 -0
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +547 -127
- package/dist/xlsx/ui/index.mjs +547 -127
- package/package.json +1 -1
- package/dist/PptxHandler-AT7FVG5Q.mjs +0 -2
- package/dist/PptxHandler-VFSCECPL.cjs +0 -11
- package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +0 -1
- package/dist/pptx/chunks/index-BZh-IMkN.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BLodkuXE.d.ts.map +0 -1
package/dist/teams/index.mjs
CHANGED
|
@@ -19981,6 +19981,25 @@ function validatePivotFields(pivot) {
|
|
|
19981
19981
|
...pivot.columnField ? [pivot.columnField] : [],
|
|
19982
19982
|
pivot.valueField
|
|
19983
19983
|
];
|
|
19984
|
+
const extras = pivot.additionalValues ?? [];
|
|
19985
|
+
if (pivot.valuesAxis !== void 0 && !["columns", "rows"].includes(pivot.valuesAxis))
|
|
19986
|
+
throw new Error("Choose a valid Values axis.");
|
|
19987
|
+
if (pivot.valuesPosition !== void 0 && !["last", "between", "first"].includes(pivot.valuesPosition))
|
|
19988
|
+
throw new Error("Choose a valid Values position.");
|
|
19989
|
+
if ((pivot.valuesPosition === "between" || pivot.valuesPosition === "first") && (pivot.valuesAxis !== "rows" || !pivot.secondRowField))
|
|
19990
|
+
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
19991
|
+
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
19992
|
+
throw new Error("Values on rows require multiple measures.");
|
|
19993
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== "Values")
|
|
19994
|
+
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
19995
|
+
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
19996
|
+
(measure) => !measure || !pivot.fields.includes(measure.field) || !PIVOT_AGGREGATES.includes(measure.aggregate) || typeof measure.caption !== "string" || !measure.caption.trim() || measure.caption.length > 255 || pivot.fields.some((field) => field.toLowerCase() === measure.caption.toLowerCase())
|
|
19997
|
+
) || new Set(
|
|
19998
|
+
[pivot.valueCaption, ...extras.map((measure) => measure.caption)].map(
|
|
19999
|
+
(caption) => caption?.toLowerCase()
|
|
20000
|
+
)
|
|
20001
|
+
).size !== extras.length + 1)
|
|
20002
|
+
throw new Error("Choose PivotTable value fields with valid aggregates and unique captions.");
|
|
19984
20003
|
if (pivot.layout !== void 0 && !["tabular", "compact", "outline"].includes(pivot.layout) || pivot.subtotalPosition !== void 0 && !["top", "bottom"].includes(pivot.subtotalPosition) || !PIVOT_AGGREGATES.includes(pivot.aggregate) || used.some((field) => !pivot.fields.includes(field)) || new Set([pivot.rowField, pivot.secondRowField, pivot.columnField].filter(Boolean)).size !== [pivot.rowField, pivot.secondRowField, pivot.columnField].filter(Boolean).length || pivot.subtotals !== void 0 && typeof pivot.subtotals !== "boolean" || pivot.repeatLabels !== void 0 && typeof pivot.repeatLabels !== "boolean")
|
|
19985
20004
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
19986
20005
|
}
|
|
@@ -19988,6 +20007,7 @@ var PIVOT_AGGREGATES;
|
|
|
19988
20007
|
var init_data = __esm({
|
|
19989
20008
|
"xlsx/pivot/data.ts"() {
|
|
19990
20009
|
init_model();
|
|
20010
|
+
init_xml2();
|
|
19991
20011
|
PIVOT_AGGREGATES = ["sum", "count", "average", "min", "max"];
|
|
19992
20012
|
}
|
|
19993
20013
|
});
|
|
@@ -20045,20 +20065,186 @@ var init_cache_xml = __esm({
|
|
|
20045
20065
|
}
|
|
20046
20066
|
});
|
|
20047
20067
|
|
|
20068
|
+
// xlsx/pivot/measures.ts
|
|
20069
|
+
function aggregate2(records, field, type) {
|
|
20070
|
+
if (!records.length) return null;
|
|
20071
|
+
const values2 = records.map((record) => record[field] ?? null);
|
|
20072
|
+
if (type === "count") return values2.filter((value) => value !== null && value !== "").length;
|
|
20073
|
+
const error = values2.find(isCellError);
|
|
20074
|
+
if (error) return error;
|
|
20075
|
+
const numbers3 = values2.filter((value) => typeof value === "number");
|
|
20076
|
+
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
20077
|
+
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
20078
|
+
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
20079
|
+
const sum2 = numbers3.reduce((total2, value) => total2 + value, 0);
|
|
20080
|
+
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
20081
|
+
}
|
|
20082
|
+
function pivotHeaderDimensions(pivot, columnItems, rowLabels) {
|
|
20083
|
+
const measures = 1 + (pivot.additionalValues?.length ?? 0);
|
|
20084
|
+
if (pivot.valuesAxis === "rows")
|
|
20085
|
+
return {
|
|
20086
|
+
rows: pivot.columnField ? 2 : 1,
|
|
20087
|
+
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
20088
|
+
};
|
|
20089
|
+
return {
|
|
20090
|
+
rows: pivot.columnField ? measures > 1 ? 3 : 2 : 1,
|
|
20091
|
+
width: rowLabels + (pivot.columnField ? measures === 1 ? Math.max(1, columnItems) + 1 : (columnItems + 1) * measures : measures)
|
|
20092
|
+
};
|
|
20093
|
+
}
|
|
20094
|
+
function pivotHeaders(pivot, columns, labels, label3) {
|
|
20095
|
+
const measures = pivotMeasures(pivot);
|
|
20096
|
+
if (pivot.valuesAxis === "rows") {
|
|
20097
|
+
const rowLabels = pivot.layout === "compact" ? ["Row Labels"] : pivot.valuesPosition === "first" ? ["Values", ...labels] : pivot.valuesPosition === "between" ? [labels[0], "Values", labels[1]] : [...labels, "Values"];
|
|
20098
|
+
return pivot.columnField ? [
|
|
20099
|
+
[
|
|
20100
|
+
...rowLabels.map(() => null),
|
|
20101
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
20102
|
+
...columns.map(() => null)
|
|
20103
|
+
],
|
|
20104
|
+
[...rowLabels, ...columns.map(label3), "Grand Total"]
|
|
20105
|
+
] : [[...rowLabels, null]];
|
|
20106
|
+
}
|
|
20107
|
+
if (!pivot.columnField) return [[...labels, ...measures.map((measure) => measure.caption)]];
|
|
20108
|
+
if (measures.length === 1)
|
|
20109
|
+
return [
|
|
20110
|
+
[
|
|
20111
|
+
pivot.valueCaption,
|
|
20112
|
+
...labels.slice(1).map(() => null),
|
|
20113
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
20114
|
+
...columns.slice(1).map(() => null),
|
|
20115
|
+
null
|
|
20116
|
+
],
|
|
20117
|
+
[...labels, ...columns.map(label3), "Grand Total"]
|
|
20118
|
+
];
|
|
20119
|
+
const { width } = pivotHeaderDimensions(pivot, columns.length, labels.length);
|
|
20120
|
+
const first2 = Array(width).fill(null);
|
|
20121
|
+
first2[labels.length] = pivot.layout === "compact" ? "Column Labels" : pivot.columnField;
|
|
20122
|
+
if (pivot.layout !== "compact") first2[labels.length + 1] = "Values";
|
|
20123
|
+
return [
|
|
20124
|
+
first2,
|
|
20125
|
+
[
|
|
20126
|
+
...labels.map(() => null),
|
|
20127
|
+
...columns.flatMap((column) => [label3(column), ...measures.slice(1).map(() => null)]),
|
|
20128
|
+
...measures.map((measure) => `Total ${measure.caption}`)
|
|
20129
|
+
],
|
|
20130
|
+
[
|
|
20131
|
+
...labels,
|
|
20132
|
+
...columns.flatMap(() => measures.map((measure) => measure.caption)),
|
|
20133
|
+
...measures.map(() => null)
|
|
20134
|
+
]
|
|
20135
|
+
];
|
|
20136
|
+
}
|
|
20137
|
+
var pivotMeasures, pivotMeasureNumber, pivotNumbers;
|
|
20138
|
+
var init_measures = __esm({
|
|
20139
|
+
"xlsx/pivot/measures.ts"() {
|
|
20140
|
+
init_model();
|
|
20141
|
+
pivotMeasures = (pivot) => [
|
|
20142
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
20143
|
+
...pivot.additionalValues ?? []
|
|
20144
|
+
];
|
|
20145
|
+
pivotMeasureNumber = (pivot, records, measure) => aggregate2(records, pivot.fields.indexOf(measure.field), measure.aggregate);
|
|
20146
|
+
pivotNumbers = (pivot, records) => pivotMeasures(pivot).map((measure) => pivotMeasureNumber(pivot, records, measure));
|
|
20147
|
+
}
|
|
20148
|
+
});
|
|
20149
|
+
|
|
20150
|
+
// xlsx/pivot/hierarchy-first.ts
|
|
20151
|
+
function appendFirstPivotValues(pivot, context) {
|
|
20152
|
+
const {
|
|
20153
|
+
rowItems,
|
|
20154
|
+
secondRowItems,
|
|
20155
|
+
columnItems,
|
|
20156
|
+
children: children2,
|
|
20157
|
+
innerIndices,
|
|
20158
|
+
groups,
|
|
20159
|
+
details,
|
|
20160
|
+
buckets,
|
|
20161
|
+
width,
|
|
20162
|
+
rowLabels,
|
|
20163
|
+
top,
|
|
20164
|
+
bottom,
|
|
20165
|
+
append
|
|
20166
|
+
} = context;
|
|
20167
|
+
const compact = pivot.layout === "compact";
|
|
20168
|
+
const tabular = !pivot.layout || pivot.layout === "tabular";
|
|
20169
|
+
const blank = () => Array(width - rowLabels).fill(null);
|
|
20170
|
+
pivotMeasures(pivot).forEach((measure, m) => {
|
|
20171
|
+
const numbers3 = (keys, records) => [
|
|
20172
|
+
...columnItems.map(
|
|
20173
|
+
(column) => pivotMeasureNumber(
|
|
20174
|
+
pivot,
|
|
20175
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
20176
|
+
measure
|
|
20177
|
+
)
|
|
20178
|
+
),
|
|
20179
|
+
pivotMeasureNumber(pivot, records, measure)
|
|
20180
|
+
];
|
|
20181
|
+
if (!tabular)
|
|
20182
|
+
append([measure.caption, ...Array(rowLabels - 1).fill(null)], blank(), {
|
|
20183
|
+
indices: [m],
|
|
20184
|
+
measure: m
|
|
20185
|
+
});
|
|
20186
|
+
let first2 = true;
|
|
20187
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
20188
|
+
const key = pivotValueKey(outer);
|
|
20189
|
+
const group = groups.get(key) ?? [];
|
|
20190
|
+
if (!tabular)
|
|
20191
|
+
append(
|
|
20192
|
+
compact ? [pivotItemLabel(outer)] : [null, pivotItemLabel(outer), null],
|
|
20193
|
+
top ? numbers3([key], group) : blank(),
|
|
20194
|
+
{ indices: [m, outerIndex], measure: m },
|
|
20195
|
+
compact ? 1 : 0
|
|
20196
|
+
);
|
|
20197
|
+
const innerKeys = [...children2.get(key)].sort(
|
|
20198
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
20199
|
+
);
|
|
20200
|
+
innerKeys.forEach((innerKey, child3) => {
|
|
20201
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
20202
|
+
append(
|
|
20203
|
+
compact ? [pivotItemLabel(secondRowItems[innerIndex])] : [
|
|
20204
|
+
tabular && first2 ? measure.caption : null,
|
|
20205
|
+
pivot.repeatLabels || tabular && child3 === 0 ? pivotItemLabel(outer) : null,
|
|
20206
|
+
pivotItemLabel(secondRowItems[innerIndex])
|
|
20207
|
+
],
|
|
20208
|
+
numbers3([key, innerKey], details.get(JSON.stringify([key, innerKey]))),
|
|
20209
|
+
{ indices: [m, outerIndex, innerIndex], measure: m },
|
|
20210
|
+
compact ? 2 : 0
|
|
20211
|
+
);
|
|
20212
|
+
first2 = false;
|
|
20213
|
+
});
|
|
20214
|
+
if (bottom)
|
|
20215
|
+
append(
|
|
20216
|
+
compact ? [`${String(pivotItemLabel(outer))} Total`] : [null, `${String(pivotItemLabel(outer))} Total`, null],
|
|
20217
|
+
numbers3([key], group),
|
|
20218
|
+
{ indices: [m, outerIndex], measure: m, type: "default" },
|
|
20219
|
+
compact ? 1 : 0
|
|
20220
|
+
);
|
|
20221
|
+
});
|
|
20222
|
+
});
|
|
20223
|
+
}
|
|
20224
|
+
var init_hierarchy_first = __esm({
|
|
20225
|
+
"xlsx/pivot/hierarchy-first.ts"() {
|
|
20226
|
+
init_data();
|
|
20227
|
+
init_measures();
|
|
20228
|
+
}
|
|
20229
|
+
});
|
|
20230
|
+
|
|
20048
20231
|
// xlsx/pivot/hierarchy.ts
|
|
20049
|
-
function hierarchicalPivotGrid(pivot
|
|
20232
|
+
function hierarchicalPivotGrid(pivot) {
|
|
20050
20233
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
20051
20234
|
const secondRowItems = pivotItems(pivot, pivot.secondRowField);
|
|
20052
20235
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
20053
20236
|
const outerField = pivot.fields.indexOf(pivot.rowField);
|
|
20054
20237
|
const innerField = pivot.fields.indexOf(pivot.secondRowField);
|
|
20055
20238
|
const columnField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
20056
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
20057
20239
|
const layout2 = pivot.layout ?? "tabular";
|
|
20058
20240
|
const compact = layout2 === "compact";
|
|
20059
|
-
const
|
|
20241
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
20242
|
+
const firstValues = rowsAxis && pivot.valuesPosition === "first";
|
|
20243
|
+
const between = rowsAxis && pivot.valuesPosition === "between";
|
|
20244
|
+
const measures = pivotMeasures(pivot);
|
|
20245
|
+
const top = (!rowsAxis || firstValues) && layout2 !== "tabular" && pivot.subtotals !== false && (pivot.subtotalPosition ?? "top") === "top";
|
|
20060
20246
|
const bottom = pivot.subtotals !== false && !top;
|
|
20061
|
-
const rowLabelColumns = compact ? 1 : 2;
|
|
20247
|
+
const rowLabelColumns = compact ? 1 : rowsAxis ? 3 : 2;
|
|
20062
20248
|
const groups = /* @__PURE__ */ new Map();
|
|
20063
20249
|
const details = /* @__PURE__ */ new Map();
|
|
20064
20250
|
const children2 = /* @__PURE__ */ new Map();
|
|
@@ -20082,20 +20268,12 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
20082
20268
|
collect(buckets, JSON.stringify([...key, column]), record);
|
|
20083
20269
|
}
|
|
20084
20270
|
}
|
|
20085
|
-
const
|
|
20086
|
-
|
|
20087
|
-
|
|
20271
|
+
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, rowLabelColumns);
|
|
20272
|
+
const rows = (details.size + rowItems.length * Number(bottom) + 1) * (rowsAxis ? measures.length : 1) + rowItems.length * Number(layout2 !== "tabular") * (firstValues ? measures.length : 1) + (firstValues ? measures.length : between ? rowItems.length * measures.length : details.size) * Number(rowsAxis && layout2 !== "tabular") + dimensions.rows;
|
|
20273
|
+
if (rows * dimensions.width > 1e6) throw new Error("The PivotTable result is too large.");
|
|
20088
20274
|
const labels = compact ? ["Row Labels"] : [pivot.rowField, pivot.secondRowField];
|
|
20089
|
-
const values2 = pivot
|
|
20090
|
-
|
|
20091
|
-
pivot.valueCaption,
|
|
20092
|
-
...compact ? [] : [null],
|
|
20093
|
-
compact ? "Column Labels" : pivot.columnField,
|
|
20094
|
-
...columnItems.slice(1).map(() => null),
|
|
20095
|
-
null
|
|
20096
|
-
],
|
|
20097
|
-
[...labels, ...columnItems.map(label2), "Grand Total"]
|
|
20098
|
-
] : [[...labels, pivot.valueCaption]];
|
|
20275
|
+
const values2 = pivotHeaders(pivot, columnItems, labels, label2);
|
|
20276
|
+
const firstDataRow = values2.length;
|
|
20099
20277
|
const indents = values2.map(() => 0);
|
|
20100
20278
|
const rowEntries = [];
|
|
20101
20279
|
const append = (labels2, numbers4, entry3, indent = 0) => {
|
|
@@ -20103,98 +20281,193 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
20103
20281
|
rowEntries.push(entry3);
|
|
20104
20282
|
indents.push(indent);
|
|
20105
20283
|
};
|
|
20106
|
-
const
|
|
20284
|
+
const bands = (keys, records) => [
|
|
20107
20285
|
...columnItems.map(
|
|
20108
|
-
(column) =>
|
|
20109
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
20110
|
-
valueField,
|
|
20111
|
-
pivot.aggregate
|
|
20112
|
-
)
|
|
20286
|
+
(column) => pivotNumbers(pivot, buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [])
|
|
20113
20287
|
),
|
|
20114
|
-
|
|
20288
|
+
pivotNumbers(pivot, records)
|
|
20115
20289
|
];
|
|
20116
|
-
|
|
20117
|
-
|
|
20118
|
-
|
|
20119
|
-
|
|
20120
|
-
|
|
20121
|
-
|
|
20122
|
-
|
|
20123
|
-
|
|
20124
|
-
|
|
20125
|
-
|
|
20126
|
-
|
|
20127
|
-
|
|
20128
|
-
|
|
20129
|
-
const records = details.get(JSON.stringify(keys));
|
|
20130
|
-
if (!records) return;
|
|
20131
|
-
append(
|
|
20132
|
-
compact ? [label2(inner)] : [
|
|
20133
|
-
pivot.repeatLabels || layout2 === "tabular" && first2 ? label2(outer) : null,
|
|
20134
|
-
label2(inner)
|
|
20290
|
+
const numbers3 = (keys, records) => bands(keys, records).flat();
|
|
20291
|
+
const appendMeasures = (labels2, keys, records, indices, type) => {
|
|
20292
|
+
const values3 = bands(keys, records);
|
|
20293
|
+
measures.forEach(
|
|
20294
|
+
(measure, m) => append(
|
|
20295
|
+
type ? [
|
|
20296
|
+
`${type === "grand" ? "Total" : String(labels2[0])} ${measure.caption}`,
|
|
20297
|
+
...Array(rowLabelColumns - 1).fill(null)
|
|
20298
|
+
] : compact ? [measure.caption] : [
|
|
20299
|
+
...labels2.map(
|
|
20300
|
+
(label3) => layout2 === "tabular" && m === 0 || pivot.repeatLabels ? label3 : null
|
|
20301
|
+
),
|
|
20302
|
+
measure.caption
|
|
20135
20303
|
],
|
|
20136
|
-
|
|
20137
|
-
{ indices: [
|
|
20138
|
-
compact ?
|
|
20139
|
-
)
|
|
20140
|
-
|
|
20304
|
+
values3.map((band) => band[m] ?? null),
|
|
20305
|
+
{ indices: type ? indices : [...indices, m], measure: m, ...type ? { type } : {} },
|
|
20306
|
+
compact && !type ? 2 : 0
|
|
20307
|
+
)
|
|
20308
|
+
);
|
|
20309
|
+
};
|
|
20310
|
+
if (firstValues)
|
|
20311
|
+
appendFirstPivotValues(pivot, {
|
|
20312
|
+
rowItems,
|
|
20313
|
+
secondRowItems,
|
|
20314
|
+
columnItems,
|
|
20315
|
+
children: children2,
|
|
20316
|
+
innerIndices,
|
|
20317
|
+
groups,
|
|
20318
|
+
details,
|
|
20319
|
+
buckets,
|
|
20320
|
+
width: dimensions.width,
|
|
20321
|
+
rowLabels: rowLabelColumns,
|
|
20322
|
+
top,
|
|
20323
|
+
bottom,
|
|
20324
|
+
append
|
|
20141
20325
|
});
|
|
20142
|
-
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20326
|
+
else
|
|
20327
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
20328
|
+
const key = pivotValueKey(outer);
|
|
20329
|
+
if (layout2 !== "tabular")
|
|
20330
|
+
append(
|
|
20331
|
+
[label2(outer), ...Array(rowLabelColumns - 1).fill(null)],
|
|
20332
|
+
top ? numbers3([key], groups.get(key) ?? []) : Array(dimensions.width - rowLabelColumns).fill(null),
|
|
20333
|
+
{ indices: [outerIndex] }
|
|
20334
|
+
);
|
|
20335
|
+
let first2 = true;
|
|
20336
|
+
const innerKeys = [...children2.get(key)].sort(
|
|
20337
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
20148
20338
|
);
|
|
20149
|
-
|
|
20150
|
-
|
|
20151
|
-
|
|
20152
|
-
|
|
20153
|
-
|
|
20154
|
-
|
|
20339
|
+
if (between)
|
|
20340
|
+
measures.forEach((measure, m) => {
|
|
20341
|
+
if (layout2 !== "tabular")
|
|
20342
|
+
append(
|
|
20343
|
+
compact ? [measure.caption] : [pivot.repeatLabels ? label2(outer) : null, measure.caption, null],
|
|
20344
|
+
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
20345
|
+
{ indices: [outerIndex, m], measure: m },
|
|
20346
|
+
compact ? 1 : 0
|
|
20347
|
+
);
|
|
20348
|
+
innerKeys.forEach((innerKey, child3) => {
|
|
20349
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
20350
|
+
const keys = [key, innerKey];
|
|
20351
|
+
const records = details.get(JSON.stringify(keys));
|
|
20352
|
+
append(
|
|
20353
|
+
compact ? [label2(secondRowItems[innerIndex])] : [
|
|
20354
|
+
pivot.repeatLabels || layout2 === "tabular" && m === 0 && child3 === 0 ? label2(outer) : null,
|
|
20355
|
+
layout2 === "tabular" && child3 === 0 ? measure.caption : null,
|
|
20356
|
+
label2(secondRowItems[innerIndex])
|
|
20357
|
+
],
|
|
20358
|
+
[
|
|
20359
|
+
...columnItems.map(
|
|
20360
|
+
(column) => pivotMeasureNumber(
|
|
20361
|
+
pivot,
|
|
20362
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
20363
|
+
measure
|
|
20364
|
+
)
|
|
20365
|
+
),
|
|
20366
|
+
pivotMeasureNumber(pivot, records, measure)
|
|
20367
|
+
],
|
|
20368
|
+
{ indices: [outerIndex, m, innerIndex], measure: m },
|
|
20369
|
+
compact ? 2 : 0
|
|
20370
|
+
);
|
|
20371
|
+
});
|
|
20372
|
+
});
|
|
20373
|
+
else
|
|
20374
|
+
innerKeys.forEach((innerKey) => {
|
|
20375
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
20376
|
+
const inner = secondRowItems[innerIndex];
|
|
20377
|
+
const keys = [key, innerKey];
|
|
20378
|
+
const records = details.get(JSON.stringify(keys));
|
|
20379
|
+
if (!records) return;
|
|
20380
|
+
if (rowsAxis) {
|
|
20381
|
+
if (layout2 !== "tabular")
|
|
20382
|
+
append(
|
|
20383
|
+
compact ? [label2(inner)] : [pivot.repeatLabels ? label2(outer) : null, label2(inner), null],
|
|
20384
|
+
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
20385
|
+
{ indices: [outerIndex, innerIndex] },
|
|
20386
|
+
compact ? 1 : 0
|
|
20387
|
+
);
|
|
20388
|
+
appendMeasures(
|
|
20389
|
+
[pivot.repeatLabels || first2 ? label2(outer) : null, label2(inner)],
|
|
20390
|
+
keys,
|
|
20391
|
+
records,
|
|
20392
|
+
[outerIndex, innerIndex]
|
|
20393
|
+
);
|
|
20394
|
+
first2 = false;
|
|
20395
|
+
return;
|
|
20396
|
+
}
|
|
20397
|
+
append(
|
|
20398
|
+
compact ? [label2(inner)] : [
|
|
20399
|
+
pivot.repeatLabels || layout2 === "tabular" && first2 ? label2(outer) : null,
|
|
20400
|
+
label2(inner)
|
|
20401
|
+
],
|
|
20402
|
+
numbers3(keys, records),
|
|
20403
|
+
{ indices: [outerIndex, innerIndex] },
|
|
20404
|
+
compact ? 1 : 0
|
|
20405
|
+
);
|
|
20406
|
+
first2 = false;
|
|
20407
|
+
});
|
|
20408
|
+
if (bottom) {
|
|
20409
|
+
if (rowsAxis) {
|
|
20410
|
+
appendMeasures([label2(outer)], [key], groups.get(key) ?? [], [outerIndex], "default");
|
|
20411
|
+
return;
|
|
20412
|
+
}
|
|
20413
|
+
const caption = String(label2(outer));
|
|
20414
|
+
append(
|
|
20415
|
+
[`${caption} Total`, ...compact ? [] : [null]],
|
|
20416
|
+
numbers3([key], groups.get(key) ?? []),
|
|
20417
|
+
{ indices: [outerIndex], type: "default" }
|
|
20418
|
+
);
|
|
20419
|
+
}
|
|
20420
|
+
});
|
|
20421
|
+
if (rowsAxis) appendMeasures([], [], pivot.records, [0], "grand");
|
|
20422
|
+
else
|
|
20423
|
+
append(["Grand Total", ...compact ? [] : [null]], numbers3([], pivot.records), {
|
|
20424
|
+
indices: [0],
|
|
20425
|
+
type: "grand"
|
|
20426
|
+
});
|
|
20155
20427
|
return {
|
|
20156
20428
|
values: values2,
|
|
20157
20429
|
rowItems,
|
|
20158
20430
|
secondRowItems,
|
|
20159
20431
|
columnItems,
|
|
20160
20432
|
rowEntries,
|
|
20161
|
-
firstDataRow
|
|
20433
|
+
firstDataRow,
|
|
20162
20434
|
rowLabelColumns,
|
|
20163
|
-
indents
|
|
20435
|
+
indents,
|
|
20436
|
+
...rowsAxis ? { firstHeaderRow: 1 } : {}
|
|
20164
20437
|
};
|
|
20165
20438
|
}
|
|
20166
20439
|
var label2;
|
|
20167
20440
|
var init_hierarchy2 = __esm({
|
|
20168
20441
|
"xlsx/pivot/hierarchy.ts"() {
|
|
20169
20442
|
init_data();
|
|
20443
|
+
init_hierarchy_first();
|
|
20444
|
+
init_measures();
|
|
20170
20445
|
label2 = pivotItemLabel;
|
|
20171
20446
|
}
|
|
20172
20447
|
});
|
|
20173
20448
|
|
|
20174
20449
|
// xlsx/pivot/aggregate.ts
|
|
20175
|
-
function aggregate2(records, field, type) {
|
|
20176
|
-
if (!records.length) return null;
|
|
20177
|
-
const values2 = records.map((record) => record[field] ?? null);
|
|
20178
|
-
if (type === "count") return values2.filter((value) => value !== null && value !== "").length;
|
|
20179
|
-
const error = values2.find(isCellError);
|
|
20180
|
-
if (error) return error;
|
|
20181
|
-
const numbers3 = values2.filter((value) => typeof value === "number");
|
|
20182
|
-
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
20183
|
-
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
20184
|
-
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
20185
|
-
const sum2 = numbers3.reduce((total2, value) => total2 + value, 0);
|
|
20186
|
-
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
20187
|
-
}
|
|
20188
20450
|
function pivotGrid(pivot) {
|
|
20189
20451
|
validatePivotFields(pivot);
|
|
20190
|
-
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot
|
|
20452
|
+
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
20191
20453
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
20192
20454
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
20193
|
-
|
|
20455
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
20456
|
+
const compact = pivot.layout === "compact";
|
|
20457
|
+
const headings = rowsAxis && pivot.layout !== void 0 && pivot.layout !== "tabular";
|
|
20458
|
+
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, rowsAxis && !compact ? 2 : 1);
|
|
20459
|
+
const dataRows = (rowItems.length + 1) * (rowsAxis ? 1 + (pivot.additionalValues?.length ?? 0) : 1) + (headings ? rowItems.length : 0);
|
|
20460
|
+
if ((dataRows + dimensions.rows) * dimensions.width > 1e6)
|
|
20194
20461
|
throw new Error("The PivotTable result is too large.");
|
|
20462
|
+
const label3 = pivotItemLabel;
|
|
20463
|
+
const values2 = pivotHeaders(
|
|
20464
|
+
pivot,
|
|
20465
|
+
columnItems,
|
|
20466
|
+
[pivot.layout === "compact" ? "Row Labels" : pivot.rowField],
|
|
20467
|
+
label3
|
|
20468
|
+
);
|
|
20195
20469
|
const rowField = pivot.fields.indexOf(pivot.rowField);
|
|
20196
20470
|
const colField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
20197
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
20198
20471
|
const groups = /* @__PURE__ */ new Map();
|
|
20199
20472
|
const cells2 = /* @__PURE__ */ new Map();
|
|
20200
20473
|
const columns = /* @__PURE__ */ new Map();
|
|
@@ -20212,48 +20485,117 @@ function pivotGrid(pivot) {
|
|
|
20212
20485
|
collect(cells2, JSON.stringify([key, col]), record);
|
|
20213
20486
|
}
|
|
20214
20487
|
}
|
|
20215
|
-
const
|
|
20216
|
-
|
|
20217
|
-
|
|
20218
|
-
|
|
20219
|
-
|
|
20220
|
-
|
|
20221
|
-
|
|
20222
|
-
|
|
20223
|
-
|
|
20224
|
-
|
|
20225
|
-
|
|
20226
|
-
|
|
20227
|
-
|
|
20228
|
-
|
|
20488
|
+
const firstDataRow = values2.length;
|
|
20489
|
+
if (rowsAxis) {
|
|
20490
|
+
const measures = pivotMeasures(pivot);
|
|
20491
|
+
const rowEntries = [];
|
|
20492
|
+
const indents = values2.map(() => 0);
|
|
20493
|
+
const append = (caption, bands, index2, grand = false) => {
|
|
20494
|
+
measures.forEach((measure, m) => {
|
|
20495
|
+
values2.push([
|
|
20496
|
+
...compact ? [grand ? `Total ${measure.caption}` : measure.caption] : [
|
|
20497
|
+
grand ? `Total ${measure.caption}` : pivot.repeatLabels || !headings && m === 0 ? caption : null,
|
|
20498
|
+
grand ? null : measure.caption
|
|
20499
|
+
],
|
|
20500
|
+
...bands.map((band) => band[m] ?? null)
|
|
20501
|
+
]);
|
|
20502
|
+
indents.push(compact && !grand ? 1 : 0);
|
|
20503
|
+
rowEntries.push({
|
|
20504
|
+
indices: grand ? [0] : [index2, m],
|
|
20505
|
+
measure: m,
|
|
20506
|
+
...grand ? { type: "grand" } : {}
|
|
20507
|
+
});
|
|
20508
|
+
});
|
|
20509
|
+
};
|
|
20510
|
+
rowItems.forEach((item, index2) => {
|
|
20511
|
+
const key = pivotValueKey(item);
|
|
20512
|
+
if (headings) {
|
|
20513
|
+
values2.push([label3(item), ...Array(dimensions.width - 1).fill(null)]);
|
|
20514
|
+
rowEntries.push({ indices: [index2] });
|
|
20515
|
+
indents.push(0);
|
|
20516
|
+
}
|
|
20517
|
+
append(
|
|
20518
|
+
label3(item),
|
|
20519
|
+
[
|
|
20520
|
+
...columnItems.map(
|
|
20521
|
+
(col) => pivotNumbers(pivot, cells2.get(JSON.stringify([key, pivotValueKey(col)])) ?? [])
|
|
20522
|
+
),
|
|
20523
|
+
pivotNumbers(pivot, groups.get(key) ?? [])
|
|
20524
|
+
],
|
|
20525
|
+
index2
|
|
20526
|
+
);
|
|
20527
|
+
});
|
|
20528
|
+
append(
|
|
20529
|
+
"Grand Total",
|
|
20530
|
+
[
|
|
20531
|
+
...columnItems.map((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
20532
|
+
pivotNumbers(pivot, pivot.records)
|
|
20533
|
+
],
|
|
20534
|
+
0,
|
|
20535
|
+
true
|
|
20536
|
+
);
|
|
20537
|
+
return {
|
|
20538
|
+
values: values2,
|
|
20539
|
+
rowItems,
|
|
20540
|
+
columnItems,
|
|
20541
|
+
firstDataRow,
|
|
20542
|
+
rowLabelColumns: compact ? 1 : 2,
|
|
20543
|
+
indents,
|
|
20544
|
+
firstHeaderRow: 1,
|
|
20545
|
+
rowEntries
|
|
20546
|
+
};
|
|
20547
|
+
}
|
|
20229
20548
|
for (const row2 of rowItems) {
|
|
20230
20549
|
const records = groups.get(pivotValueKey(row2)) ?? [];
|
|
20231
20550
|
values2.push([
|
|
20232
20551
|
label3(row2),
|
|
20233
|
-
...columnItems.
|
|
20234
|
-
(col) =>
|
|
20235
|
-
|
|
20236
|
-
|
|
20237
|
-
pivot.aggregate
|
|
20552
|
+
...columnItems.flatMap(
|
|
20553
|
+
(col) => pivotNumbers(
|
|
20554
|
+
pivot,
|
|
20555
|
+
cells2.get(JSON.stringify([pivotValueKey(row2), pivotValueKey(col)])) ?? []
|
|
20238
20556
|
)
|
|
20239
20557
|
),
|
|
20240
|
-
|
|
20558
|
+
...pivotNumbers(pivot, records)
|
|
20241
20559
|
]);
|
|
20242
20560
|
}
|
|
20243
20561
|
values2.push([
|
|
20244
20562
|
"Grand Total",
|
|
20245
|
-
...columnItems.
|
|
20246
|
-
|
|
20247
|
-
),
|
|
20248
|
-
aggregate2(pivot.records, valueField, pivot.aggregate)
|
|
20563
|
+
...columnItems.flatMap((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
20564
|
+
...pivotNumbers(pivot, pivot.records)
|
|
20249
20565
|
]);
|
|
20250
|
-
return { values: values2, rowItems, columnItems, firstDataRow
|
|
20566
|
+
return { values: values2, rowItems, columnItems, firstDataRow };
|
|
20251
20567
|
}
|
|
20252
20568
|
var init_aggregate = __esm({
|
|
20253
20569
|
"xlsx/pivot/aggregate.ts"() {
|
|
20254
|
-
init_model();
|
|
20255
20570
|
init_data();
|
|
20256
20571
|
init_hierarchy2();
|
|
20572
|
+
init_measures();
|
|
20573
|
+
}
|
|
20574
|
+
});
|
|
20575
|
+
|
|
20576
|
+
// xlsx/pivot/values-axis.ts
|
|
20577
|
+
function pivotValueAxisItems(measures, columns) {
|
|
20578
|
+
const entries = [];
|
|
20579
|
+
if (columns === void 0) {
|
|
20580
|
+
for (let measure = 0; measure < measures; measure++)
|
|
20581
|
+
entries.push(
|
|
20582
|
+
`<i${attrs({ i: measure || void 0 })}><x${attrs({ v: measure || void 0 })}/></i>`
|
|
20583
|
+
);
|
|
20584
|
+
} else {
|
|
20585
|
+
for (let column = 0; column < columns; column++)
|
|
20586
|
+
for (let measure = 0; measure < measures; measure++) {
|
|
20587
|
+
entries.push(
|
|
20588
|
+
`<i${attrs({ r: measure ? 1 : void 0, i: measure || void 0 })}>${measure ? "" : `<x${attrs({ v: column || void 0 })}/>`}<x${attrs({ v: measure || void 0 })}/></i>`
|
|
20589
|
+
);
|
|
20590
|
+
}
|
|
20591
|
+
for (let measure = 0; measure < measures; measure++)
|
|
20592
|
+
entries.push(`<i${attrs({ t: "grand", i: measure || void 0 })}><x/></i>`);
|
|
20593
|
+
}
|
|
20594
|
+
return `<colItems count="${entries.length}">${entries.join("")}</colItems>`;
|
|
20595
|
+
}
|
|
20596
|
+
var init_values_axis = __esm({
|
|
20597
|
+
"xlsx/pivot/values-axis.ts"() {
|
|
20598
|
+
init_xml_out();
|
|
20257
20599
|
}
|
|
20258
20600
|
});
|
|
20259
20601
|
|
|
@@ -20263,7 +20605,9 @@ function pivotTableXml(pivot, cacheId, cache2) {
|
|
|
20263
20605
|
const row2 = pivot.fields.indexOf(pivot.rowField);
|
|
20264
20606
|
const second = pivot.secondRowField ? pivot.fields.indexOf(pivot.secondRowField) : -1;
|
|
20265
20607
|
const col = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
20266
|
-
const
|
|
20608
|
+
const measures = pivotMeasures(pivot);
|
|
20609
|
+
const multiple = measures.length > 1;
|
|
20610
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
20267
20611
|
const compact = pivot.layout === "compact";
|
|
20268
20612
|
const outline = pivot.layout === "compact" || pivot.layout === "outline";
|
|
20269
20613
|
const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
|
|
@@ -20271,36 +20615,61 @@ function pivotTableXml(pivot, cacheId, cache2) {
|
|
|
20271
20615
|
const items2 = index2 === row2 ? grid.rowItems : index2 === second ? grid.secondRowItems : index2 === col ? grid.columnItems : void 0;
|
|
20272
20616
|
const subtotal = !(index2 === row2 && pivot.subtotals === false);
|
|
20273
20617
|
const repeated = pivot.repeatLabels && (index2 === row2 || index2 === second) ? '<extLst><ext uri="{2946ED86-A175-432a-8AC1-64E0C546D7DE}"><x14:pivotField xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" fillDownLabels="1"/></ext></extLst>' : "";
|
|
20274
|
-
return `<pivotField${attrs({ axis: index2 === row2 || index2 === second ? "axisRow" : index2 === col ? "axisCol" : void 0, dataField:
|
|
20618
|
+
return `<pivotField${attrs({ axis: index2 === row2 || index2 === second ? "axisRow" : index2 === col ? "axisCol" : void 0, dataField: measures.some((measure) => pivot.fields.indexOf(measure.field) === index2) ? true : void 0, compact, outline, showAll: false, subtotalTop: index2 === row2 ? top : void 0, defaultSubtotal: subtotal ? void 0 : false })}>${items2 ? `<items count="${items2.length + Number(subtotal)}">${items2.map((item) => `<item x="${cache2.indices[index2].get(pivotValueKey(item))}"/>`).join("")}${subtotal ? '<item t="default"/>' : ""}</items>` : ""}${repeated}</pivotField>`;
|
|
20275
20619
|
}).join("");
|
|
20276
20620
|
const items = (count2) => Array.from({ length: count2 }, (_v, i) => `<i><x v="${i}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
20277
|
-
const header = grid.firstDataRow - 1;
|
|
20278
|
-
const rowIndices = [row2, ...second >= 0 ? [second] : []];
|
|
20621
|
+
const header = grid.firstHeaderRow ?? (multiple && col >= 0 ? 1 : grid.firstDataRow - 1);
|
|
20622
|
+
const rowIndices = rowsAxis && pivot.valuesPosition === "first" ? [-2, row2, second] : rowsAxis && pivot.valuesPosition === "between" ? [row2, -2, second] : [row2, ...second >= 0 ? [second] : [], ...rowsAxis ? [-2] : []];
|
|
20279
20623
|
let previous = [];
|
|
20280
20624
|
const rowItems = grid.rowEntries?.map((entry3) => {
|
|
20281
20625
|
let prefix = 0;
|
|
20282
|
-
if (
|
|
20626
|
+
if (entry3.type === "default" && rowsAxis && pivot.valuesPosition === "first") prefix = 1;
|
|
20627
|
+
else if (!entry3.type)
|
|
20283
20628
|
while (prefix < entry3.indices.length - 1 && entry3.indices[prefix] === previous[prefix])
|
|
20284
20629
|
prefix++;
|
|
20285
|
-
previous = entry3.type ? [] : entry3.indices;
|
|
20286
|
-
return `<i${attrs({ t: entry3.type, r: prefix || void 0 })}>${entry3.indices.slice(prefix).map((index2) => `<x${attrs({ v: index2 || void 0 })}/>`).join("")}</i>`;
|
|
20630
|
+
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
20631
|
+
return `<i${attrs({ t: entry3.type, r: prefix || void 0, i: entry3.measure || void 0 })}>${entry3.indices.slice(prefix).map((index2) => `<x${attrs({ v: index2 || void 0 })}/>`).join("")}</i>`;
|
|
20287
20632
|
}).join("") ?? items(grid.rowItems.length);
|
|
20288
20633
|
let body = `<location${attrs({ ref: formatRange(pivot.location), firstHeaderRow: header, firstDataRow: grid.firstDataRow, firstDataCol: grid.rowLabelColumns ?? 1 })}/><pivotFields count="${pivot.fields.length}">${fields}</pivotFields><rowFields count="${rowIndices.length}">${rowIndices.map((index2) => `<field x="${index2}"/>`).join("")}</rowFields><rowItems count="${grid.rowEntries?.length ?? grid.rowItems.length + 1}">${rowItems}</rowItems>`;
|
|
20289
|
-
if (
|
|
20634
|
+
if (multiple && !rowsAxis)
|
|
20635
|
+
body += `<colFields count="${col >= 0 ? 2 : 1}">${col >= 0 ? `<field x="${col}"/>` : ""}<field x="-2"/></colFields>${pivotValueAxisItems(measures.length, col >= 0 ? grid.columnItems.length : void 0)}`;
|
|
20636
|
+
else if (col >= 0)
|
|
20290
20637
|
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length)}</colItems>`;
|
|
20291
|
-
else
|
|
20292
|
-
|
|
20638
|
+
else
|
|
20639
|
+
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
20640
|
+
body += `<dataFields count="${measures.length}">${measures.map((measure) => `<dataField${attrs({ name: encodeEscapes(measure.caption), fld: pivot.fields.indexOf(measure.field), subtotal: measure.aggregate, baseField: 0, baseItem: 0 })}/>`).join("")}</dataFields>`;
|
|
20293
20641
|
const doc = parseXml(
|
|
20294
20642
|
pivot.sourceXml ?? `<pivotTableDefinition xmlns="${NS.x}" dataCaption="Values" updatedVersion="6" minRefreshableVersion="3" createdVersion="6"><pivotTableStyleInfo name="PivotStyleLight16" showRowHeaders="1" showColHeaders="1" showRowStripes="0" showColStripes="0" showLastColumn="1"/></pivotTableDefinition>`
|
|
20295
20643
|
);
|
|
20296
20644
|
const root = doc.documentElement;
|
|
20297
20645
|
root.setAttribute("name", pivot.name);
|
|
20298
20646
|
root.setAttribute("cacheId", String(cacheId));
|
|
20647
|
+
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
20648
|
+
if (rowsAxis && (pivot.valuesPosition === "between" || pivot.valuesPosition === "first"))
|
|
20649
|
+
root.setAttribute("dataPosition", pivot.valuesPosition === "first" ? "0" : "1");
|
|
20650
|
+
else root.removeAttribute("dataPosition");
|
|
20299
20651
|
root.setAttribute("compact", compact ? "1" : "0");
|
|
20300
20652
|
root.setAttribute("compactData", compact ? "1" : "0");
|
|
20301
20653
|
root.setAttribute("outline", outline ? "1" : "0");
|
|
20302
20654
|
root.setAttribute("outlineData", outline ? "1" : "0");
|
|
20303
20655
|
if (compact) root.setAttribute("indent", "0");
|
|
20656
|
+
if (multiple && !elements(first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement).some(
|
|
20657
|
+
(extension) => first(
|
|
20658
|
+
extension,
|
|
20659
|
+
"pivotTableDefinition",
|
|
20660
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
20661
|
+
)
|
|
20662
|
+
)) {
|
|
20663
|
+
let list = first(root, "extLst", NS.x);
|
|
20664
|
+
if (!list) {
|
|
20665
|
+
list = doc.createElementNS(NS.x, "extLst");
|
|
20666
|
+
root.appendChild(list);
|
|
20667
|
+
}
|
|
20668
|
+
const extension = parseXml(
|
|
20669
|
+
`<ext xmlns="${NS.x}" uri="{962EF5D1-5CA2-4c93-8EF4-DBF5C05439D2}"><x14:pivotTableDefinition xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" hideValuesRow="1"/></ext>`
|
|
20670
|
+
).documentElement;
|
|
20671
|
+
list.appendChild(doc.importNode(extension, true));
|
|
20672
|
+
}
|
|
20304
20673
|
root.setAttribute("rowGrandTotals", "1");
|
|
20305
20674
|
root.setAttribute("colGrandTotals", "1");
|
|
20306
20675
|
for (const extension of elements(
|
|
@@ -20311,6 +20680,7 @@ function pivotTableXml(pivot, cacheId, cache2) {
|
|
|
20311
20680
|
"pivotTableDefinition",
|
|
20312
20681
|
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
20313
20682
|
);
|
|
20683
|
+
if (multiple && definition) definition.setAttribute("hideValuesRow", "1");
|
|
20314
20684
|
if (definition?.hasAttribute("fillDownLabelsDefault"))
|
|
20315
20685
|
definition.setAttribute("fillDownLabelsDefault", pivot.repeatLabels ? "1" : "0");
|
|
20316
20686
|
}
|
|
@@ -20336,6 +20706,8 @@ var init_table_xml = __esm({
|
|
|
20336
20706
|
init_xml_out();
|
|
20337
20707
|
init_aggregate();
|
|
20338
20708
|
init_data();
|
|
20709
|
+
init_measures();
|
|
20710
|
+
init_values_axis();
|
|
20339
20711
|
}
|
|
20340
20712
|
});
|
|
20341
20713
|
|