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
|
@@ -14200,6 +14200,25 @@ function validatePivotFields(pivot) {
|
|
|
14200
14200
|
...pivot.columnField ? [pivot.columnField] : [],
|
|
14201
14201
|
pivot.valueField
|
|
14202
14202
|
];
|
|
14203
|
+
const extras = pivot.additionalValues ?? [];
|
|
14204
|
+
if (pivot.valuesAxis !== void 0 && !["columns", "rows"].includes(pivot.valuesAxis))
|
|
14205
|
+
throw new Error("Choose a valid Values axis.");
|
|
14206
|
+
if (pivot.valuesPosition !== void 0 && !["last", "between", "first"].includes(pivot.valuesPosition))
|
|
14207
|
+
throw new Error("Choose a valid Values position.");
|
|
14208
|
+
if ((pivot.valuesPosition === "between" || pivot.valuesPosition === "first") && (pivot.valuesAxis !== "rows" || !pivot.secondRowField))
|
|
14209
|
+
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
14210
|
+
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
14211
|
+
throw new Error("Values on rows require multiple measures.");
|
|
14212
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== "Values")
|
|
14213
|
+
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
14214
|
+
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
14215
|
+
(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())
|
|
14216
|
+
) || new Set(
|
|
14217
|
+
[pivot.valueCaption, ...extras.map((measure2) => measure2.caption)].map(
|
|
14218
|
+
(caption) => caption?.toLowerCase()
|
|
14219
|
+
)
|
|
14220
|
+
).size !== extras.length + 1)
|
|
14221
|
+
throw new Error("Choose PivotTable value fields with valid aggregates and unique captions.");
|
|
14203
14222
|
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((field2) => !pivot.fields.includes(field2)) || 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")
|
|
14204
14223
|
throw new Error("Choose valid PivotTable fields; row and column fields must differ.");
|
|
14205
14224
|
}
|
|
@@ -14207,21 +14226,191 @@ function pivotCaption(aggregate3, field2) {
|
|
|
14207
14226
|
return `${aggregate3[0].toUpperCase()}${aggregate3.slice(1)} of ${field2}`;
|
|
14208
14227
|
}
|
|
14209
14228
|
|
|
14229
|
+
// xlsx/pivot/measures.ts
|
|
14230
|
+
var pivotMeasures = (pivot) => [
|
|
14231
|
+
{ field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
|
|
14232
|
+
...pivot.additionalValues ?? []
|
|
14233
|
+
];
|
|
14234
|
+
function normalizedPivotMeasures(values2) {
|
|
14235
|
+
if (!Array.isArray(values2) || values2.length > 15)
|
|
14236
|
+
throw new Error("Choose between one and sixteen PivotTable value fields.");
|
|
14237
|
+
return values2.map((value2) => {
|
|
14238
|
+
if (!value2 || typeof value2.field !== "string")
|
|
14239
|
+
throw new Error("Choose valid PivotTable value fields.");
|
|
14240
|
+
const aggregate3 = value2.aggregate ?? "sum";
|
|
14241
|
+
if (!PIVOT_AGGREGATES.includes(aggregate3))
|
|
14242
|
+
throw new Error("Choose a valid PivotTable aggregate.");
|
|
14243
|
+
return {
|
|
14244
|
+
field: value2.field,
|
|
14245
|
+
aggregate: aggregate3,
|
|
14246
|
+
caption: value2.caption ?? `${aggregate3[0].toUpperCase()}${aggregate3.slice(1)} of ${value2.field}`
|
|
14247
|
+
};
|
|
14248
|
+
});
|
|
14249
|
+
}
|
|
14250
|
+
function aggregate(records, field2, type) {
|
|
14251
|
+
if (!records.length) return null;
|
|
14252
|
+
const values2 = records.map((record2) => record2[field2] ?? null);
|
|
14253
|
+
if (type === "count") return values2.filter((value2) => value2 !== null && value2 !== "").length;
|
|
14254
|
+
const error = values2.find(isCellError);
|
|
14255
|
+
if (error) return error;
|
|
14256
|
+
const numbers3 = values2.filter((value2) => typeof value2 === "number");
|
|
14257
|
+
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
14258
|
+
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
14259
|
+
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
14260
|
+
const sum2 = numbers3.reduce((total2, value2) => total2 + value2, 0);
|
|
14261
|
+
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
14262
|
+
}
|
|
14263
|
+
var pivotMeasureNumber = (pivot, records, measure2) => aggregate(records, pivot.fields.indexOf(measure2.field), measure2.aggregate);
|
|
14264
|
+
var pivotNumbers = (pivot, records) => pivotMeasures(pivot).map((measure2) => pivotMeasureNumber(pivot, records, measure2));
|
|
14265
|
+
function pivotHeaderDimensions(pivot, columnItems, rowLabels) {
|
|
14266
|
+
const measures2 = 1 + (pivot.additionalValues?.length ?? 0);
|
|
14267
|
+
if (pivot.valuesAxis === "rows")
|
|
14268
|
+
return {
|
|
14269
|
+
rows: pivot.columnField ? 2 : 1,
|
|
14270
|
+
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
14271
|
+
};
|
|
14272
|
+
return {
|
|
14273
|
+
rows: pivot.columnField ? measures2 > 1 ? 3 : 2 : 1,
|
|
14274
|
+
width: rowLabels + (pivot.columnField ? measures2 === 1 ? Math.max(1, columnItems) + 1 : (columnItems + 1) * measures2 : measures2)
|
|
14275
|
+
};
|
|
14276
|
+
}
|
|
14277
|
+
function pivotHeaders(pivot, columns, labels, label3) {
|
|
14278
|
+
const measures2 = pivotMeasures(pivot);
|
|
14279
|
+
if (pivot.valuesAxis === "rows") {
|
|
14280
|
+
const rowLabels = pivot.layout === "compact" ? ["Row Labels"] : pivot.valuesPosition === "first" ? ["Values", ...labels] : pivot.valuesPosition === "between" ? [labels[0], "Values", labels[1]] : [...labels, "Values"];
|
|
14281
|
+
return pivot.columnField ? [
|
|
14282
|
+
[
|
|
14283
|
+
...rowLabels.map(() => null),
|
|
14284
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
14285
|
+
...columns.map(() => null)
|
|
14286
|
+
],
|
|
14287
|
+
[...rowLabels, ...columns.map(label3), "Grand Total"]
|
|
14288
|
+
] : [[...rowLabels, null]];
|
|
14289
|
+
}
|
|
14290
|
+
if (!pivot.columnField) return [[...labels, ...measures2.map((measure2) => measure2.caption)]];
|
|
14291
|
+
if (measures2.length === 1)
|
|
14292
|
+
return [
|
|
14293
|
+
[
|
|
14294
|
+
pivot.valueCaption,
|
|
14295
|
+
...labels.slice(1).map(() => null),
|
|
14296
|
+
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
14297
|
+
...columns.slice(1).map(() => null),
|
|
14298
|
+
null
|
|
14299
|
+
],
|
|
14300
|
+
[...labels, ...columns.map(label3), "Grand Total"]
|
|
14301
|
+
];
|
|
14302
|
+
const { width } = pivotHeaderDimensions(pivot, columns.length, labels.length);
|
|
14303
|
+
const first3 = Array(width).fill(null);
|
|
14304
|
+
first3[labels.length] = pivot.layout === "compact" ? "Column Labels" : pivot.columnField;
|
|
14305
|
+
if (pivot.layout !== "compact") first3[labels.length + 1] = "Values";
|
|
14306
|
+
return [
|
|
14307
|
+
first3,
|
|
14308
|
+
[
|
|
14309
|
+
...labels.map(() => null),
|
|
14310
|
+
...columns.flatMap((column) => [label3(column), ...measures2.slice(1).map(() => null)]),
|
|
14311
|
+
...measures2.map((measure2) => `Total ${measure2.caption}`)
|
|
14312
|
+
],
|
|
14313
|
+
[
|
|
14314
|
+
...labels,
|
|
14315
|
+
...columns.flatMap(() => measures2.map((measure2) => measure2.caption)),
|
|
14316
|
+
...measures2.map(() => null)
|
|
14317
|
+
]
|
|
14318
|
+
];
|
|
14319
|
+
}
|
|
14320
|
+
|
|
14321
|
+
// xlsx/pivot/hierarchy-first.ts
|
|
14322
|
+
function appendFirstPivotValues(pivot, context) {
|
|
14323
|
+
const {
|
|
14324
|
+
rowItems,
|
|
14325
|
+
secondRowItems,
|
|
14326
|
+
columnItems,
|
|
14327
|
+
children: children4,
|
|
14328
|
+
innerIndices,
|
|
14329
|
+
groups,
|
|
14330
|
+
details,
|
|
14331
|
+
buckets,
|
|
14332
|
+
width,
|
|
14333
|
+
rowLabels,
|
|
14334
|
+
top,
|
|
14335
|
+
bottom,
|
|
14336
|
+
append
|
|
14337
|
+
} = context;
|
|
14338
|
+
const compact3 = pivot.layout === "compact";
|
|
14339
|
+
const tabular = !pivot.layout || pivot.layout === "tabular";
|
|
14340
|
+
const blank = () => Array(width - rowLabels).fill(null);
|
|
14341
|
+
pivotMeasures(pivot).forEach((measure2, m) => {
|
|
14342
|
+
const numbers3 = (keys, records) => [
|
|
14343
|
+
...columnItems.map(
|
|
14344
|
+
(column) => pivotMeasureNumber(
|
|
14345
|
+
pivot,
|
|
14346
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
14347
|
+
measure2
|
|
14348
|
+
)
|
|
14349
|
+
),
|
|
14350
|
+
pivotMeasureNumber(pivot, records, measure2)
|
|
14351
|
+
];
|
|
14352
|
+
if (!tabular)
|
|
14353
|
+
append([measure2.caption, ...Array(rowLabels - 1).fill(null)], blank(), {
|
|
14354
|
+
indices: [m],
|
|
14355
|
+
measure: m
|
|
14356
|
+
});
|
|
14357
|
+
let first3 = true;
|
|
14358
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
14359
|
+
const key2 = pivotValueKey(outer);
|
|
14360
|
+
const group = groups.get(key2) ?? [];
|
|
14361
|
+
if (!tabular)
|
|
14362
|
+
append(
|
|
14363
|
+
compact3 ? [pivotItemLabel(outer)] : [null, pivotItemLabel(outer), null],
|
|
14364
|
+
top ? numbers3([key2], group) : blank(),
|
|
14365
|
+
{ indices: [m, outerIndex], measure: m },
|
|
14366
|
+
compact3 ? 1 : 0
|
|
14367
|
+
);
|
|
14368
|
+
const innerKeys = [...children4.get(key2)].sort(
|
|
14369
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
14370
|
+
);
|
|
14371
|
+
innerKeys.forEach((innerKey, child6) => {
|
|
14372
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
14373
|
+
append(
|
|
14374
|
+
compact3 ? [pivotItemLabel(secondRowItems[innerIndex])] : [
|
|
14375
|
+
tabular && first3 ? measure2.caption : null,
|
|
14376
|
+
pivot.repeatLabels || tabular && child6 === 0 ? pivotItemLabel(outer) : null,
|
|
14377
|
+
pivotItemLabel(secondRowItems[innerIndex])
|
|
14378
|
+
],
|
|
14379
|
+
numbers3([key2, innerKey], details.get(JSON.stringify([key2, innerKey]))),
|
|
14380
|
+
{ indices: [m, outerIndex, innerIndex], measure: m },
|
|
14381
|
+
compact3 ? 2 : 0
|
|
14382
|
+
);
|
|
14383
|
+
first3 = false;
|
|
14384
|
+
});
|
|
14385
|
+
if (bottom)
|
|
14386
|
+
append(
|
|
14387
|
+
compact3 ? [`${String(pivotItemLabel(outer))} Total`] : [null, `${String(pivotItemLabel(outer))} Total`, null],
|
|
14388
|
+
numbers3([key2], group),
|
|
14389
|
+
{ indices: [m, outerIndex], measure: m, type: "default" },
|
|
14390
|
+
compact3 ? 1 : 0
|
|
14391
|
+
);
|
|
14392
|
+
});
|
|
14393
|
+
});
|
|
14394
|
+
}
|
|
14395
|
+
|
|
14210
14396
|
// xlsx/pivot/hierarchy.ts
|
|
14211
14397
|
var label = pivotItemLabel;
|
|
14212
|
-
function hierarchicalPivotGrid(pivot
|
|
14398
|
+
function hierarchicalPivotGrid(pivot) {
|
|
14213
14399
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
14214
14400
|
const secondRowItems = pivotItems(pivot, pivot.secondRowField);
|
|
14215
14401
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
14216
14402
|
const outerField = pivot.fields.indexOf(pivot.rowField);
|
|
14217
14403
|
const innerField = pivot.fields.indexOf(pivot.secondRowField);
|
|
14218
14404
|
const columnField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
14219
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
14220
14405
|
const layout3 = pivot.layout ?? "tabular";
|
|
14221
14406
|
const compact3 = layout3 === "compact";
|
|
14222
|
-
const
|
|
14407
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
14408
|
+
const firstValues = rowsAxis && pivot.valuesPosition === "first";
|
|
14409
|
+
const between = rowsAxis && pivot.valuesPosition === "between";
|
|
14410
|
+
const measures2 = pivotMeasures(pivot);
|
|
14411
|
+
const top = (!rowsAxis || firstValues) && layout3 !== "tabular" && pivot.subtotals !== false && (pivot.subtotalPosition ?? "top") === "top";
|
|
14223
14412
|
const bottom = pivot.subtotals !== false && !top;
|
|
14224
|
-
const rowLabelColumns = compact3 ? 1 : 2;
|
|
14413
|
+
const rowLabelColumns = compact3 ? 1 : rowsAxis ? 3 : 2;
|
|
14225
14414
|
const groups = /* @__PURE__ */ new Map();
|
|
14226
14415
|
const details = /* @__PURE__ */ new Map();
|
|
14227
14416
|
const children4 = /* @__PURE__ */ new Map();
|
|
@@ -14245,20 +14434,12 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
14245
14434
|
collect(buckets, JSON.stringify([...key2, column]), record2);
|
|
14246
14435
|
}
|
|
14247
14436
|
}
|
|
14248
|
-
const
|
|
14249
|
-
|
|
14250
|
-
|
|
14437
|
+
const dimensions3 = pivotHeaderDimensions(pivot, columnItems.length, rowLabelColumns);
|
|
14438
|
+
const rows = (details.size + rowItems.length * Number(bottom) + 1) * (rowsAxis ? measures2.length : 1) + rowItems.length * Number(layout3 !== "tabular") * (firstValues ? measures2.length : 1) + (firstValues ? measures2.length : between ? rowItems.length * measures2.length : details.size) * Number(rowsAxis && layout3 !== "tabular") + dimensions3.rows;
|
|
14439
|
+
if (rows * dimensions3.width > 1e6) throw new Error("The PivotTable result is too large.");
|
|
14251
14440
|
const labels = compact3 ? ["Row Labels"] : [pivot.rowField, pivot.secondRowField];
|
|
14252
|
-
const values2 = pivot
|
|
14253
|
-
|
|
14254
|
-
pivot.valueCaption,
|
|
14255
|
-
...compact3 ? [] : [null],
|
|
14256
|
-
compact3 ? "Column Labels" : pivot.columnField,
|
|
14257
|
-
...columnItems.slice(1).map(() => null),
|
|
14258
|
-
null
|
|
14259
|
-
],
|
|
14260
|
-
[...labels, ...columnItems.map(label), "Grand Total"]
|
|
14261
|
-
] : [[...labels, pivot.valueCaption]];
|
|
14441
|
+
const values2 = pivotHeaders(pivot, columnItems, labels, label);
|
|
14442
|
+
const firstDataRow = values2.length;
|
|
14262
14443
|
const indents = values2.map(() => 0);
|
|
14263
14444
|
const rowEntries = [];
|
|
14264
14445
|
const append = (labels2, numbers4, entry3, indent = 0) => {
|
|
@@ -14266,91 +14447,184 @@ function hierarchicalPivotGrid(pivot, aggregate3) {
|
|
|
14266
14447
|
rowEntries.push(entry3);
|
|
14267
14448
|
indents.push(indent);
|
|
14268
14449
|
};
|
|
14269
|
-
const
|
|
14450
|
+
const bands = (keys, records) => [
|
|
14270
14451
|
...columnItems.map(
|
|
14271
|
-
(column) =>
|
|
14272
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
14273
|
-
valueField,
|
|
14274
|
-
pivot.aggregate
|
|
14275
|
-
)
|
|
14452
|
+
(column) => pivotNumbers(pivot, buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [])
|
|
14276
14453
|
),
|
|
14277
|
-
|
|
14454
|
+
pivotNumbers(pivot, records)
|
|
14278
14455
|
];
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
const records = details.get(JSON.stringify(keys));
|
|
14293
|
-
if (!records) return;
|
|
14294
|
-
append(
|
|
14295
|
-
compact3 ? [label(inner2)] : [
|
|
14296
|
-
pivot.repeatLabels || layout3 === "tabular" && first3 ? label(outer) : null,
|
|
14297
|
-
label(inner2)
|
|
14456
|
+
const numbers3 = (keys, records) => bands(keys, records).flat();
|
|
14457
|
+
const appendMeasures = (labels2, keys, records, indices, type) => {
|
|
14458
|
+
const values3 = bands(keys, records);
|
|
14459
|
+
measures2.forEach(
|
|
14460
|
+
(measure2, m) => append(
|
|
14461
|
+
type ? [
|
|
14462
|
+
`${type === "grand" ? "Total" : String(labels2[0])} ${measure2.caption}`,
|
|
14463
|
+
...Array(rowLabelColumns - 1).fill(null)
|
|
14464
|
+
] : compact3 ? [measure2.caption] : [
|
|
14465
|
+
...labels2.map(
|
|
14466
|
+
(label3) => layout3 === "tabular" && m === 0 || pivot.repeatLabels ? label3 : null
|
|
14467
|
+
),
|
|
14468
|
+
measure2.caption
|
|
14298
14469
|
],
|
|
14299
|
-
|
|
14300
|
-
{ indices: [
|
|
14301
|
-
compact3 ?
|
|
14302
|
-
)
|
|
14303
|
-
|
|
14470
|
+
values3.map((band2) => band2[m] ?? null),
|
|
14471
|
+
{ indices: type ? indices : [...indices, m], measure: m, ...type ? { type } : {} },
|
|
14472
|
+
compact3 && !type ? 2 : 0
|
|
14473
|
+
)
|
|
14474
|
+
);
|
|
14475
|
+
};
|
|
14476
|
+
if (firstValues)
|
|
14477
|
+
appendFirstPivotValues(pivot, {
|
|
14478
|
+
rowItems,
|
|
14479
|
+
secondRowItems,
|
|
14480
|
+
columnItems,
|
|
14481
|
+
children: children4,
|
|
14482
|
+
innerIndices,
|
|
14483
|
+
groups,
|
|
14484
|
+
details,
|
|
14485
|
+
buckets,
|
|
14486
|
+
width: dimensions3.width,
|
|
14487
|
+
rowLabels: rowLabelColumns,
|
|
14488
|
+
top,
|
|
14489
|
+
bottom,
|
|
14490
|
+
append
|
|
14304
14491
|
});
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
|
|
14492
|
+
else
|
|
14493
|
+
rowItems.forEach((outer, outerIndex) => {
|
|
14494
|
+
const key2 = pivotValueKey(outer);
|
|
14495
|
+
if (layout3 !== "tabular")
|
|
14496
|
+
append(
|
|
14497
|
+
[label(outer), ...Array(rowLabelColumns - 1).fill(null)],
|
|
14498
|
+
top ? numbers3([key2], groups.get(key2) ?? []) : Array(dimensions3.width - rowLabelColumns).fill(null),
|
|
14499
|
+
{ indices: [outerIndex] }
|
|
14500
|
+
);
|
|
14501
|
+
let first3 = true;
|
|
14502
|
+
const innerKeys = [...children4.get(key2)].sort(
|
|
14503
|
+
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
14311
14504
|
);
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
|
|
14505
|
+
if (between)
|
|
14506
|
+
measures2.forEach((measure2, m) => {
|
|
14507
|
+
if (layout3 !== "tabular")
|
|
14508
|
+
append(
|
|
14509
|
+
compact3 ? [measure2.caption] : [pivot.repeatLabels ? label(outer) : null, measure2.caption, null],
|
|
14510
|
+
Array(dimensions3.width - rowLabelColumns).fill(null),
|
|
14511
|
+
{ indices: [outerIndex, m], measure: m },
|
|
14512
|
+
compact3 ? 1 : 0
|
|
14513
|
+
);
|
|
14514
|
+
innerKeys.forEach((innerKey, child6) => {
|
|
14515
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
14516
|
+
const keys = [key2, innerKey];
|
|
14517
|
+
const records = details.get(JSON.stringify(keys));
|
|
14518
|
+
append(
|
|
14519
|
+
compact3 ? [label(secondRowItems[innerIndex])] : [
|
|
14520
|
+
pivot.repeatLabels || layout3 === "tabular" && m === 0 && child6 === 0 ? label(outer) : null,
|
|
14521
|
+
layout3 === "tabular" && child6 === 0 ? measure2.caption : null,
|
|
14522
|
+
label(secondRowItems[innerIndex])
|
|
14523
|
+
],
|
|
14524
|
+
[
|
|
14525
|
+
...columnItems.map(
|
|
14526
|
+
(column) => pivotMeasureNumber(
|
|
14527
|
+
pivot,
|
|
14528
|
+
buckets.get(JSON.stringify([...keys, pivotValueKey(column)])) ?? [],
|
|
14529
|
+
measure2
|
|
14530
|
+
)
|
|
14531
|
+
),
|
|
14532
|
+
pivotMeasureNumber(pivot, records, measure2)
|
|
14533
|
+
],
|
|
14534
|
+
{ indices: [outerIndex, m, innerIndex], measure: m },
|
|
14535
|
+
compact3 ? 2 : 0
|
|
14536
|
+
);
|
|
14537
|
+
});
|
|
14538
|
+
});
|
|
14539
|
+
else
|
|
14540
|
+
innerKeys.forEach((innerKey) => {
|
|
14541
|
+
const innerIndex = innerIndices.get(innerKey);
|
|
14542
|
+
const inner2 = secondRowItems[innerIndex];
|
|
14543
|
+
const keys = [key2, innerKey];
|
|
14544
|
+
const records = details.get(JSON.stringify(keys));
|
|
14545
|
+
if (!records) return;
|
|
14546
|
+
if (rowsAxis) {
|
|
14547
|
+
if (layout3 !== "tabular")
|
|
14548
|
+
append(
|
|
14549
|
+
compact3 ? [label(inner2)] : [pivot.repeatLabels ? label(outer) : null, label(inner2), null],
|
|
14550
|
+
Array(dimensions3.width - rowLabelColumns).fill(null),
|
|
14551
|
+
{ indices: [outerIndex, innerIndex] },
|
|
14552
|
+
compact3 ? 1 : 0
|
|
14553
|
+
);
|
|
14554
|
+
appendMeasures(
|
|
14555
|
+
[pivot.repeatLabels || first3 ? label(outer) : null, label(inner2)],
|
|
14556
|
+
keys,
|
|
14557
|
+
records,
|
|
14558
|
+
[outerIndex, innerIndex]
|
|
14559
|
+
);
|
|
14560
|
+
first3 = false;
|
|
14561
|
+
return;
|
|
14562
|
+
}
|
|
14563
|
+
append(
|
|
14564
|
+
compact3 ? [label(inner2)] : [
|
|
14565
|
+
pivot.repeatLabels || layout3 === "tabular" && first3 ? label(outer) : null,
|
|
14566
|
+
label(inner2)
|
|
14567
|
+
],
|
|
14568
|
+
numbers3(keys, records),
|
|
14569
|
+
{ indices: [outerIndex, innerIndex] },
|
|
14570
|
+
compact3 ? 1 : 0
|
|
14571
|
+
);
|
|
14572
|
+
first3 = false;
|
|
14573
|
+
});
|
|
14574
|
+
if (bottom) {
|
|
14575
|
+
if (rowsAxis) {
|
|
14576
|
+
appendMeasures([label(outer)], [key2], groups.get(key2) ?? [], [outerIndex], "default");
|
|
14577
|
+
return;
|
|
14578
|
+
}
|
|
14579
|
+
const caption = String(label(outer));
|
|
14580
|
+
append(
|
|
14581
|
+
[`${caption} Total`, ...compact3 ? [] : [null]],
|
|
14582
|
+
numbers3([key2], groups.get(key2) ?? []),
|
|
14583
|
+
{ indices: [outerIndex], type: "default" }
|
|
14584
|
+
);
|
|
14585
|
+
}
|
|
14586
|
+
});
|
|
14587
|
+
if (rowsAxis) appendMeasures([], [], pivot.records, [0], "grand");
|
|
14588
|
+
else
|
|
14589
|
+
append(["Grand Total", ...compact3 ? [] : [null]], numbers3([], pivot.records), {
|
|
14590
|
+
indices: [0],
|
|
14591
|
+
type: "grand"
|
|
14592
|
+
});
|
|
14318
14593
|
return {
|
|
14319
14594
|
values: values2,
|
|
14320
14595
|
rowItems,
|
|
14321
14596
|
secondRowItems,
|
|
14322
14597
|
columnItems,
|
|
14323
14598
|
rowEntries,
|
|
14324
|
-
firstDataRow
|
|
14599
|
+
firstDataRow,
|
|
14325
14600
|
rowLabelColumns,
|
|
14326
|
-
indents
|
|
14601
|
+
indents,
|
|
14602
|
+
...rowsAxis ? { firstHeaderRow: 1 } : {}
|
|
14327
14603
|
};
|
|
14328
14604
|
}
|
|
14329
14605
|
|
|
14330
14606
|
// xlsx/pivot/aggregate.ts
|
|
14331
|
-
function aggregate(records, field2, type) {
|
|
14332
|
-
if (!records.length) return null;
|
|
14333
|
-
const values2 = records.map((record2) => record2[field2] ?? null);
|
|
14334
|
-
if (type === "count") return values2.filter((value2) => value2 !== null && value2 !== "").length;
|
|
14335
|
-
const error = values2.find(isCellError);
|
|
14336
|
-
if (error) return error;
|
|
14337
|
-
const numbers3 = values2.filter((value2) => typeof value2 === "number");
|
|
14338
|
-
if (!numbers3.length) return type === "average" ? { error: "#DIV/0!" } : 0;
|
|
14339
|
-
if (type === "min") return numbers3.reduce((a2, b) => Math.min(a2, b));
|
|
14340
|
-
if (type === "max") return numbers3.reduce((a2, b) => Math.max(a2, b));
|
|
14341
|
-
const sum2 = numbers3.reduce((total2, value2) => total2 + value2, 0);
|
|
14342
|
-
return type === "average" ? sum2 / numbers3.length : sum2;
|
|
14343
|
-
}
|
|
14344
14607
|
function pivotGrid(pivot) {
|
|
14345
14608
|
validatePivotFields(pivot);
|
|
14346
|
-
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot
|
|
14609
|
+
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
14347
14610
|
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
14348
14611
|
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
14349
|
-
|
|
14612
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
14613
|
+
const compact3 = pivot.layout === "compact";
|
|
14614
|
+
const headings = rowsAxis && pivot.layout !== void 0 && pivot.layout !== "tabular";
|
|
14615
|
+
const dimensions3 = pivotHeaderDimensions(pivot, columnItems.length, rowsAxis && !compact3 ? 2 : 1);
|
|
14616
|
+
const dataRows = (rowItems.length + 1) * (rowsAxis ? 1 + (pivot.additionalValues?.length ?? 0) : 1) + (headings ? rowItems.length : 0);
|
|
14617
|
+
if ((dataRows + dimensions3.rows) * dimensions3.width > 1e6)
|
|
14350
14618
|
throw new Error("The PivotTable result is too large.");
|
|
14619
|
+
const label3 = pivotItemLabel;
|
|
14620
|
+
const values2 = pivotHeaders(
|
|
14621
|
+
pivot,
|
|
14622
|
+
columnItems,
|
|
14623
|
+
[pivot.layout === "compact" ? "Row Labels" : pivot.rowField],
|
|
14624
|
+
label3
|
|
14625
|
+
);
|
|
14351
14626
|
const rowField = pivot.fields.indexOf(pivot.rowField);
|
|
14352
14627
|
const colField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
14353
|
-
const valueField = pivot.fields.indexOf(pivot.valueField);
|
|
14354
14628
|
const groups = /* @__PURE__ */ new Map();
|
|
14355
14629
|
const cells3 = /* @__PURE__ */ new Map();
|
|
14356
14630
|
const columns = /* @__PURE__ */ new Map();
|
|
@@ -14368,49 +14642,92 @@ function pivotGrid(pivot) {
|
|
|
14368
14642
|
collect(cells3, JSON.stringify([key2, col]), record2);
|
|
14369
14643
|
}
|
|
14370
14644
|
}
|
|
14371
|
-
const
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
|
|
14381
|
-
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
14645
|
+
const firstDataRow = values2.length;
|
|
14646
|
+
if (rowsAxis) {
|
|
14647
|
+
const measures2 = pivotMeasures(pivot);
|
|
14648
|
+
const rowEntries = [];
|
|
14649
|
+
const indents = values2.map(() => 0);
|
|
14650
|
+
const append = (caption, bands, index2, grand = false) => {
|
|
14651
|
+
measures2.forEach((measure2, m) => {
|
|
14652
|
+
values2.push([
|
|
14653
|
+
...compact3 ? [grand ? `Total ${measure2.caption}` : measure2.caption] : [
|
|
14654
|
+
grand ? `Total ${measure2.caption}` : pivot.repeatLabels || !headings && m === 0 ? caption : null,
|
|
14655
|
+
grand ? null : measure2.caption
|
|
14656
|
+
],
|
|
14657
|
+
...bands.map((band2) => band2[m] ?? null)
|
|
14658
|
+
]);
|
|
14659
|
+
indents.push(compact3 && !grand ? 1 : 0);
|
|
14660
|
+
rowEntries.push({
|
|
14661
|
+
indices: grand ? [0] : [index2, m],
|
|
14662
|
+
measure: m,
|
|
14663
|
+
...grand ? { type: "grand" } : {}
|
|
14664
|
+
});
|
|
14665
|
+
});
|
|
14666
|
+
};
|
|
14667
|
+
rowItems.forEach((item, index2) => {
|
|
14668
|
+
const key2 = pivotValueKey(item);
|
|
14669
|
+
if (headings) {
|
|
14670
|
+
values2.push([label3(item), ...Array(dimensions3.width - 1).fill(null)]);
|
|
14671
|
+
rowEntries.push({ indices: [index2] });
|
|
14672
|
+
indents.push(0);
|
|
14673
|
+
}
|
|
14674
|
+
append(
|
|
14675
|
+
label3(item),
|
|
14676
|
+
[
|
|
14677
|
+
...columnItems.map(
|
|
14678
|
+
(col) => pivotNumbers(pivot, cells3.get(JSON.stringify([key2, pivotValueKey(col)])) ?? [])
|
|
14679
|
+
),
|
|
14680
|
+
pivotNumbers(pivot, groups.get(key2) ?? [])
|
|
14681
|
+
],
|
|
14682
|
+
index2
|
|
14683
|
+
);
|
|
14684
|
+
});
|
|
14685
|
+
append(
|
|
14686
|
+
"Grand Total",
|
|
14687
|
+
[
|
|
14688
|
+
...columnItems.map((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
14689
|
+
pivotNumbers(pivot, pivot.records)
|
|
14690
|
+
],
|
|
14691
|
+
0,
|
|
14692
|
+
true
|
|
14693
|
+
);
|
|
14694
|
+
return {
|
|
14695
|
+
values: values2,
|
|
14696
|
+
rowItems,
|
|
14697
|
+
columnItems,
|
|
14698
|
+
firstDataRow,
|
|
14699
|
+
rowLabelColumns: compact3 ? 1 : 2,
|
|
14700
|
+
indents,
|
|
14701
|
+
firstHeaderRow: 1,
|
|
14702
|
+
rowEntries
|
|
14703
|
+
};
|
|
14704
|
+
}
|
|
14385
14705
|
for (const row3 of rowItems) {
|
|
14386
14706
|
const records = groups.get(pivotValueKey(row3)) ?? [];
|
|
14387
14707
|
values2.push([
|
|
14388
14708
|
label3(row3),
|
|
14389
|
-
...columnItems.
|
|
14390
|
-
(col) =>
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
pivot.aggregate
|
|
14709
|
+
...columnItems.flatMap(
|
|
14710
|
+
(col) => pivotNumbers(
|
|
14711
|
+
pivot,
|
|
14712
|
+
cells3.get(JSON.stringify([pivotValueKey(row3), pivotValueKey(col)])) ?? []
|
|
14394
14713
|
)
|
|
14395
14714
|
),
|
|
14396
|
-
|
|
14715
|
+
...pivotNumbers(pivot, records)
|
|
14397
14716
|
]);
|
|
14398
14717
|
}
|
|
14399
14718
|
values2.push([
|
|
14400
14719
|
"Grand Total",
|
|
14401
|
-
...columnItems.
|
|
14402
|
-
|
|
14403
|
-
),
|
|
14404
|
-
aggregate(pivot.records, valueField, pivot.aggregate)
|
|
14720
|
+
...columnItems.flatMap((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
14721
|
+
...pivotNumbers(pivot, pivot.records)
|
|
14405
14722
|
]);
|
|
14406
|
-
return { values: values2, rowItems, columnItems, firstDataRow
|
|
14723
|
+
return { values: values2, rowItems, columnItems, firstDataRow };
|
|
14407
14724
|
}
|
|
14408
14725
|
|
|
14409
14726
|
// xlsx/pivot/admission.ts
|
|
14410
14727
|
var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
|
14411
14728
|
var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
|
|
14412
14729
|
var TABLE = {
|
|
14413
|
-
pivotTableDefinition: "name cacheId dataCaption updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
|
|
14730
|
+
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",
|
|
14414
14731
|
location: "ref firstHeaderRow firstDataRow firstDataCol",
|
|
14415
14732
|
pivotFields: "count",
|
|
14416
14733
|
pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal",
|
|
@@ -14421,7 +14738,7 @@ var TABLE = {
|
|
|
14421
14738
|
field: "x",
|
|
14422
14739
|
rowItems: "count",
|
|
14423
14740
|
colItems: "count",
|
|
14424
|
-
i: "t r",
|
|
14741
|
+
i: "t r i",
|
|
14425
14742
|
x: "v",
|
|
14426
14743
|
dataFields: "count",
|
|
14427
14744
|
dataField: "name fld subtotal baseField baseItem showDataAs",
|
|
@@ -14452,7 +14769,7 @@ function inspect(node2, profile, cache3) {
|
|
|
14452
14769
|
for (let i2 = 0; i2 < node2.attributes.length; i2++) {
|
|
14453
14770
|
const attr3 = node2.attributes.item(i2);
|
|
14454
14771
|
if (attr3.name.startsWith("xmlns")) continue;
|
|
14455
|
-
if (!cache3 && node2.namespaceURI === X14 && node2.localName === "pivotTableDefinition" && attr3.name === "hideValuesRow" &&
|
|
14772
|
+
if (!cache3 && node2.namespaceURI === X14 && node2.localName === "pivotTableDefinition" && attr3.name === "hideValuesRow" && ["0", "1"].includes(attr3.value))
|
|
14456
14773
|
continue;
|
|
14457
14774
|
if (!cache3 && node2.namespaceURI === X14 && (node2.localName === "pivotField" && attr3.name === "fillDownLabels" || node2.localName === "pivotTableDefinition" && attr3.name === "fillDownLabelsDefault") && ["0", "1"].includes(attr3.value))
|
|
14458
14775
|
continue;
|
|
@@ -14481,7 +14798,9 @@ function inspect(node2, profile, cache3) {
|
|
|
14481
14798
|
throw new Error("Unsupported PivotTable option");
|
|
14482
14799
|
if (attr3.localName === "numFmtId" && attr3.value !== "0")
|
|
14483
14800
|
throw new Error("Unsupported PivotTable field number format");
|
|
14484
|
-
if (node2.localName === "pivotTableDefinition" && ["compact", "compactData", "outline", "outlineData"
|
|
14801
|
+
if (node2.localName === "pivotTableDefinition" && ["compact", "compactData", "outline", "outlineData", "dataOnRows"].includes(
|
|
14802
|
+
attr3.localName
|
|
14803
|
+
) && !["0", "1"].includes(attr3.value))
|
|
14485
14804
|
throw new Error("Unsupported PivotTable global layout");
|
|
14486
14805
|
if (node2.localName === "item" && attr3.localName === "t" && !["default", "data"].includes(attr3.value))
|
|
14487
14806
|
throw new Error("Unsupported PivotTable subtotal");
|
|
@@ -14504,6 +14823,88 @@ function assertPivotRecords(records) {
|
|
|
14504
14823
|
);
|
|
14505
14824
|
}
|
|
14506
14825
|
|
|
14826
|
+
// xlsx/write/xml-out.ts
|
|
14827
|
+
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
14828
|
+
var CONTROL2 = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
14829
|
+
var NEEDS_ESCAPE = new RegExp(`[${CONTROL2}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
14830
|
+
var ESCAPABLE = new RegExp(`[${CONTROL2}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
14831
|
+
function encodeEscapes(text6) {
|
|
14832
|
+
if (!NEEDS_ESCAPE.test(text6)) return text6;
|
|
14833
|
+
return text6.replace(
|
|
14834
|
+
ESCAPABLE,
|
|
14835
|
+
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
14836
|
+
);
|
|
14837
|
+
}
|
|
14838
|
+
var INVALID_XML2 = new RegExp(`[${CONTROL2}]`, "g");
|
|
14839
|
+
var escapeText3 = (text6) => text6.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
14840
|
+
var escapeAttr3 = (text6) => text6.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
14841
|
+
function attrs(values2) {
|
|
14842
|
+
let out = "";
|
|
14843
|
+
for (const [name3, value2] of Object.entries(values2)) {
|
|
14844
|
+
if (value2 === void 0) continue;
|
|
14845
|
+
const text6 = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num(value2) : value2;
|
|
14846
|
+
out += ` ${name3}="${escapeAttr3(text6)}"`;
|
|
14847
|
+
}
|
|
14848
|
+
return out;
|
|
14849
|
+
}
|
|
14850
|
+
var el3 = (name3, values2 = {}, content2 = "") => content2 ? `<${name3}${attrs(values2)}>${content2}</${name3}>` : `<${name3}${attrs(values2)}/>`;
|
|
14851
|
+
var num = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
14852
|
+
function tElement(text6, name3 = "t") {
|
|
14853
|
+
const encoded = escapeText3(encodeEscapes(text6));
|
|
14854
|
+
const preserve = /^\s|\s$|\n|\t/.test(text6) ? ' xml:space="preserve"' : "";
|
|
14855
|
+
return `<${name3}${preserve}>${encoded}</${name3}>`;
|
|
14856
|
+
}
|
|
14857
|
+
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
14858
|
+
function inlineFragment(xml) {
|
|
14859
|
+
const end = xml.indexOf(">");
|
|
14860
|
+
if (end < 0) return xml;
|
|
14861
|
+
const head = xml.slice(0, end);
|
|
14862
|
+
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
14863
|
+
}
|
|
14864
|
+
|
|
14865
|
+
// xlsx/pivot/values-axis.ts
|
|
14866
|
+
function pivotFieldIndex(field2) {
|
|
14867
|
+
const raw2 = field2?.getAttribute("x");
|
|
14868
|
+
if (raw2 === null || raw2 === void 0 || !/^-?\d+$/.test(raw2.trim())) return NaN;
|
|
14869
|
+
const value2 = Number(raw2);
|
|
14870
|
+
return Number.isSafeInteger(value2) ? value2 : NaN;
|
|
14871
|
+
}
|
|
14872
|
+
function pivotValueIndex(root, axis) {
|
|
14873
|
+
const index2 = axis.findIndex((field2) => pivotFieldIndex(field2) === -2);
|
|
14874
|
+
const position = root.getAttribute("dataPosition");
|
|
14875
|
+
if (position !== null && (!/^\d+$/.test(position.trim()) || Number(position) !== index2))
|
|
14876
|
+
throw new Error("Inconsistent Values axis position");
|
|
14877
|
+
if (axis.length === 3 && index2 < 2 && position === null)
|
|
14878
|
+
throw new Error("Missing leading or between-field Values position");
|
|
14879
|
+
return index2;
|
|
14880
|
+
}
|
|
14881
|
+
function pivotValueAxisItems(measures2, columns) {
|
|
14882
|
+
const entries = [];
|
|
14883
|
+
if (columns === void 0) {
|
|
14884
|
+
for (let measure2 = 0; measure2 < measures2; measure2++)
|
|
14885
|
+
entries.push(
|
|
14886
|
+
`<i${attrs({ i: measure2 || void 0 })}><x${attrs({ v: measure2 || void 0 })}/></i>`
|
|
14887
|
+
);
|
|
14888
|
+
} else {
|
|
14889
|
+
for (let column = 0; column < columns; column++)
|
|
14890
|
+
for (let measure2 = 0; measure2 < measures2; measure2++) {
|
|
14891
|
+
entries.push(
|
|
14892
|
+
`<i${attrs({ r: measure2 ? 1 : void 0, i: measure2 || void 0 })}>${measure2 ? "" : `<x${attrs({ v: column || void 0 })}/>`}<x${attrs({ v: measure2 || void 0 })}/></i>`
|
|
14893
|
+
);
|
|
14894
|
+
}
|
|
14895
|
+
for (let measure2 = 0; measure2 < measures2; measure2++)
|
|
14896
|
+
entries.push(`<i${attrs({ t: "grand", i: measure2 || void 0 })}><x/></i>`);
|
|
14897
|
+
}
|
|
14898
|
+
return `<colItems count="${entries.length}">${entries.join("")}</colItems>`;
|
|
14899
|
+
}
|
|
14900
|
+
function supportedPivotAxes(rows, columns, measures2, valuesOnRows) {
|
|
14901
|
+
const index2 = pivotFieldIndex;
|
|
14902
|
+
if (valuesOnRows)
|
|
14903
|
+
return measures2 > 1 && (rows.length === 2 || rows.length === 3) && (index2(rows[0]) >= 0 || rows.length === 3) && rows.filter((field2) => index2(field2) === -2).length === 1 && rows.filter((field2) => index2(field2) !== -2).every((field2) => index2(field2) >= 0) && columns.length <= 1 && (!columns.length || index2(columns[0]) >= 0);
|
|
14904
|
+
if (rows.some((field2) => !Number.isInteger(index2(field2)) || index2(field2) < 0)) return false;
|
|
14905
|
+
return measures2 === 1 ? columns.length <= 1 : columns.length >= 1 && columns.length <= 2 && index2(columns.at(-1)) === -2 && (columns.length !== 2 || index2(columns[0]) >= 0);
|
|
14906
|
+
}
|
|
14907
|
+
|
|
14507
14908
|
// xlsx/pivot/read.ts
|
|
14508
14909
|
function value(node2) {
|
|
14509
14910
|
const v = att(node2, "v") ?? "";
|
|
@@ -14538,6 +14939,7 @@ function readOne(workbook, source2, part) {
|
|
|
14538
14939
|
const dataSheet = sourceNode && att(sourceNode, "sheet");
|
|
14539
14940
|
const dataRange = sourceNode && parseRange(att(sourceNode, "ref") ?? "");
|
|
14540
14941
|
const recordPart = source2.targetOfType(cachePart, `${NS.r}/pivotCacheRecords`);
|
|
14942
|
+
const rowsAxis = att(root, "dataOnRows") === "1";
|
|
14541
14943
|
if (!dataSheet || !dataRange || !recordPart || !workbook.sheets.some((sheet) => sheet.name === dataSheet))
|
|
14542
14944
|
throw new Error("Unsupported pivot source");
|
|
14543
14945
|
assertPivotRecords(parseXml(source2.text(recordPart)).documentElement);
|
|
@@ -14573,17 +14975,42 @@ function readOne(workbook, source2, part) {
|
|
|
14573
14975
|
"dataField",
|
|
14574
14976
|
NS.x
|
|
14575
14977
|
);
|
|
14576
|
-
if (rowFields.length < 1 || rowFields.length > 2 ||
|
|
14978
|
+
if (rowFields.length < 1 || rowFields.length > (rowsAxis ? 3 : 2) || dataFields.length < 1 || dataFields.length > 16 || !supportedPivotAxes(rowFields, colFields, dataFields.length, rowsAxis) || first(root, "pageFields", NS.x) || first(root, "filters", NS.x) || root.getAttribute("rowGrandTotals") === "0" || root.getAttribute("colGrandTotals") === "0")
|
|
14577
14979
|
throw new Error("Unsupported pivot layout");
|
|
14980
|
+
const valueIndex = pivotValueIndex(root, rowsAxis ? rowFields : colFields);
|
|
14578
14981
|
const measure2 = dataFields[0];
|
|
14982
|
+
const definition = elements(first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement).map(
|
|
14983
|
+
(extension2) => first(
|
|
14984
|
+
extension2,
|
|
14985
|
+
"pivotTableDefinition",
|
|
14986
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
14987
|
+
)
|
|
14988
|
+
).find(Boolean);
|
|
14989
|
+
if (dataFields.length > 1 && att(definition, "hideValuesRow") !== "1")
|
|
14990
|
+
throw new Error("Visible Values header rows are preserved");
|
|
14991
|
+
for (const [axis, count2] of [
|
|
14992
|
+
["rowItems", rowsAxis ? dataFields.length : 1],
|
|
14993
|
+
["colItems", rowsAxis ? 1 : dataFields.length]
|
|
14994
|
+
]) {
|
|
14995
|
+
for (const item of children(
|
|
14996
|
+
first(root, axis, NS.x) ?? parseXml("<root/>").documentElement,
|
|
14997
|
+
"i",
|
|
14998
|
+
NS.x
|
|
14999
|
+
)) {
|
|
15000
|
+
const index2 = Number(att(item, "i") ?? "0");
|
|
15001
|
+
if (!Number.isInteger(index2) || index2 < 0 || index2 >= count2)
|
|
15002
|
+
throw new Error("Unsupported Values axis item");
|
|
15003
|
+
}
|
|
15004
|
+
}
|
|
14579
15005
|
const aggregate3 = att(measure2, "subtotal") ?? "sum";
|
|
14580
15006
|
if (!PIVOT_AGGREGATES.includes(aggregate3) || att(measure2, "showDataAs") && att(measure2, "showDataAs") !== "normal")
|
|
14581
15007
|
throw new Error("Unsupported pivot aggregate");
|
|
14582
15008
|
const names = fields.map((field2) => decodeEscapes(att(field2, "name") ?? ""));
|
|
14583
|
-
const
|
|
14584
|
-
const
|
|
15009
|
+
const realRows = rowsAxis ? rowFields.filter((field2) => pivotFieldIndex(field2) !== -2) : rowFields;
|
|
15010
|
+
const row3 = names[pivotFieldIndex(realRows[0])];
|
|
15011
|
+
const second = realRows[1] ? names[Number(att(realRows[1], "x"))] : void 0;
|
|
14585
15012
|
const tableFields = children(first(root, "pivotFields", NS.x), "pivotField", NS.x);
|
|
14586
|
-
const outer = tableFields[
|
|
15013
|
+
const outer = tableFields[pivotFieldIndex(realRows[0])];
|
|
14587
15014
|
const compact3 = att(outer, "compact") !== "0";
|
|
14588
15015
|
const outline2 = att(outer, "outline") !== "0";
|
|
14589
15016
|
const layout3 = compact3 ? "compact" : outline2 ? "outline" : "tabular";
|
|
@@ -14592,7 +15019,7 @@ function readOne(workbook, source2, part) {
|
|
|
14592
15019
|
) || att(root, "compact") !== "0" !== compact3 || att(root, "compactData") !== "0" !== compact3 || att(root, "outline") === "1" !== outline2 || att(root, "outlineData") === "1" !== outline2 || layout3 === "compact" && att(root, "indent") !== "0")
|
|
14593
15020
|
throw new Error("Mixed field layouts or custom compact indentation are preserved");
|
|
14594
15021
|
const subtotal = att(outer, "defaultSubtotal") !== "0";
|
|
14595
|
-
const repeat =
|
|
15022
|
+
const repeat = realRows.map((field2) => {
|
|
14596
15023
|
const node2 = tableFields[Number(att(field2, "x"))];
|
|
14597
15024
|
const extension2 = first(first(node2, "extLst", NS.x), "ext", NS.x);
|
|
14598
15025
|
return att(
|
|
@@ -14605,16 +15032,19 @@ function readOne(workbook, source2, part) {
|
|
|
14605
15032
|
) === "1";
|
|
14606
15033
|
});
|
|
14607
15034
|
if (repeat.some((entry4) => entry4 !== repeat[0])) throw new Error("Mixed field label repetition");
|
|
14608
|
-
const
|
|
15035
|
+
const hasColumn = colFields.length > (dataFields.length > 1 && !rowsAxis ? 1 : 0);
|
|
15036
|
+
const col = hasColumn ? names[Number(att(colFields[0], "x"))] : void 0;
|
|
14609
15037
|
const data = names[Number(att(measure2, "fld"))];
|
|
14610
15038
|
const location = parseRange(att(first(root, "location", NS.x), "ref") ?? "");
|
|
14611
|
-
if (!row3 || !data || !location ||
|
|
15039
|
+
if (!row3 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
|
|
14612
15040
|
throw new Error("Invalid pivot fields");
|
|
14613
15041
|
const pivot = {
|
|
14614
15042
|
name: att(root, "name") ?? "PivotTable",
|
|
14615
15043
|
source: `${quoteSheetName(dataSheet)}!${formatRange(dataRange)}`,
|
|
14616
15044
|
rowField: row3,
|
|
14617
15045
|
layout: layout3,
|
|
15046
|
+
...rowsAxis ? { valuesAxis: "rows" } : {},
|
|
15047
|
+
...rowsAxis && realRows.length === 2 && valueIndex < 2 ? { valuesPosition: valueIndex === 0 ? "first" : "between" } : {},
|
|
14618
15048
|
subtotalPosition: att(outer, "subtotalTop") === "0" ? "bottom" : "top",
|
|
14619
15049
|
...second ? { secondRowField: second, subtotals: subtotal, repeatLabels: repeat[0] ?? false } : {
|
|
14620
15050
|
...subtotal ? {} : { subtotals: false },
|
|
@@ -14623,6 +15053,15 @@ function readOne(workbook, source2, part) {
|
|
|
14623
15053
|
valueField: data,
|
|
14624
15054
|
aggregate: aggregate3,
|
|
14625
15055
|
valueCaption: decodeEscapes(att(measure2, "name") ?? data),
|
|
15056
|
+
...dataFields.length > 1 ? {
|
|
15057
|
+
additionalValues: dataFields.slice(1).map((measure3) => {
|
|
15058
|
+
const field2 = names[Number(att(measure3, "fld"))];
|
|
15059
|
+
const aggregate4 = att(measure3, "subtotal") ?? "sum";
|
|
15060
|
+
if (!field2 || !PIVOT_AGGREGATES.includes(aggregate4) || att(measure3, "showDataAs") && att(measure3, "showDataAs") !== "normal")
|
|
15061
|
+
throw new Error("Unsupported pivot measure");
|
|
15062
|
+
return { field: field2, aggregate: aggregate4, caption: decodeEscapes(att(measure3, "name") ?? field2) };
|
|
15063
|
+
})
|
|
15064
|
+
} : {},
|
|
14626
15065
|
fields: names,
|
|
14627
15066
|
records,
|
|
14628
15067
|
location,
|
|
@@ -16176,45 +16615,6 @@ function readDataValidations(node2) {
|
|
|
16176
16615
|
return out;
|
|
16177
16616
|
}
|
|
16178
16617
|
|
|
16179
|
-
// xlsx/write/xml-out.ts
|
|
16180
|
-
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
16181
|
-
var CONTROL2 = "\0-\b\v\f-" + String.fromCharCode(65534, 65535);
|
|
16182
|
-
var NEEDS_ESCAPE = new RegExp(`[${CONTROL2}\r]|_x[0-9A-Fa-f]{4}_`);
|
|
16183
|
-
var ESCAPABLE = new RegExp(`[${CONTROL2}\r]|_(?=x[0-9A-Fa-f]{4}_)`, "g");
|
|
16184
|
-
function encodeEscapes(text6) {
|
|
16185
|
-
if (!NEEDS_ESCAPE.test(text6)) return text6;
|
|
16186
|
-
return text6.replace(
|
|
16187
|
-
ESCAPABLE,
|
|
16188
|
-
(ch) => `_x${ch.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}_`
|
|
16189
|
-
);
|
|
16190
|
-
}
|
|
16191
|
-
var INVALID_XML2 = new RegExp(`[${CONTROL2}]`, "g");
|
|
16192
|
-
var escapeText3 = (text6) => text6.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
16193
|
-
var escapeAttr3 = (text6) => text6.replace(INVALID_XML2, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/\r/g, " ").replace(/\n/g, " ").replace(/\t/g, "	");
|
|
16194
|
-
function attrs(values2) {
|
|
16195
|
-
let out = "";
|
|
16196
|
-
for (const [name3, value2] of Object.entries(values2)) {
|
|
16197
|
-
if (value2 === void 0) continue;
|
|
16198
|
-
const text6 = typeof value2 === "boolean" ? value2 ? "1" : "0" : typeof value2 === "number" ? num(value2) : value2;
|
|
16199
|
-
out += ` ${name3}="${escapeAttr3(text6)}"`;
|
|
16200
|
-
}
|
|
16201
|
-
return out;
|
|
16202
|
-
}
|
|
16203
|
-
var el3 = (name3, values2 = {}, content2 = "") => content2 ? `<${name3}${attrs(values2)}>${content2}</${name3}>` : `<${name3}${attrs(values2)}/>`;
|
|
16204
|
-
var num = (value2) => Object.is(value2, -0) ? "0" : String(value2);
|
|
16205
|
-
function tElement(text6, name3 = "t") {
|
|
16206
|
-
const encoded = escapeText3(encodeEscapes(text6));
|
|
16207
|
-
const preserve = /^\s|\s$|\n|\t/.test(text6) ? ' xml:space="preserve"' : "";
|
|
16208
|
-
return `<${name3}${preserve}>${encoded}</${name3}>`;
|
|
16209
|
-
}
|
|
16210
|
-
var MAIN_NS = ' xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"';
|
|
16211
|
-
function inlineFragment(xml) {
|
|
16212
|
-
const end = xml.indexOf(">");
|
|
16213
|
-
if (end < 0) return xml;
|
|
16214
|
-
const head = xml.slice(0, end);
|
|
16215
|
-
return head.includes(MAIN_NS) ? head.replace(MAIN_NS, "") + xml.slice(end) : xml;
|
|
16216
|
-
}
|
|
16217
|
-
|
|
16218
16618
|
// xlsx/conditional-extensions.ts
|
|
16219
16619
|
var XM = "http://schemas.microsoft.com/office/excel/2006/main";
|
|
16220
16620
|
var URI = "{78C0D931-6437-407d-A8EE-F0AAD7539E65}";
|
|
@@ -31528,7 +31928,9 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
31528
31928
|
const row3 = pivot.fields.indexOf(pivot.rowField);
|
|
31529
31929
|
const second = pivot.secondRowField ? pivot.fields.indexOf(pivot.secondRowField) : -1;
|
|
31530
31930
|
const col = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
31531
|
-
const
|
|
31931
|
+
const measures2 = pivotMeasures(pivot);
|
|
31932
|
+
const multiple = measures2.length > 1;
|
|
31933
|
+
const rowsAxis = pivot.valuesAxis === "rows";
|
|
31532
31934
|
const compact3 = pivot.layout === "compact";
|
|
31533
31935
|
const outline2 = pivot.layout === "compact" || pivot.layout === "outline";
|
|
31534
31936
|
const top = (pivot.subtotalPosition ?? (outline2 ? "top" : "bottom")) === "top";
|
|
@@ -31536,36 +31938,61 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
31536
31938
|
const items2 = index2 === row3 ? grid.rowItems : index2 === second ? grid.secondRowItems : index2 === col ? grid.columnItems : void 0;
|
|
31537
31939
|
const subtotal = !(index2 === row3 && pivot.subtotals === false);
|
|
31538
31940
|
const repeated = pivot.repeatLabels && (index2 === row3 || 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>' : "";
|
|
31539
|
-
return `<pivotField${attrs({ axis: index2 === row3 || index2 === second ? "axisRow" : index2 === col ? "axisCol" : void 0, dataField:
|
|
31941
|
+
return `<pivotField${attrs({ axis: index2 === row3 || index2 === second ? "axisRow" : index2 === col ? "axisCol" : void 0, dataField: measures2.some((measure2) => pivot.fields.indexOf(measure2.field) === index2) ? true : void 0, compact: compact3, outline: outline2, showAll: false, subtotalTop: index2 === row3 ? top : void 0, defaultSubtotal: subtotal ? void 0 : false })}>${items2 ? `<items count="${items2.length + Number(subtotal)}">${items2.map((item) => `<item x="${cache3.indices[index2].get(pivotValueKey(item))}"/>`).join("")}${subtotal ? '<item t="default"/>' : ""}</items>` : ""}${repeated}</pivotField>`;
|
|
31540
31942
|
}).join("");
|
|
31541
31943
|
const items = (count2) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
31542
|
-
const header = grid.firstDataRow - 1;
|
|
31543
|
-
const rowIndices = [row3, ...second >= 0 ? [second] : []];
|
|
31944
|
+
const header = grid.firstHeaderRow ?? (multiple && col >= 0 ? 1 : grid.firstDataRow - 1);
|
|
31945
|
+
const rowIndices = rowsAxis && pivot.valuesPosition === "first" ? [-2, row3, second] : rowsAxis && pivot.valuesPosition === "between" ? [row3, -2, second] : [row3, ...second >= 0 ? [second] : [], ...rowsAxis ? [-2] : []];
|
|
31544
31946
|
let previous = [];
|
|
31545
31947
|
const rowItems = grid.rowEntries?.map((entry3) => {
|
|
31546
31948
|
let prefix3 = 0;
|
|
31547
|
-
if (
|
|
31949
|
+
if (entry3.type === "default" && rowsAxis && pivot.valuesPosition === "first") prefix3 = 1;
|
|
31950
|
+
else if (!entry3.type)
|
|
31548
31951
|
while (prefix3 < entry3.indices.length - 1 && entry3.indices[prefix3] === previous[prefix3])
|
|
31549
31952
|
prefix3++;
|
|
31550
|
-
previous = entry3.type ? [] : entry3.indices;
|
|
31551
|
-
return `<i${attrs({ t: entry3.type, r: prefix3 || void 0 })}>${entry3.indices.slice(prefix3).map((index2) => `<x${attrs({ v: index2 || void 0 })}/>`).join("")}</i>`;
|
|
31953
|
+
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
31954
|
+
return `<i${attrs({ t: entry3.type, r: prefix3 || void 0, i: entry3.measure || void 0 })}>${entry3.indices.slice(prefix3).map((index2) => `<x${attrs({ v: index2 || void 0 })}/>`).join("")}</i>`;
|
|
31552
31955
|
}).join("") ?? items(grid.rowItems.length);
|
|
31553
31956
|
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>`;
|
|
31554
|
-
if (
|
|
31957
|
+
if (multiple && !rowsAxis)
|
|
31958
|
+
body += `<colFields count="${col >= 0 ? 2 : 1}">${col >= 0 ? `<field x="${col}"/>` : ""}<field x="-2"/></colFields>${pivotValueAxisItems(measures2.length, col >= 0 ? grid.columnItems.length : void 0)}`;
|
|
31959
|
+
else if (col >= 0)
|
|
31555
31960
|
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length)}</colItems>`;
|
|
31556
|
-
else
|
|
31557
|
-
|
|
31961
|
+
else
|
|
31962
|
+
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
31963
|
+
body += `<dataFields count="${measures2.length}">${measures2.map((measure2) => `<dataField${attrs({ name: encodeEscapes(measure2.caption), fld: pivot.fields.indexOf(measure2.field), subtotal: measure2.aggregate, baseField: 0, baseItem: 0 })}/>`).join("")}</dataFields>`;
|
|
31558
31964
|
const doc = parseXml(
|
|
31559
31965
|
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>`
|
|
31560
31966
|
);
|
|
31561
31967
|
const root = doc.documentElement;
|
|
31562
31968
|
root.setAttribute("name", pivot.name);
|
|
31563
31969
|
root.setAttribute("cacheId", String(cacheId));
|
|
31970
|
+
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
31971
|
+
if (rowsAxis && (pivot.valuesPosition === "between" || pivot.valuesPosition === "first"))
|
|
31972
|
+
root.setAttribute("dataPosition", pivot.valuesPosition === "first" ? "0" : "1");
|
|
31973
|
+
else root.removeAttribute("dataPosition");
|
|
31564
31974
|
root.setAttribute("compact", compact3 ? "1" : "0");
|
|
31565
31975
|
root.setAttribute("compactData", compact3 ? "1" : "0");
|
|
31566
31976
|
root.setAttribute("outline", outline2 ? "1" : "0");
|
|
31567
31977
|
root.setAttribute("outlineData", outline2 ? "1" : "0");
|
|
31568
31978
|
if (compact3) root.setAttribute("indent", "0");
|
|
31979
|
+
if (multiple && !elements(first(root, "extLst", NS.x) ?? parseXml("<root/>").documentElement).some(
|
|
31980
|
+
(extension2) => first(
|
|
31981
|
+
extension2,
|
|
31982
|
+
"pivotTableDefinition",
|
|
31983
|
+
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
31984
|
+
)
|
|
31985
|
+
)) {
|
|
31986
|
+
let list2 = first(root, "extLst", NS.x);
|
|
31987
|
+
if (!list2) {
|
|
31988
|
+
list2 = doc.createElementNS(NS.x, "extLst");
|
|
31989
|
+
root.appendChild(list2);
|
|
31990
|
+
}
|
|
31991
|
+
const extension2 = parseXml(
|
|
31992
|
+
`<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>`
|
|
31993
|
+
).documentElement;
|
|
31994
|
+
list2.appendChild(doc.importNode(extension2, true));
|
|
31995
|
+
}
|
|
31569
31996
|
root.setAttribute("rowGrandTotals", "1");
|
|
31570
31997
|
root.setAttribute("colGrandTotals", "1");
|
|
31571
31998
|
for (const extension2 of elements(
|
|
@@ -31576,6 +32003,7 @@ function pivotTableXml(pivot, cacheId, cache3) {
|
|
|
31576
32003
|
"pivotTableDefinition",
|
|
31577
32004
|
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"
|
|
31578
32005
|
);
|
|
32006
|
+
if (multiple && definition) definition.setAttribute("hideValuesRow", "1");
|
|
31579
32007
|
if (definition?.hasAttribute("fillDownLabelsDefault"))
|
|
31580
32008
|
definition.setAttribute("fillDownLabelsDefault", pivot.repeatLabels ? "1" : "0");
|
|
31581
32009
|
}
|
|
@@ -35795,12 +36223,16 @@ function write(ctx, s, pivot, old) {
|
|
|
35795
36223
|
],
|
|
35796
36224
|
() => {
|
|
35797
36225
|
const compact3 = pivot.layout === "compact";
|
|
35798
|
-
const indents =
|
|
35799
|
-
|
|
35800
|
-
|
|
35801
|
-
|
|
35802
|
-
|
|
35803
|
-
|
|
36226
|
+
const indents = new Map(
|
|
36227
|
+
[.../* @__PURE__ */ new Set([0, ...grid.indents ?? []])].map(
|
|
36228
|
+
(indent) => [
|
|
36229
|
+
indent,
|
|
36230
|
+
stylePatcher(ctx.workbook, {
|
|
36231
|
+
alignment: { indent, ...compact3 || indent > 0 ? { horizontal: "left" } : {} }
|
|
36232
|
+
})
|
|
36233
|
+
]
|
|
36234
|
+
)
|
|
36235
|
+
);
|
|
35804
36236
|
const styles = /* @__PURE__ */ new Map();
|
|
35805
36237
|
forEachCellInRange(sheet, location, (cell, row3, col) => {
|
|
35806
36238
|
if (cell.styleId !== void 0) styles.set(`${row3}:${col}`, cell.styleId);
|
|
@@ -35823,7 +36255,7 @@ function write(ctx, s, pivot, old) {
|
|
|
35823
36255
|
const indent = col === 0 ? grid.indents?.[row3] ?? 0 : 0;
|
|
35824
36256
|
const alignment = styleAt(ctx.workbook, styleId).alignment;
|
|
35825
36257
|
if ((alignment?.indent ?? 0) !== indent || compact3 && alignment?.horizontal !== "left")
|
|
35826
|
-
styleId = indents
|
|
36258
|
+
styleId = indents.get(indent)(styleId);
|
|
35827
36259
|
}
|
|
35828
36260
|
putCell(sheet, r, c2, { value: value2, ...styleId !== void 0 ? { styleId } : {} });
|
|
35829
36261
|
})
|
|
@@ -35850,6 +36282,9 @@ function createPivotTable(ctx, s, destination, options) {
|
|
|
35850
36282
|
valueField: options.valueField,
|
|
35851
36283
|
aggregate: aggregate3,
|
|
35852
36284
|
valueCaption: pivotCaption(aggregate3, options.valueField),
|
|
36285
|
+
...options.valuesAxis !== void 0 ? { valuesAxis: options.valuesAxis } : {},
|
|
36286
|
+
...options.valuesPosition !== void 0 ? { valuesPosition: options.valuesPosition } : {},
|
|
36287
|
+
...options.additionalValues ? { additionalValues: normalizedPivotMeasures(options.additionalValues) } : {},
|
|
35853
36288
|
location: { start: { ...destination }, end: { ...destination } },
|
|
35854
36289
|
...options.columnField ? { columnField: options.columnField } : {}
|
|
35855
36290
|
};
|
|
@@ -35881,6 +36316,15 @@ function refreshPivotTable(ctx, s, name3, patch2 = {}) {
|
|
|
35881
36316
|
if (patch2.repeatLabels !== void 0) next.repeatLabels = patch2.repeatLabels;
|
|
35882
36317
|
if (patch2.layout !== void 0) next.layout = patch2.layout;
|
|
35883
36318
|
if (patch2.subtotalPosition !== void 0) next.subtotalPosition = patch2.subtotalPosition;
|
|
36319
|
+
if (patch2.valuesAxis !== void 0) next.valuesAxis = patch2.valuesAxis;
|
|
36320
|
+
if (patch2.valuesPosition !== void 0) next.valuesPosition = patch2.valuesPosition;
|
|
36321
|
+
else if (patch2.valuesAxis === "columns" || patch2.secondRowField === "")
|
|
36322
|
+
delete next.valuesPosition;
|
|
36323
|
+
if (patch2.additionalValues !== void 0) {
|
|
36324
|
+
const measures2 = normalizedPivotMeasures(patch2.additionalValues);
|
|
36325
|
+
if (measures2.length) next.additionalValues = measures2;
|
|
36326
|
+
else delete next.additionalValues;
|
|
36327
|
+
}
|
|
35884
36328
|
validatePivotFields(next);
|
|
35885
36329
|
write(ctx, s, next, old);
|
|
35886
36330
|
}
|
|
@@ -45133,7 +45577,6 @@ function visioWallClock(date2) {
|
|
|
45133
45577
|
);
|
|
45134
45578
|
}
|
|
45135
45579
|
var EPOCH = Date.UTC(1899, 11, 30);
|
|
45136
|
-
var visioDateSerial = (date2) => Number(((date2.getTime() - EPOCH) / 864e5).toFixed(8));
|
|
45137
45580
|
var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
|
|
45138
45581
|
function evaluateVisioTextField(formula, context) {
|
|
45139
45582
|
let ast;
|
|
@@ -45244,7 +45687,10 @@ function formatNumber2(value2, picture) {
|
|
|
45244
45687
|
if (!match2) return void 0;
|
|
45245
45688
|
const decimals = match2[2]?.length ?? 0;
|
|
45246
45689
|
const optional = match2[2]?.startsWith("#") ?? false;
|
|
45247
|
-
|
|
45690
|
+
const [coefficient2, exponent = "0"] = Math.abs(value2).toString().split("e");
|
|
45691
|
+
const shifted2 = Number(coefficient2 + "e" + (Number(exponent) + decimals));
|
|
45692
|
+
const rounded = Math.floor(shifted2 + 0.5) / 10 ** decimals;
|
|
45693
|
+
let text6 = (Math.sign(value2) * rounded).toFixed(decimals);
|
|
45248
45694
|
if (optional && text6.includes(".")) text6 = text6.replace(/\.?0+$/, "");
|
|
45249
45695
|
if (match2[1]) {
|
|
45250
45696
|
const [whole, fraction] = text6.split(".");
|
|
@@ -45272,9 +45718,35 @@ function formatVisioFieldValue(value2, format4 = "") {
|
|
|
45272
45718
|
return units2 || body === "" ? `${text6}${suffix}` : text6;
|
|
45273
45719
|
}
|
|
45274
45720
|
|
|
45721
|
+
// visio/text-field-fraction.ts
|
|
45722
|
+
function fractionalFieldNumber(value2, maxDenominator) {
|
|
45723
|
+
if (!Number.isFinite(value2) || Math.abs(value2) > 1e15) return void 0;
|
|
45724
|
+
const absolute = Math.abs(value2);
|
|
45725
|
+
let whole = Math.floor(absolute);
|
|
45726
|
+
const remainder2 = absolute - whole;
|
|
45727
|
+
let numerator = 0, denominator = 1, error = remainder2;
|
|
45728
|
+
for (let candidate = 1; candidate <= maxDenominator; candidate++) {
|
|
45729
|
+
const top = Math.round(remainder2 * candidate);
|
|
45730
|
+
const fraction = top / candidate;
|
|
45731
|
+
const distance4 = Math.abs(remainder2 - fraction);
|
|
45732
|
+
if (distance4 < error || distance4 === error && fraction > numerator / denominator) {
|
|
45733
|
+
numerator = top;
|
|
45734
|
+
denominator = candidate;
|
|
45735
|
+
error = distance4;
|
|
45736
|
+
}
|
|
45737
|
+
}
|
|
45738
|
+
if (numerator === denominator) {
|
|
45739
|
+
whole++;
|
|
45740
|
+
numerator = 0;
|
|
45741
|
+
}
|
|
45742
|
+
const text6 = numerator ? `${whole ? whole + " " : ""}${numerator}/${denominator}` : String(whole);
|
|
45743
|
+
return value2 < 0 && text6 !== "0" ? "-" + text6 : text6;
|
|
45744
|
+
}
|
|
45745
|
+
|
|
45275
45746
|
// visio/text-field-numeric.ts
|
|
45276
45747
|
function numericFieldPicture(value2, code, displayUnit) {
|
|
45277
|
-
if (value2.kind !== "number" || code <
|
|
45748
|
+
if (value2.kind !== "number" || code < 0 || code > 18 || code > 9 && code < 15 || !Number.isInteger(code))
|
|
45749
|
+
return void 0;
|
|
45278
45750
|
const unit3 = displayUnit?.toUpperCase() ?? "NUM";
|
|
45279
45751
|
const units2 = {
|
|
45280
45752
|
NUM: ["scalar", 1, ""],
|
|
@@ -45287,21 +45759,106 @@ function numericFieldPicture(value2, code, displayUnit) {
|
|
|
45287
45759
|
};
|
|
45288
45760
|
const definition = Object.hasOwn(units2, unit3) ? units2[unit3] : void 0;
|
|
45289
45761
|
if (!definition || definition[0] !== value2.unit) return void 0;
|
|
45290
|
-
const
|
|
45291
|
-
const
|
|
45292
|
-
const
|
|
45293
|
-
|
|
45294
|
-
|
|
45295
|
-
)
|
|
45762
|
+
const general = code < 2;
|
|
45763
|
+
const decimals = general ? 4 : Math.floor((code - 2) / 2);
|
|
45764
|
+
const picture = general ? "0.####" : decimals ? `0.${"0".repeat(decimals)}` : "0";
|
|
45765
|
+
const displayed = value2.value * definition[1];
|
|
45766
|
+
if (!Number.isFinite(displayed)) return void 0;
|
|
45767
|
+
if (code >= 15) {
|
|
45768
|
+
const fraction = fractionalFieldNumber(displayed, code < 17 ? 9 : 99);
|
|
45769
|
+
return fraction === void 0 ? void 0 : fraction + (code % 2 === 0 ? definition[2] : "");
|
|
45770
|
+
}
|
|
45771
|
+
if ((general || !decimals) && Math.abs(displayed) > 1e15) return void 0;
|
|
45772
|
+
const scientific3 = decimals > 0 && (Math.abs(displayed) >= 1e15 || displayed !== 0 && Math.abs(displayed) < 0.5 / 10 ** decimals);
|
|
45773
|
+
let text6;
|
|
45774
|
+
if (scientific3) {
|
|
45775
|
+
const [coefficient2, power2] = displayed.toExponential().split("e");
|
|
45776
|
+
let exponent = Number(power2);
|
|
45777
|
+
let precision = Math.abs(displayed) >= 1e15 ? decimals : decimals - 1;
|
|
45778
|
+
const mantissaPicture = precision ? `0.${"0".repeat(precision)}` : "0";
|
|
45779
|
+
let mantissa = formatVisioFieldValue(
|
|
45780
|
+
{ kind: "number", value: Number(coefficient2), unit: "scalar" },
|
|
45781
|
+
mantissaPicture
|
|
45782
|
+
);
|
|
45783
|
+
if (mantissa === void 0) return void 0;
|
|
45784
|
+
if (Math.abs(Number(mantissa)) >= 10) {
|
|
45785
|
+
exponent += 1;
|
|
45786
|
+
precision = decimals;
|
|
45787
|
+
mantissa = Math.sign(displayed).toFixed(precision);
|
|
45788
|
+
}
|
|
45789
|
+
if (general) mantissa = mantissa.replace(/\.?0+$/, "");
|
|
45790
|
+
else if (!mantissa.includes(".")) mantissa += ".";
|
|
45791
|
+
text6 = mantissa + (code % 2 ? "e" : "E") + exponent;
|
|
45792
|
+
} else {
|
|
45793
|
+
text6 = formatVisioFieldValue({ kind: "number", value: displayed, unit: "scalar" }, picture);
|
|
45794
|
+
}
|
|
45296
45795
|
return text6 === void 0 ? void 0 : text6 + (code % 2 ? definition[2] : "");
|
|
45297
45796
|
}
|
|
45298
45797
|
|
|
45798
|
+
// visio/date-cache.ts
|
|
45799
|
+
function visioIsoDateSerial(text6) {
|
|
45800
|
+
const match2 = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?$/.exec(
|
|
45801
|
+
text6.trim()
|
|
45802
|
+
);
|
|
45803
|
+
if (!match2) return void 0;
|
|
45804
|
+
const year = Number(match2[1]), month = Number(match2[2]), day = Number(match2[3]);
|
|
45805
|
+
const hour = Number(match2[4] ?? 0), minute = Number(match2[5] ?? 0), second = Number(match2[6] ?? 0);
|
|
45806
|
+
const millisecond = Number((match2[7] ?? "").padEnd(3, "0").slice(0, 3));
|
|
45807
|
+
if (year < 1 || hour > 23 || minute > 59 || second > 59) return void 0;
|
|
45808
|
+
const date2 = /* @__PURE__ */ new Date(0);
|
|
45809
|
+
date2.setUTCFullYear(year, month - 1, day);
|
|
45810
|
+
date2.setUTCHours(hour, minute, second, millisecond);
|
|
45811
|
+
if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month - 1 || date2.getUTCDate() !== day)
|
|
45812
|
+
return void 0;
|
|
45813
|
+
return (date2.getTime() - Date.UTC(1899, 11, 30)) / 864e5;
|
|
45814
|
+
}
|
|
45815
|
+
|
|
45816
|
+
// visio/text-field-system-date.ts
|
|
45817
|
+
var LONG_DATE = "{{dddd, MMMM d, yyyy}}";
|
|
45818
|
+
function englishLongDateProfile(cached6) {
|
|
45819
|
+
const match2 = /^[A-Za-z]+, [A-Za-z]+ ([1-9]|[12]\d|3[01]), (\d{4})$/.exec(cached6);
|
|
45820
|
+
if (!match2) return false;
|
|
45821
|
+
for (let month = 0; month < 12; month++) {
|
|
45822
|
+
const candidate = /* @__PURE__ */ new Date(0);
|
|
45823
|
+
candidate.setUTCFullYear(Number(match2[2]), month, Number(match2[1]));
|
|
45824
|
+
if (candidate.getUTCMonth() === month && candidate.getTime() >= Date.UTC(1899, 11, 30) && formatVisioFieldValue({ kind: "date", date: candidate }, LONG_DATE) === cached6)
|
|
45825
|
+
return true;
|
|
45826
|
+
}
|
|
45827
|
+
return false;
|
|
45828
|
+
}
|
|
45829
|
+
function systemDatePicture(date2, code, cached6) {
|
|
45830
|
+
if (!Number.isFinite(date2.getTime()) || date2.getTime() < Date.UTC(1899, 11, 30) || date2.getUTCFullYear() > 9999)
|
|
45831
|
+
return void 0;
|
|
45832
|
+
if (code === "204") return formatVisioFieldValue({ kind: "date", date: date2 }, "{{yyyy-MM-dd}}");
|
|
45833
|
+
if (code === "21" || code === "201")
|
|
45834
|
+
return englishLongDateProfile(cached6) ? formatVisioFieldValue({ kind: "date", date: date2 }, LONG_DATE) : void 0;
|
|
45835
|
+
if (code === "20" || code === "200") {
|
|
45836
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(cached6) || visioIsoDateSerial(cached6) === void 0)
|
|
45837
|
+
return void 0;
|
|
45838
|
+
return formatVisioFieldValue({ kind: "date", date: date2 }, "{{yyyy-MM-dd}}");
|
|
45839
|
+
}
|
|
45840
|
+
if (code !== "211" && code !== "212") return void 0;
|
|
45841
|
+
const match2 = /^(\d{4}-\d{2}-\d{2}) ([1-9]|1[0-2]):([0-5]\d)(?::([0-5]\d))? (AM|PM)$/.exec(
|
|
45842
|
+
cached6
|
|
45843
|
+
);
|
|
45844
|
+
if (!match2 || code === "212" !== (match2[4] !== void 0)) return void 0;
|
|
45845
|
+
const hour = Number(match2[2]) % 12 + (match2[5] === "PM" ? 12 : 0);
|
|
45846
|
+
if (visioIsoDateSerial(
|
|
45847
|
+
`${match2[1]}T${String(hour).padStart(2, "0")}:${match2[3]}:${match2[4] ?? "00"}`
|
|
45848
|
+
) === void 0)
|
|
45849
|
+
return void 0;
|
|
45850
|
+
return formatVisioFieldValue(
|
|
45851
|
+
{ kind: "date", date: date2 },
|
|
45852
|
+
code === "211" ? "{{yyyy-MM-dd h:mm tt}}" : "{{yyyy-MM-dd h:mm:ss tt}}"
|
|
45853
|
+
);
|
|
45854
|
+
}
|
|
45855
|
+
|
|
45299
45856
|
// visio/text-field-display.ts
|
|
45300
45857
|
function cachedValue(value2, unit3) {
|
|
45301
45858
|
if (value2 === void 0) return void 0;
|
|
45302
45859
|
if (unit3 === "STR") return { kind: "string", text: value2 };
|
|
45303
45860
|
if (unit3 === "DATE") {
|
|
45304
|
-
const date2 = visioSerialDate(Number(value2));
|
|
45861
|
+
const date2 = visioSerialDate(visioIsoDateSerial(value2) ?? Number(value2));
|
|
45305
45862
|
return date2 ? { kind: "date", date: date2 } : void 0;
|
|
45306
45863
|
}
|
|
45307
45864
|
try {
|
|
@@ -45331,6 +45888,8 @@ function textFieldDisplay(element2, sheet, context) {
|
|
|
45331
45888
|
}
|
|
45332
45889
|
if (source2?.kind === "number" && code !== void 0)
|
|
45333
45890
|
text7 = numericFieldPicture(source2, Number(code), value2?.unit) ?? cached6;
|
|
45891
|
+
if (source2?.kind === "date" && code !== void 0)
|
|
45892
|
+
text7 = systemDatePicture(source2.date, code, cached6) ?? cached6;
|
|
45334
45893
|
return { text: text7, ...result2 };
|
|
45335
45894
|
}
|
|
45336
45895
|
const text6 = source2 ? formatVisioFieldValue(source2, picture) : void 0;
|
|
@@ -46787,15 +47346,6 @@ function booleanValue(text6) {
|
|
|
46787
47346
|
const value2 = numeric3(text6);
|
|
46788
47347
|
return value2 === void 0 ? void 0 : value2 !== 0;
|
|
46789
47348
|
}
|
|
46790
|
-
function isoSerialDays(text6) {
|
|
46791
|
-
const match2 = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}(?:\.\d+)?))?)?$/.exec(
|
|
46792
|
-
text6.trim()
|
|
46793
|
-
);
|
|
46794
|
-
if (!match2) return void 0;
|
|
46795
|
-
const [year, month, day, hour, minute, second] = match2.slice(1).map((part) => Number(part ?? 0));
|
|
46796
|
-
const time = Date.UTC(year, month - 1, day, hour, minute, second);
|
|
46797
|
-
return Number.isFinite(time) ? (time - Date.UTC(1899, 11, 30)) / 864e5 : void 0;
|
|
46798
|
-
}
|
|
46799
47349
|
function property(row3, budget, report) {
|
|
46800
47350
|
const get = (key2) => cached2(row3.cells, key2, budget, report);
|
|
46801
47351
|
const rawType = get("Type"), rawValue = get("Value");
|
|
@@ -46806,7 +47356,7 @@ function property(row3, budget, report) {
|
|
|
46806
47356
|
if (rawValue !== void 0 && row3.cells.get("Value")?.error === void 0) {
|
|
46807
47357
|
if (type === 0 || type === 1 || type === 4) value2 = budget.retain(rawValue);
|
|
46808
47358
|
else if (type === 3) value2 = booleanValue(rawValue);
|
|
46809
|
-
else if (type === 5) value2 = numeric3(rawValue) ??
|
|
47359
|
+
else if (type === 5) value2 = numeric3(rawValue) ?? visioIsoDateSerial(rawValue);
|
|
46810
47360
|
else if (valueKind !== "unparsed") value2 = numeric3(rawValue);
|
|
46811
47361
|
}
|
|
46812
47362
|
if (value2 === void 0) {
|
|
@@ -55558,7 +56108,8 @@ function shapeResolver(shape2) {
|
|
|
55558
56108
|
}
|
|
55559
56109
|
function valueCell(value2) {
|
|
55560
56110
|
if (value2.kind === "string") return { v: value2.text, u: "STR", type: 0 };
|
|
55561
|
-
if (value2.kind === "date")
|
|
56111
|
+
if (value2.kind === "date")
|
|
56112
|
+
return { v: value2.date.toISOString().replace(/Z$/, ""), u: "DATE", type: 5 };
|
|
55562
56113
|
const unit3 = value2.unit === "length" ? "IN" : value2.unit === "angle" ? "DEG" : void 0;
|
|
55563
56114
|
return { v: String(Number(value2.value.toFixed(10))), ...unit3 ? { u: unit3 } : {}, type: 2 };
|
|
55564
56115
|
}
|
|
@@ -55645,7 +56196,8 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
|
|
|
55645
56196
|
};
|
|
55646
56197
|
const stored = valueCell(value2);
|
|
55647
56198
|
cell("Value", stored.v, { ...stored.u ? { U: stored.u } : {}, F: edit.formula });
|
|
55648
|
-
if (edit.format)
|
|
56199
|
+
if (edit.format)
|
|
56200
|
+
cell("Format", edit.format, { U: "STR", F: `"${edit.format.replaceAll('"', '""')}"` });
|
|
55649
56201
|
cell("Type", String(stored.type));
|
|
55650
56202
|
section3.appendChild(row3);
|
|
55651
56203
|
const field2 = owner.createElementNS(ns, "fld");
|