@extend-ai/react-xlsx 0.20.2 → 0.20.4
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/browser-IQ4UDS5M.js +209 -0
- package/dist/browser-IQ4UDS5M.js.map +1 -0
- package/dist/browser-S6E2BS5S.cjs +212 -0
- package/dist/browser-S6E2BS5S.cjs.map +1 -0
- package/dist/{chart-renderer-F355CYSE.js → chart-renderer-4HTNG3SX.js} +94 -180
- package/dist/chart-renderer-4HTNG3SX.js.map +1 -0
- package/dist/{chart-renderer-7DTEXXG6.js → chart-renderer-5IN2B3YS.js} +94 -180
- package/dist/chart-renderer-5IN2B3YS.js.map +1 -0
- package/dist/{chart-renderer-LGW4EH4M.cjs → chart-renderer-6CWSXOSC.cjs} +324 -410
- package/dist/chart-renderer-6CWSXOSC.cjs.map +1 -0
- package/dist/{chart-renderer-3QDNTMRN.cjs → chart-renderer-H4BLRO5P.cjs} +324 -410
- package/dist/chart-renderer-H4BLRO5P.cjs.map +1 -0
- package/dist/chunk-GX5LAENE.cjs +108 -0
- package/dist/chunk-GX5LAENE.cjs.map +1 -0
- package/dist/{chunk-GXYDJPHM.js → chunk-H62SZBEY.js} +401 -132
- package/dist/chunk-H62SZBEY.js.map +1 -0
- package/dist/{chunk-3LMOGW6A.js → chunk-IISMO3AX.js} +30 -15
- package/dist/chunk-IISMO3AX.js.map +1 -0
- package/dist/{chunk-ZJ76CZAL.cjs → chunk-KQSUAIZD.cjs} +1168 -899
- package/dist/chunk-KQSUAIZD.cjs.map +1 -0
- package/dist/{chunk-IYGZTLDY.js → chunk-LZXL5E4W.js} +16 -7
- package/dist/chunk-LZXL5E4W.js.map +1 -0
- package/dist/chunk-MYN475JP.cjs +32 -0
- package/dist/chunk-MYN475JP.cjs.map +1 -0
- package/dist/{chunk-D2UA4P6N.cjs → chunk-NAYVSTCX.cjs} +22 -9
- package/dist/chunk-NAYVSTCX.cjs.map +1 -0
- package/dist/chunk-PK3MCNDK.js +32 -0
- package/dist/chunk-PK3MCNDK.js.map +1 -0
- package/dist/full-3FSPB3R6.cjs +212 -0
- package/dist/full-3FSPB3R6.cjs.map +1 -0
- package/dist/full-GPY27HZY.js +209 -0
- package/dist/full-GPY27HZY.js.map +1 -0
- package/dist/index.cjs +834 -602
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.js +347 -115
- package/dist/index.js.map +1 -1
- package/dist/{internal-BJsg5os3.d.cts → internal-Cks9H21d.d.cts} +56 -1
- package/dist/{internal-BJsg5os3.d.ts → internal-Cks9H21d.d.ts} +56 -1
- package/dist/internal.cjs +3 -3
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +2 -2
- package/dist/office_charts_bg.wasm +0 -0
- package/dist/office_charts_full_bg.wasm +0 -0
- package/dist/payload-B55ZKNYO.js +6 -0
- package/dist/payload-B55ZKNYO.js.map +1 -0
- package/dist/payload-E2KM77DZ.js +6 -0
- package/dist/payload-E2KM77DZ.js.map +1 -0
- package/dist/payload-K4S5RLJN.cjs +8 -0
- package/dist/payload-K4S5RLJN.cjs.map +1 -0
- package/dist/payload-PL4646XV.cjs +8 -0
- package/dist/payload-PL4646XV.cjs.map +1 -0
- package/dist/rust-office-charts-LICENSE.txt +21 -0
- package/dist/{shared-chart-3STFRVWT.js → shared-chart-5KTGZEZ5.js} +38 -20
- package/dist/shared-chart-5KTGZEZ5.js.map +1 -0
- package/dist/{shared-chart-DVC5S2P6.cjs → shared-chart-ACR4M7BP.cjs} +37 -20
- package/dist/shared-chart-ACR4M7BP.cjs.map +1 -0
- package/dist/{shared-chart-BFQNYOIQ.js → shared-chart-EGN5JTKT.js} +37 -20
- package/dist/shared-chart-EGN5JTKT.js.map +1 -0
- package/dist/{shared-chart-MFQSQG4K.cjs → shared-chart-XAV7VA45.cjs} +37 -19
- package/dist/shared-chart-XAV7VA45.cjs.map +1 -0
- package/dist/{surface-regl-R2N54JT2.js → surface-webgl-2ZZ6JQR2.js} +87 -151
- package/dist/surface-webgl-2ZZ6JQR2.js.map +1 -0
- package/dist/{surface-regl-BBJ6OIKK.cjs → surface-webgl-3HS6VBCK.cjs} +88 -152
- package/dist/surface-webgl-3HS6VBCK.cjs.map +1 -0
- package/dist/{surface-regl-7CDGGVDG.js → surface-webgl-4DQXDDXU.js} +87 -151
- package/dist/surface-webgl-4DQXDDXU.js.map +1 -0
- package/dist/{surface-regl-SUJ2TFZA.cjs → surface-webgl-SVYD564V.cjs} +88 -152
- package/dist/surface-webgl-SVYD564V.cjs.map +1 -0
- package/dist/vanilla.cjs +3 -3
- package/dist/vanilla.d.cts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +2 -2
- package/dist/xlsx-worker.js +298 -92
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +7 -15
- package/dist/chart-renderer-3QDNTMRN.cjs.map +0 -1
- package/dist/chart-renderer-7DTEXXG6.js.map +0 -1
- package/dist/chart-renderer-F355CYSE.js.map +0 -1
- package/dist/chart-renderer-LGW4EH4M.cjs.map +0 -1
- package/dist/chunk-3LMOGW6A.js.map +0 -1
- package/dist/chunk-D2UA4P6N.cjs.map +0 -1
- package/dist/chunk-GXYDJPHM.js.map +0 -1
- package/dist/chunk-IYGZTLDY.js.map +0 -1
- package/dist/chunk-OCF75R75.cjs +0 -90
- package/dist/chunk-OCF75R75.cjs.map +0 -1
- package/dist/chunk-ZJ76CZAL.cjs.map +0 -1
- package/dist/region-map-geography-24TXETDP.cjs +0 -184
- package/dist/region-map-geography-24TXETDP.cjs.map +0 -1
- package/dist/region-map-geography-OR6DHAF7.js +0 -182
- package/dist/region-map-geography-OR6DHAF7.js.map +0 -1
- package/dist/shared-chart-3STFRVWT.js.map +0 -1
- package/dist/shared-chart-BFQNYOIQ.js.map +0 -1
- package/dist/shared-chart-DVC5S2P6.cjs.map +0 -1
- package/dist/shared-chart-MFQSQG4K.cjs.map +0 -1
- package/dist/surface-regl-7CDGGVDG.js.map +0 -1
- package/dist/surface-regl-BBJ6OIKK.cjs.map +0 -1
- package/dist/surface-regl-R2N54JT2.js.map +0 -1
- package/dist/surface-regl-SUJ2TFZA.cjs.map +0 -1
- package/dist/world-atlas-LICENSE.txt +0 -13
- /package/dist/{us-atlas-LICENSE.txt → rust-office-charts-MAP-DATA-LICENSE.txt} +0 -0
package/dist/xlsx-worker.js
CHANGED
|
@@ -2993,6 +2993,76 @@ function getBuiltinChartSurfaceStyle(styleId) {
|
|
|
2993
2993
|
};
|
|
2994
2994
|
}
|
|
2995
2995
|
|
|
2996
|
+
// src/chartsheet-payload.ts
|
|
2997
|
+
var REL_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
2998
|
+
function readXml(archive, path) {
|
|
2999
|
+
const bytes = archive[path];
|
|
3000
|
+
if (!bytes || typeof DOMParser === "undefined") return null;
|
|
3001
|
+
const document2 = new DOMParser().parseFromString(strFromU8(bytes), "application/xml");
|
|
3002
|
+
return document2.getElementsByTagName("parsererror").length > 0 ? null : document2;
|
|
3003
|
+
}
|
|
3004
|
+
function relationshipPath(partPath) {
|
|
3005
|
+
const separator = partPath.lastIndexOf("/");
|
|
3006
|
+
return `${partPath.slice(0, separator + 1)}_rels/${partPath.slice(separator + 1)}.rels`;
|
|
3007
|
+
}
|
|
3008
|
+
function resolveTarget(partPath, target) {
|
|
3009
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(target) || target.startsWith("//")) return null;
|
|
3010
|
+
const segments = target.startsWith("/") ? [] : partPath.split("/").slice(0, -1);
|
|
3011
|
+
for (const segment of target.replace(/\\/g, "/").split("/")) {
|
|
3012
|
+
if (!segment || segment === ".") continue;
|
|
3013
|
+
if (segment === "..") {
|
|
3014
|
+
if (segments.length === 0) return null;
|
|
3015
|
+
segments.pop();
|
|
3016
|
+
} else {
|
|
3017
|
+
segments.push(segment);
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
return segments.join("/");
|
|
3021
|
+
}
|
|
3022
|
+
function readRelationships(archive, partPath) {
|
|
3023
|
+
const relationships = /* @__PURE__ */ new Map();
|
|
3024
|
+
const document2 = readXml(archive, relationshipPath(partPath));
|
|
3025
|
+
for (const element of Array.from(document2?.getElementsByTagNameNS("*", "Relationship") ?? [])) {
|
|
3026
|
+
if (element.getAttribute("TargetMode") === "External") continue;
|
|
3027
|
+
const id = element.getAttribute("Id");
|
|
3028
|
+
const rawTarget = element.getAttribute("Target");
|
|
3029
|
+
const type = element.getAttribute("Type");
|
|
3030
|
+
const target = rawTarget ? resolveTarget(partPath, rawTarget) : null;
|
|
3031
|
+
if (id && type && target && archive[target]) relationships.set(id, { target, type });
|
|
3032
|
+
}
|
|
3033
|
+
return relationships;
|
|
3034
|
+
}
|
|
3035
|
+
function collectChartsheetDrawingOrigins(archive, chartsheets2) {
|
|
3036
|
+
const origins = /* @__PURE__ */ new Map();
|
|
3037
|
+
if (chartsheets2.length === 0) return origins;
|
|
3038
|
+
const workbookPath = "xl/workbook.xml";
|
|
3039
|
+
const workbookDocument = readXml(archive, workbookPath);
|
|
3040
|
+
const workbookRelationships = readRelationships(archive, workbookPath);
|
|
3041
|
+
for (const sheet of Array.from(workbookDocument?.getElementsByTagNameNS("*", "sheet") ?? [])) {
|
|
3042
|
+
const relationshipId = sheet.getAttributeNS(REL_NS, "id") ?? sheet.getAttribute("r:id");
|
|
3043
|
+
const relationship = relationshipId ? workbookRelationships.get(relationshipId) : null;
|
|
3044
|
+
if (!relationship?.type.endsWith("/chartsheet")) continue;
|
|
3045
|
+
const chartsheet = chartsheets2.find((entry) => entry.name === sheet.getAttribute("name"));
|
|
3046
|
+
if (!chartsheet || chartsheet.workbookSheetIndex == null) continue;
|
|
3047
|
+
const sheetDocument = readXml(archive, relationship.target);
|
|
3048
|
+
const sheetRelationships = readRelationships(archive, relationship.target);
|
|
3049
|
+
const attachments = [];
|
|
3050
|
+
for (const drawing of Array.from(sheetDocument?.getElementsByTagNameNS("*", "drawing") ?? [])) {
|
|
3051
|
+
const drawingId = drawing.getAttributeNS(REL_NS, "id") ?? drawing.getAttribute("r:id");
|
|
3052
|
+
const drawingRelationship = drawingId ? sheetRelationships.get(drawingId) : null;
|
|
3053
|
+
if (!drawingRelationship?.type.endsWith("/drawing")) continue;
|
|
3054
|
+
const drawingRelsPath = relationshipPath(drawingRelationship.target);
|
|
3055
|
+
attachments.push({
|
|
3056
|
+
drawingPath: drawingRelationship.target,
|
|
3057
|
+
drawingRelsPath: archive[drawingRelsPath] ? drawingRelsPath : null,
|
|
3058
|
+
mediaPaths: []
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
3061
|
+
origins.set(chartsheet.index, { attachments, workbookSheetIndex: chartsheet.workbookSheetIndex });
|
|
3062
|
+
}
|
|
3063
|
+
return origins;
|
|
3064
|
+
}
|
|
3065
|
+
|
|
2996
3066
|
// src/charts.ts
|
|
2997
3067
|
var CHART_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
|
2998
3068
|
var CHART_EX_REL_TYPE = "http://schemas.microsoft.com/office/2014/relationships/chartEx";
|
|
@@ -3713,9 +3783,10 @@ function applyBuiltinChartDefaults(chart, themePalette) {
|
|
|
3713
3783
|
};
|
|
3714
3784
|
};
|
|
3715
3785
|
chart.series = chart.series.map(applySeriesDefaults);
|
|
3786
|
+
const canonicalSeries = chart.id.startsWith("chart-ex-") ? null : new Map(chart.series.map((series) => [series.id, series]));
|
|
3716
3787
|
let groupSeriesOffset = 0;
|
|
3717
3788
|
chart.typeGroups = chart.typeGroups?.map((group) => {
|
|
3718
|
-
const series = group.series.map((entry, index) => applySeriesDefaults(entry, groupSeriesOffset + index));
|
|
3789
|
+
const series = group.series.map((entry, index) => canonicalSeries?.get(entry.id) ?? applySeriesDefaults(entry, groupSeriesOffset + index));
|
|
3719
3790
|
groupSeriesOffset += group.series.length;
|
|
3720
3791
|
return { ...group, series };
|
|
3721
3792
|
});
|
|
@@ -3859,11 +3930,12 @@ function applyChartSeriesStyleFromXml(chart, chartTypeNode, themePalette) {
|
|
|
3859
3930
|
const rawFillColor = typeof existingShapeProperties?.solidFillHex === "string" ? normalizeHexColor(existingShapeProperties.solidFillHex) : null;
|
|
3860
3931
|
const rawLineColor = typeof existingShapeProperties?.lineColorHex === "string" ? normalizeHexColor(existingShapeProperties.lineColorHex) : null;
|
|
3861
3932
|
const resolvedLineColor = lineStyle.hidden ? void 0 : rawLineColor ?? lineStyle.color ?? rawFillColor ?? fillColor ?? series.lineColor ?? series.color;
|
|
3862
|
-
const hasCategoryReference = typeof series.categoriesRef?.formula === "string" && series.categoriesRef.formula.length > 0;
|
|
3863
|
-
const hasValueReference = typeof series.valuesRef?.formula === "string" && series.valuesRef.formula.length > 0;
|
|
3864
|
-
const hasBubbleSizeReference = typeof series.bubbleSizeRef?.formula === "string" && series.bubbleSizeRef.formula.length > 0;
|
|
3933
|
+
const hasCategoryReference = typeof series.categoriesRef?.formula === "string" && series.categoriesRef.formula.length > 0 && !series.raw?.unresolvedCategoriesReference;
|
|
3934
|
+
const hasValueReference = typeof series.valuesRef?.formula === "string" && series.valuesRef.formula.length > 0 && !series.raw?.unresolvedValuesReference;
|
|
3935
|
+
const hasBubbleSizeReference = typeof series.bubbleSizeRef?.formula === "string" && series.bubbleSizeRef.formula.length > 0 && !series.raw?.unresolvedBubbleSizeReference;
|
|
3865
3936
|
return {
|
|
3866
3937
|
...series,
|
|
3938
|
+
name: series.raw?.unresolvedNameReference ? parseChartCacheValues(getFirstLocalChild(seriesNode, "tx"), "strCache", "category")?.[0]?.toString() ?? series.name : series.name,
|
|
3867
3939
|
bubbleSizes: !hasBubbleSizeReference && cachedBubbleSizes ? cachedBubbleSizes.map((value) => typeof value === "number" && Number.isFinite(value) ? value : null) : series.bubbleSizes,
|
|
3868
3940
|
categories: !hasCategoryReference && cachedCategories ? cachedCategories : series.categories,
|
|
3869
3941
|
color: rawFillColor ?? rawLineColor ?? fillColor ?? lineStyle.color ?? series.color,
|
|
@@ -4123,6 +4195,23 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
4123
4195
|
if (typeof fallbackStyleId === "number" && Number.isFinite(fallbackStyleId)) {
|
|
4124
4196
|
chart.chartStyleId = fallbackStyleId;
|
|
4125
4197
|
}
|
|
4198
|
+
const sourceSeries = chart.raw?.officeSourceSeries;
|
|
4199
|
+
if (sourceSeries && chartDocument?.documentElement.namespaceURI === "http://schemas.microsoft.com/office/drawing/2014/chartex") {
|
|
4200
|
+
chart.renderSource = {
|
|
4201
|
+
kind: chart.chartExLayout ?? "",
|
|
4202
|
+
seriesTypes: getLocalDescendants(chartNode, "series").map((node) => node.getAttribute("layoutId") ?? ""),
|
|
4203
|
+
sourceSeries,
|
|
4204
|
+
experimental: true,
|
|
4205
|
+
xml: chartXml,
|
|
4206
|
+
themeColors: themePalette ? Object.fromEntries(Object.entries(THEME_COLOR_INDEX_BY_NAME).flatMap(([key, index]) => {
|
|
4207
|
+
const color = themePalette.colorsByIndex[index];
|
|
4208
|
+
return color ? [[key, color]] : [];
|
|
4209
|
+
})) : void 0,
|
|
4210
|
+
themeOverrideXml: readArchiveText(archive, relationships.get("http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride")) ?? void 0,
|
|
4211
|
+
styleXml: readArchiveText(archive, relationships.get(CHART_STYLE_REL_TYPE)) ?? void 0,
|
|
4212
|
+
colorStyleXml: readArchiveText(archive, relationships.get(CHART_COLOR_STYLE_REL_TYPE)) ?? void 0
|
|
4213
|
+
};
|
|
4214
|
+
}
|
|
4126
4215
|
applyModernChartExStyles();
|
|
4127
4216
|
applyFallbackSeriesStyles();
|
|
4128
4217
|
applyBuiltinChartDefaults(chart, themePalette);
|
|
@@ -4364,11 +4453,22 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
4364
4453
|
chart.axes = [...chart.axes, seriesAxis];
|
|
4365
4454
|
}
|
|
4366
4455
|
}
|
|
4367
|
-
const
|
|
4368
|
-
const
|
|
4369
|
-
|
|
4456
|
+
const groups = Array.from(plotArea.children).filter((entry) => entry.localName.endsWith("Chart"));
|
|
4457
|
+
const seriesTypes = groups.flatMap((group) => getLocalChildren(group, "ser").map(() => group.localName.slice(0, -5)));
|
|
4458
|
+
const seriesNodes = groups.flatMap((group) => getLocalChildren(group, "ser"));
|
|
4459
|
+
const indexedXSeries = seriesNodes.map((series) => {
|
|
4460
|
+
const x = getFirstLocalChild(series, "xVal");
|
|
4461
|
+
return Boolean(x && (getFirstLocalChild(x, "multiLvlStrRef") || getFirstLocalChild(x, "strRef") || getFirstLocalChild(x, "strLit")));
|
|
4462
|
+
});
|
|
4463
|
+
const unsupportedHierarchy = getLocalDescendants(plotArea, "multiLvlStrRef").some((node) => node.parentElement?.localName !== "xVal");
|
|
4464
|
+
const kind = chartTypeNode.localName.slice(0, -5);
|
|
4465
|
+
const stable = groups.length === 1 && !chart.is3d && (kind === "line" && chart.chartType === "Line" || kind === "bar" && chart.chartType === "ColumnClustered") && !plotArea.querySelector("trendline, errBars, dropLines, hiLowLines, upDownBars, dateAx, multiLvlStrRef, pictureOptions");
|
|
4466
|
+
if (seriesTypes.length === chart.series.length && !unsupportedHierarchy && !plotArea.querySelector("pictureOptions")) {
|
|
4370
4467
|
chart.renderSource = {
|
|
4371
4468
|
kind,
|
|
4469
|
+
seriesTypes,
|
|
4470
|
+
indexedXSeries,
|
|
4471
|
+
experimental: !stable,
|
|
4372
4472
|
xml: chartXml,
|
|
4373
4473
|
themeColors: themePalette ? Object.fromEntries(Object.entries(THEME_COLOR_INDEX_BY_NAME).flatMap(([key, index]) => {
|
|
4374
4474
|
const color = themePalette.colorsByIndex[index];
|
|
@@ -4379,7 +4479,21 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
4379
4479
|
colorStyleXml: readArchiveText(archive, relationships.get(CHART_COLOR_STYLE_REL_TYPE)) ?? void 0
|
|
4380
4480
|
};
|
|
4381
4481
|
}
|
|
4382
|
-
|
|
4482
|
+
if (groups.length > 1 && chart.typeGroups?.length === groups.length) {
|
|
4483
|
+
let seriesOffset = 0;
|
|
4484
|
+
const hydratedSeries = [];
|
|
4485
|
+
chart.typeGroups = chart.typeGroups.map((group, index) => {
|
|
4486
|
+
const count = getLocalChildren(groups[index], "ser").length;
|
|
4487
|
+
const groupChart = { ...chart, chartType: group.chartType, series: chart.series.slice(seriesOffset, seriesOffset + count) };
|
|
4488
|
+
applyChartSeriesStyleFromXml(groupChart, groups[index], themePalette);
|
|
4489
|
+
seriesOffset += count;
|
|
4490
|
+
hydratedSeries.push(...groupChart.series);
|
|
4491
|
+
return { ...group, series: groupChart.series };
|
|
4492
|
+
});
|
|
4493
|
+
chart.series = [...hydratedSeries, ...chart.series.slice(seriesOffset)];
|
|
4494
|
+
} else {
|
|
4495
|
+
applyChartSeriesStyleFromXml(chart, chartTypeNode, themePalette);
|
|
4496
|
+
}
|
|
4383
4497
|
applyFallbackSeriesStyles();
|
|
4384
4498
|
applyBuiltinChartDefaults(chart, themePalette);
|
|
4385
4499
|
}
|
|
@@ -4535,8 +4649,8 @@ function resolveReferenceSheet(workbook2, fallbackSheetIndex, formula) {
|
|
|
4535
4649
|
if (!formula) {
|
|
4536
4650
|
return {
|
|
4537
4651
|
range: null,
|
|
4538
|
-
sheet: workbook2.getSheet(fallbackSheetIndex),
|
|
4539
|
-
sheetName: workbook2.getSheet(fallbackSheetIndex)?.name ?? ""
|
|
4652
|
+
sheet: fallbackSheetIndex < workbook2.sheetCount ? workbook2.getSheet(fallbackSheetIndex) : null,
|
|
4653
|
+
sheetName: fallbackSheetIndex < workbook2.sheetCount ? workbook2.getSheet(fallbackSheetIndex)?.name ?? "" : ""
|
|
4540
4654
|
};
|
|
4541
4655
|
}
|
|
4542
4656
|
const trimmedFormula = formula.trim();
|
|
@@ -4553,8 +4667,8 @@ function resolveReferenceSheet(workbook2, fallbackSheetIndex, formula) {
|
|
|
4553
4667
|
if (!split) {
|
|
4554
4668
|
return {
|
|
4555
4669
|
range: parseA1Range(trimmedFormula),
|
|
4556
|
-
sheet: workbook2.getSheet(fallbackSheetIndex),
|
|
4557
|
-
sheetName: workbook2.getSheet(fallbackSheetIndex)?.name ?? ""
|
|
4670
|
+
sheet: fallbackSheetIndex < workbook2.sheetCount ? workbook2.getSheet(fallbackSheetIndex) : null,
|
|
4671
|
+
sheetName: fallbackSheetIndex < workbook2.sheetCount ? workbook2.getSheet(fallbackSheetIndex)?.name ?? "" : ""
|
|
4558
4672
|
};
|
|
4559
4673
|
}
|
|
4560
4674
|
try {
|
|
@@ -4566,8 +4680,8 @@ function resolveReferenceSheet(workbook2, fallbackSheetIndex, formula) {
|
|
|
4566
4680
|
} catch {
|
|
4567
4681
|
return {
|
|
4568
4682
|
range: parseA1Range(split.range),
|
|
4569
|
-
sheet:
|
|
4570
|
-
sheetName:
|
|
4683
|
+
sheet: null,
|
|
4684
|
+
sheetName: split.sheetName
|
|
4571
4685
|
};
|
|
4572
4686
|
}
|
|
4573
4687
|
}
|
|
@@ -4836,6 +4950,7 @@ function buildChartExParetoLineSeries(series, sourceRaw, index) {
|
|
|
4836
4950
|
});
|
|
4837
4951
|
return {
|
|
4838
4952
|
...series,
|
|
4953
|
+
id: series.id.replace(/-series-\d+$/, `-series-${index}`),
|
|
4839
4954
|
color: void 0,
|
|
4840
4955
|
lineColor: void 0,
|
|
4841
4956
|
markerColor: void 0,
|
|
@@ -5098,7 +5213,7 @@ function normalizeChartExChart(workbook2, workbookSheetIndex, visibleSheetIndex,
|
|
|
5098
5213
|
name: typeof drawing.name === "string" ? drawing.name : chartTitle,
|
|
5099
5214
|
overlap: void 0,
|
|
5100
5215
|
plotVisibleOnly: void 0,
|
|
5101
|
-
raw: chart,
|
|
5216
|
+
raw: { ...chart, officeSourceSeries: normalizedSeries },
|
|
5102
5217
|
radarStyle: void 0,
|
|
5103
5218
|
scatterStyle: void 0,
|
|
5104
5219
|
roundedCorners: void 0,
|
|
@@ -5566,7 +5681,13 @@ function normalizeChartSeries(workbook2, workbookSheetIndex, chartId, raw, index
|
|
|
5566
5681
|
name: resolveSeriesName(workbook2, workbookSheetIndex, series.name),
|
|
5567
5682
|
negativeColor: void 0,
|
|
5568
5683
|
negativeLineColor: void 0,
|
|
5569
|
-
raw:
|
|
5684
|
+
raw: {
|
|
5685
|
+
...series,
|
|
5686
|
+
unresolvedCategoriesReference: Boolean(categoriesRef?.formula && !resolveReferenceSheet(workbook2, workbookSheetIndex, categoriesRef.formula).sheet),
|
|
5687
|
+
unresolvedValuesReference: Boolean(valuesRef?.formula && !resolveReferenceSheet(workbook2, workbookSheetIndex, valuesRef.formula).sheet),
|
|
5688
|
+
unresolvedBubbleSizeReference: Boolean(bubbleSizeRef?.formula && !resolveReferenceSheet(workbook2, workbookSheetIndex, bubbleSizeRef.formula).sheet),
|
|
5689
|
+
unresolvedNameReference: typeof series.name === "string" && series.name.includes("!") && !resolveReferenceSheet(workbook2, workbookSheetIndex, series.name).sheet
|
|
5690
|
+
},
|
|
5570
5691
|
shapeProperties,
|
|
5571
5692
|
smooth: typeof series.smooth === "boolean" ? series.smooth : void 0,
|
|
5572
5693
|
values: resolveReferenceValues(workbook2, workbookSheetIndex, valuesRef, "value").map((value) => typeof value === "number" && Number.isFinite(value) ? value : null),
|
|
@@ -5628,12 +5749,15 @@ function buildTabs(workbook2, chartsheets2, visibleSheetIndexByWorkbookSheetInde
|
|
|
5628
5749
|
const slotIndex = typeof entry.index === "number" ? entry.index : index;
|
|
5629
5750
|
if (slotType === "chartsheet") {
|
|
5630
5751
|
const chartsheet = chartsheets2[slotIndex];
|
|
5752
|
+
const visibility2 = normalizeWorksheetVisibility(chartsheet?.raw?.visibility);
|
|
5753
|
+
if (!showHiddenSheets && visibility2 !== "visible") return [];
|
|
5631
5754
|
return chartsheet ? [{
|
|
5632
5755
|
chartsheetIndex: slotIndex,
|
|
5633
5756
|
id: `chartsheet-${slotIndex}`,
|
|
5634
5757
|
index,
|
|
5635
5758
|
kind: "chartsheet",
|
|
5636
|
-
name: chartsheet.name
|
|
5759
|
+
name: chartsheet.name,
|
|
5760
|
+
visibility: visibility2
|
|
5637
5761
|
}] : [];
|
|
5638
5762
|
}
|
|
5639
5763
|
const worksheet = workbook2.getSheet(slotIndex);
|
|
@@ -5737,9 +5861,24 @@ function applyChartOrigins(chartsByWorkbookSheetIndex2, chartOriginsById, archiv
|
|
|
5737
5861
|
});
|
|
5738
5862
|
}
|
|
5739
5863
|
}
|
|
5740
|
-
function hydrateWorkbookChartStyles(chartsByWorkbookSheetIndex2, imageAssets) {
|
|
5864
|
+
function hydrateWorkbookChartStyles(chartsByWorkbookSheetIndex2, imageAssets, chartsheets2 = []) {
|
|
5741
5865
|
const chartOriginsById = /* @__PURE__ */ new Map();
|
|
5742
5866
|
applyChartOrigins(chartsByWorkbookSheetIndex2, chartOriginsById, imageAssets.archive, imageAssets.sheetOrigins);
|
|
5867
|
+
const chartsheetOrigins = collectChartsheetDrawingOrigins(imageAssets.archive, chartsheets2);
|
|
5868
|
+
for (const chartsheet of chartsheets2) {
|
|
5869
|
+
if (chartsheet.workbookSheetIndex == null) continue;
|
|
5870
|
+
const charts = chartsByWorkbookSheetIndex2[chartsheet.workbookSheetIndex] ?? [];
|
|
5871
|
+
const origins = collectChartOriginsForSheet(imageAssets.archive, chartsheetOrigins.get(chartsheet.index) ?? null);
|
|
5872
|
+
for (const chart of charts) {
|
|
5873
|
+
const kind = chart.id.startsWith("chart-ex-") ? "modern" : "classic";
|
|
5874
|
+
const origin = origins.find((entry) => entry.chartKind === kind);
|
|
5875
|
+
if (!origin) continue;
|
|
5876
|
+
if (origin.anchor) chart.anchor = origin.anchor;
|
|
5877
|
+
chart.chartPath = origin.chartPath ?? void 0;
|
|
5878
|
+
chartsheet.chartPath = chart.chartPath;
|
|
5879
|
+
chartOriginsById.set(chart.id, origin);
|
|
5880
|
+
}
|
|
5881
|
+
}
|
|
5743
5882
|
for (const charts of chartsByWorkbookSheetIndex2) {
|
|
5744
5883
|
for (const chart of charts) {
|
|
5745
5884
|
applyChartStyleFromXml(chart, chart.chartPath, imageAssets.archive, imageAssets.themePalette);
|
|
@@ -5748,6 +5887,84 @@ function hydrateWorkbookChartStyles(chartsByWorkbookSheetIndex2, imageAssets) {
|
|
|
5748
5887
|
}
|
|
5749
5888
|
return chartOriginsById;
|
|
5750
5889
|
}
|
|
5890
|
+
function normalizeClassicChartDrawing(workbook2, workbookSheetIndex, visibleSheetIndex, rawChart, chartIndex, chartId = `chart-${workbookSheetIndex}-${chartIndex}`) {
|
|
5891
|
+
const drawing = rawChart && typeof rawChart === "object" ? rawChart : {};
|
|
5892
|
+
const chart = drawing.chart && typeof drawing.chart === "object" ? drawing.chart : {};
|
|
5893
|
+
const rawView3d = chart.view3D && typeof chart.view3D === "object" ? chart.view3D : null;
|
|
5894
|
+
const rawSeries = Array.isArray(chart.series) ? chart.series : [];
|
|
5895
|
+
const typeGroups = Array.isArray(chart.typeGroups) ? chart.typeGroups.map((entry, groupIndex) => normalizeChartTypeGroup(workbook2, workbookSheetIndex, chartId, entry, groupIndex)).filter((value) => value != null) : [];
|
|
5896
|
+
let seriesOrdinal = 0;
|
|
5897
|
+
const series = typeGroups.some((group) => group.series.length > 0) ? typeGroups.flatMap((group) => {
|
|
5898
|
+
group.series = group.series.map((entry) => ({ ...entry, id: `${chartId}-series-${seriesOrdinal++}` }));
|
|
5899
|
+
return group.series;
|
|
5900
|
+
}) : rawSeries.map((entry, seriesIndex) => normalizeChartSeries(workbook2, workbookSheetIndex, chartId, entry, seriesIndex));
|
|
5901
|
+
const chartLevelDataLabels = normalizeChartDataLabels(chart.dataLabels);
|
|
5902
|
+
const firstSeriesDataLabels = rawSeries.length > 0 && rawSeries[0] && typeof rawSeries[0] === "object" ? normalizeChartDataLabels(rawSeries[0].dataLabels) : null;
|
|
5903
|
+
return {
|
|
5904
|
+
anchor: normalizeChartAnchor(drawing.anchor),
|
|
5905
|
+
autoTitleDeleted: typeof chart.autoTitleDeleted === "boolean" ? chart.autoTitleDeleted : void 0,
|
|
5906
|
+
axes: Array.isArray(chart.axes) ? chart.axes.map(normalizeChartAxis).filter((value) => Boolean(value)) : [],
|
|
5907
|
+
axisLabelColor: void 0,
|
|
5908
|
+
axisLineColor: void 0,
|
|
5909
|
+
categoryAxis: normalizeChartAxis(chart.categoryAxis),
|
|
5910
|
+
chartAreaBorderColor: void 0,
|
|
5911
|
+
chartAreaFillColor: void 0,
|
|
5912
|
+
chartColorPalette: void 0,
|
|
5913
|
+
chartColorPaletteOffset: void 0,
|
|
5914
|
+
chartPath: void 0,
|
|
5915
|
+
chartStyleId: void 0,
|
|
5916
|
+
chartType: typeof chart.chartType === "string" ? chart.chartType : "ColumnClustered",
|
|
5917
|
+
dataLabels: chartLevelDataLabels ?? firstSeriesDataLabels,
|
|
5918
|
+
displayBlanksAs: typeof chart.displayBlanksAs === "string" ? chart.displayBlanksAs : void 0,
|
|
5919
|
+
editable: true,
|
|
5920
|
+
firstSliceAngle: typeof chart.firstSliceAngle === "number" ? chart.firstSliceAngle : void 0,
|
|
5921
|
+
fontFamily: void 0,
|
|
5922
|
+
gapWidth: typeof chart.gapWidth === "number" ? chart.gapWidth : void 0,
|
|
5923
|
+
holeSize: typeof chart.holeSize === "number" ? chart.holeSize : void 0,
|
|
5924
|
+
id: chartId,
|
|
5925
|
+
is3d: typeof chart.is3D === "boolean" ? chart.is3D : typeof chart.is3d === "boolean" ? chart.is3d : void 0,
|
|
5926
|
+
legend: normalizeLegend(chart.legend) ? {
|
|
5927
|
+
...normalizeLegend(chart.legend),
|
|
5928
|
+
position: normalizeLegendPosition(normalizeLegend(chart.legend)?.position)
|
|
5929
|
+
} : null,
|
|
5930
|
+
name: typeof drawing.name === "string" ? drawing.name : void 0,
|
|
5931
|
+
overlap: typeof chart.overlap === "number" ? chart.overlap : void 0,
|
|
5932
|
+
plotVisibleOnly: typeof chart.plotVisibleOnly === "boolean" ? chart.plotVisibleOnly : void 0,
|
|
5933
|
+
raw: chart,
|
|
5934
|
+
radarStyle: typeof chart.radarStyle === "string" ? chart.radarStyle : void 0,
|
|
5935
|
+
scatterStyle: typeof chart.scatterStyle === "string" ? chart.scatterStyle : void 0,
|
|
5936
|
+
roundedCorners: typeof chart.roundedCorners === "boolean" ? chart.roundedCorners : void 0,
|
|
5937
|
+
shape3d: typeof chart.shape === "string" ? chart.shape : typeof chart.shape3d === "string" ? chart.shape3d : void 0,
|
|
5938
|
+
seriesAxis: null,
|
|
5939
|
+
series,
|
|
5940
|
+
sheetIndex: visibleSheetIndex,
|
|
5941
|
+
showDlblsOverMax: typeof chart.showDlblsOverMax === "boolean" ? chart.showDlblsOverMax : void 0,
|
|
5942
|
+
sideWall: null,
|
|
5943
|
+
backWall: null,
|
|
5944
|
+
bubbleScale: typeof chart.bubbleScale === "number" ? chart.bubbleScale : void 0,
|
|
5945
|
+
bubble3d: typeof chart.bubble3d === "boolean" ? chart.bubble3d : void 0,
|
|
5946
|
+
floor: null,
|
|
5947
|
+
surfaceMaterial: void 0,
|
|
5948
|
+
textColor: void 0,
|
|
5949
|
+
title: typeof chart.title === "string" ? chart.title : void 0,
|
|
5950
|
+
titleColor: void 0,
|
|
5951
|
+
titleFontFamily: void 0,
|
|
5952
|
+
typeGroups,
|
|
5953
|
+
valueAxis: normalizeChartAxis(chart.valueAxis),
|
|
5954
|
+
varyColors: typeof chart.varyColors === "boolean" ? chart.varyColors : void 0,
|
|
5955
|
+
view3d: rawView3d ? {
|
|
5956
|
+
depthPercent: typeof rawView3d.depthPercent === "number" ? rawView3d.depthPercent : void 0,
|
|
5957
|
+
heightPercent: typeof rawView3d.heightPercent === "number" ? rawView3d.heightPercent : void 0,
|
|
5958
|
+
perspective: typeof rawView3d.perspective === "number" ? rawView3d.perspective : void 0,
|
|
5959
|
+
rAngAx: typeof rawView3d.rAngAx === "boolean" ? rawView3d.rAngAx : typeof rawView3d.rightAngleAxes === "boolean" ? rawView3d.rightAngleAxes : void 0,
|
|
5960
|
+
rotX: typeof rawView3d.rotX === "number" ? rawView3d.rotX : typeof rawView3d.rotateX === "number" ? rawView3d.rotateX : void 0,
|
|
5961
|
+
rotY: typeof rawView3d.rotY === "number" ? rawView3d.rotY : typeof rawView3d.rotateY === "number" ? rawView3d.rotateY : void 0
|
|
5962
|
+
} : void 0,
|
|
5963
|
+
wireframe: typeof chart.wireframe === "boolean" ? chart.wireframe : void 0,
|
|
5964
|
+
workbookSheetIndex,
|
|
5965
|
+
zIndex: Array.isArray(drawing.drawingPath) && typeof drawing.drawingPath[0] === "number" ? drawing.drawingPath[0] + 1 : chartIndex + 1
|
|
5966
|
+
};
|
|
5967
|
+
}
|
|
5751
5968
|
function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWorkbookSheetIndex, showHiddenSheets = false) {
|
|
5752
5969
|
const excludedChartIds = /* @__PURE__ */ new Set();
|
|
5753
5970
|
const chartsByWorkbookSheetIndex2 = Array.from({ length: workbook2.sheetCount }, (_, workbookSheetIndex) => {
|
|
@@ -5760,76 +5977,7 @@ function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWork
|
|
|
5760
5977
|
if (rawChart.hidden || !rawChart.anchor) {
|
|
5761
5978
|
excludedChartIds.add(chartId);
|
|
5762
5979
|
}
|
|
5763
|
-
|
|
5764
|
-
const chart = drawing.chart && typeof drawing.chart === "object" ? drawing.chart : {};
|
|
5765
|
-
const rawView3d = chart.view3D && typeof chart.view3D === "object" ? chart.view3D : null;
|
|
5766
|
-
const rawSeries = Array.isArray(chart.series) ? chart.series : [];
|
|
5767
|
-
const chartLevelDataLabels = normalizeChartDataLabels(chart.dataLabels);
|
|
5768
|
-
const firstSeriesDataLabels = rawSeries.length > 0 && rawSeries[0] && typeof rawSeries[0] === "object" ? normalizeChartDataLabels(rawSeries[0].dataLabels) : null;
|
|
5769
|
-
return {
|
|
5770
|
-
anchor: normalizeChartAnchor(drawing.anchor),
|
|
5771
|
-
autoTitleDeleted: typeof chart.autoTitleDeleted === "boolean" ? chart.autoTitleDeleted : void 0,
|
|
5772
|
-
axes: Array.isArray(chart.axes) ? chart.axes.map(normalizeChartAxis).filter((value) => Boolean(value)) : [],
|
|
5773
|
-
axisLabelColor: void 0,
|
|
5774
|
-
axisLineColor: void 0,
|
|
5775
|
-
categoryAxis: normalizeChartAxis(chart.categoryAxis),
|
|
5776
|
-
chartAreaBorderColor: void 0,
|
|
5777
|
-
chartAreaFillColor: void 0,
|
|
5778
|
-
chartColorPalette: void 0,
|
|
5779
|
-
chartColorPaletteOffset: void 0,
|
|
5780
|
-
chartPath: void 0,
|
|
5781
|
-
chartStyleId: void 0,
|
|
5782
|
-
chartType: typeof chart.chartType === "string" ? chart.chartType : "ColumnClustered",
|
|
5783
|
-
dataLabels: chartLevelDataLabels ?? firstSeriesDataLabels,
|
|
5784
|
-
displayBlanksAs: typeof chart.displayBlanksAs === "string" ? chart.displayBlanksAs : void 0,
|
|
5785
|
-
editable: true,
|
|
5786
|
-
firstSliceAngle: typeof chart.firstSliceAngle === "number" ? chart.firstSliceAngle : void 0,
|
|
5787
|
-
fontFamily: void 0,
|
|
5788
|
-
gapWidth: typeof chart.gapWidth === "number" ? chart.gapWidth : void 0,
|
|
5789
|
-
holeSize: typeof chart.holeSize === "number" ? chart.holeSize : void 0,
|
|
5790
|
-
id: chartId,
|
|
5791
|
-
is3d: typeof chart.is3D === "boolean" ? chart.is3D : void 0,
|
|
5792
|
-
legend: normalizeLegend(chart.legend) ? {
|
|
5793
|
-
...normalizeLegend(chart.legend),
|
|
5794
|
-
position: normalizeLegendPosition(normalizeLegend(chart.legend)?.position)
|
|
5795
|
-
} : null,
|
|
5796
|
-
name: typeof drawing.name === "string" ? drawing.name : void 0,
|
|
5797
|
-
overlap: typeof chart.overlap === "number" ? chart.overlap : void 0,
|
|
5798
|
-
plotVisibleOnly: typeof chart.plotVisibleOnly === "boolean" ? chart.plotVisibleOnly : void 0,
|
|
5799
|
-
raw: chart,
|
|
5800
|
-
radarStyle: typeof chart.radarStyle === "string" ? chart.radarStyle : void 0,
|
|
5801
|
-
scatterStyle: typeof chart.scatterStyle === "string" ? chart.scatterStyle : void 0,
|
|
5802
|
-
roundedCorners: typeof chart.roundedCorners === "boolean" ? chart.roundedCorners : void 0,
|
|
5803
|
-
shape3d: typeof chart.shape === "string" ? chart.shape : typeof chart.shape3d === "string" ? chart.shape3d : void 0,
|
|
5804
|
-
seriesAxis: null,
|
|
5805
|
-
series: rawSeries.map((entry, seriesIndex) => normalizeChartSeries(workbook2, workbookSheetIndex, chartId, entry, seriesIndex)),
|
|
5806
|
-
sheetIndex: visibleSheetIndex,
|
|
5807
|
-
showDlblsOverMax: typeof chart.showDlblsOverMax === "boolean" ? chart.showDlblsOverMax : void 0,
|
|
5808
|
-
sideWall: null,
|
|
5809
|
-
backWall: null,
|
|
5810
|
-
bubbleScale: typeof chart.bubbleScale === "number" ? chart.bubbleScale : void 0,
|
|
5811
|
-
bubble3d: typeof chart.bubble3d === "boolean" ? chart.bubble3d : void 0,
|
|
5812
|
-
floor: null,
|
|
5813
|
-
surfaceMaterial: void 0,
|
|
5814
|
-
textColor: void 0,
|
|
5815
|
-
title: typeof chart.title === "string" ? chart.title : void 0,
|
|
5816
|
-
titleColor: void 0,
|
|
5817
|
-
titleFontFamily: void 0,
|
|
5818
|
-
typeGroups: Array.isArray(chart.typeGroups) ? chart.typeGroups.map((entry, groupIndex) => normalizeChartTypeGroup(workbook2, workbookSheetIndex, chartId, entry, groupIndex)).filter((value) => value != null) : [],
|
|
5819
|
-
valueAxis: normalizeChartAxis(chart.valueAxis),
|
|
5820
|
-
varyColors: typeof chart.varyColors === "boolean" ? chart.varyColors : void 0,
|
|
5821
|
-
view3d: rawView3d ? {
|
|
5822
|
-
depthPercent: typeof rawView3d.depthPercent === "number" ? rawView3d.depthPercent : void 0,
|
|
5823
|
-
heightPercent: typeof rawView3d.heightPercent === "number" ? rawView3d.heightPercent : void 0,
|
|
5824
|
-
perspective: typeof rawView3d.perspective === "number" ? rawView3d.perspective : void 0,
|
|
5825
|
-
rAngAx: typeof rawView3d.rAngAx === "boolean" ? rawView3d.rAngAx : typeof rawView3d.rightAngleAxes === "boolean" ? rawView3d.rightAngleAxes : void 0,
|
|
5826
|
-
rotX: typeof rawView3d.rotX === "number" ? rawView3d.rotX : typeof rawView3d.rotateX === "number" ? rawView3d.rotateX : void 0,
|
|
5827
|
-
rotY: typeof rawView3d.rotY === "number" ? rawView3d.rotY : typeof rawView3d.rotateY === "number" ? rawView3d.rotateY : void 0
|
|
5828
|
-
} : void 0,
|
|
5829
|
-
wireframe: typeof chart.wireframe === "boolean" ? chart.wireframe : void 0,
|
|
5830
|
-
workbookSheetIndex,
|
|
5831
|
-
zIndex: Array.isArray(drawing.drawingPath) && typeof drawing.drawingPath[0] === "number" ? drawing.drawingPath[0] + 1 : chartIndex + 1
|
|
5832
|
-
};
|
|
5980
|
+
return normalizeClassicChartDrawing(workbook2, workbookSheetIndex, visibleSheetIndex, rawChart, chartIndex, chartId);
|
|
5833
5981
|
});
|
|
5834
5982
|
const modernCharts = rawChartsEx.map((rawChartEx, chartExIndex) => {
|
|
5835
5983
|
const chartId = `chart-ex-${workbookSheetIndex}-${chartExIndex}`;
|
|
@@ -5848,8 +5996,36 @@ function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWork
|
|
|
5848
5996
|
return [...classicCharts, ...modernCharts];
|
|
5849
5997
|
});
|
|
5850
5998
|
const chartsheets2 = Array.isArray(workbook2.chartsheets) ? workbook2.chartsheets.map((entry, index) => normalizeChartsheet(entry, index)) : [];
|
|
5999
|
+
for (const chartsheet of chartsheets2) {
|
|
6000
|
+
const workbookSheetIndex = workbook2.sheetCount + chartsheet.index;
|
|
6001
|
+
const raw = chartsheet.raw;
|
|
6002
|
+
const charts = [];
|
|
6003
|
+
if (raw?.chart && typeof raw.chart === "object") {
|
|
6004
|
+
charts.push(normalizeClassicChartDrawing(
|
|
6005
|
+
workbook2,
|
|
6006
|
+
workbookSheetIndex,
|
|
6007
|
+
workbookSheetIndex,
|
|
6008
|
+
raw,
|
|
6009
|
+
0,
|
|
6010
|
+
`${chartsheet.id}-chart-0`
|
|
6011
|
+
));
|
|
6012
|
+
}
|
|
6013
|
+
if (raw?.chartEx && typeof raw.chartEx === "object") {
|
|
6014
|
+
charts.push(normalizeChartExChart(
|
|
6015
|
+
workbook2,
|
|
6016
|
+
workbookSheetIndex,
|
|
6017
|
+
workbookSheetIndex,
|
|
6018
|
+
raw,
|
|
6019
|
+
0,
|
|
6020
|
+
imageAssets?.themePalette ?? null
|
|
6021
|
+
));
|
|
6022
|
+
}
|
|
6023
|
+
chartsByWorkbookSheetIndex2[workbookSheetIndex] = charts;
|
|
6024
|
+
chartsheet.chartIds = charts.map((chart) => chart.id);
|
|
6025
|
+
chartsheet.workbookSheetIndex = workbookSheetIndex;
|
|
6026
|
+
}
|
|
5851
6027
|
const tabs2 = buildTabs(workbook2, chartsheets2, visibleSheetIndexByWorkbookSheetIndex, showHiddenSheets);
|
|
5852
|
-
const chartOriginsById = imageAssets ? hydrateWorkbookChartStyles(chartsByWorkbookSheetIndex2, imageAssets) : /* @__PURE__ */ new Map();
|
|
6028
|
+
const chartOriginsById = imageAssets ? hydrateWorkbookChartStyles(chartsByWorkbookSheetIndex2, imageAssets, chartsheets2) : /* @__PURE__ */ new Map();
|
|
5853
6029
|
if (imageAssets) {
|
|
5854
6030
|
for (let index = 0; index < chartsByWorkbookSheetIndex2.length; index += 1) {
|
|
5855
6031
|
chartsByWorkbookSheetIndex2[index] = (chartsByWorkbookSheetIndex2[index] ?? []).filter((chart) => !excludedChartIds.has(chart.id));
|
|
@@ -6012,7 +6188,7 @@ function getCellGeneralAlignment(worksheet, row, col) {
|
|
|
6012
6188
|
}
|
|
6013
6189
|
|
|
6014
6190
|
// src/images.ts
|
|
6015
|
-
var
|
|
6191
|
+
var REL_NS2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
6016
6192
|
var SPREADSHEET_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
6017
6193
|
var DRAWING_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing";
|
|
6018
6194
|
var EMU_PER_PIXEL2 = 9525;
|
|
@@ -6047,6 +6223,19 @@ function measureColumnCharacterWidthPx(fontFamily, fontSizePt) {
|
|
|
6047
6223
|
columnCharacterWidthCache.set(cacheKey, width);
|
|
6048
6224
|
return width;
|
|
6049
6225
|
}
|
|
6226
|
+
function measureOfficeDigitWidthPt(fontFamily, fontSizePt) {
|
|
6227
|
+
const family = fontFamily?.trim() || "Calibri";
|
|
6228
|
+
const size = typeof fontSizePt === "number" && fontSizePt > 0 ? fontSizePt : 11;
|
|
6229
|
+
const key = `office|${family}|${size}`;
|
|
6230
|
+
const cached = columnCharacterWidthCache.get(key);
|
|
6231
|
+
if (cached !== void 0) return cached;
|
|
6232
|
+
const context = typeof document !== "undefined" ? document.createElement("canvas").getContext("2d") : null;
|
|
6233
|
+
if (!context) return 6;
|
|
6234
|
+
context.font = `${size}px ${JSON.stringify(family)}, "React XLSX Carlito"`;
|
|
6235
|
+
const width = Math.max(1, Math.round(Math.max(...Array.from("0123456789", (digit) => context.measureText(digit).width))));
|
|
6236
|
+
columnCharacterWidthCache.set(key, width);
|
|
6237
|
+
return width;
|
|
6238
|
+
}
|
|
6050
6239
|
function sheetColumnWidthToPixels(width, columnCharacterWidthPx = DEFAULT_COLUMN_CHARACTER_WIDTH_PX) {
|
|
6051
6240
|
if (!Number.isFinite(width) || width <= 0) {
|
|
6052
6241
|
return MIN_COL_WIDTH_PX;
|
|
@@ -6271,7 +6460,7 @@ function readFeaturePropertyBagCheckboxComplements(archive) {
|
|
|
6271
6460
|
return checkboxComplementIndices;
|
|
6272
6461
|
}
|
|
6273
6462
|
function getRelationshipId(element) {
|
|
6274
|
-
return element.getAttributeNS(
|
|
6463
|
+
return element.getAttributeNS(REL_NS2, "id") ?? element.getAttribute("r:id") ?? element.getAttribute("id");
|
|
6275
6464
|
}
|
|
6276
6465
|
function parseContentTypes(archive) {
|
|
6277
6466
|
const xml = readArchiveText2(archive, "[Content_Types].xml");
|
|
@@ -7112,6 +7301,18 @@ function parseSheetState(archive, path, options) {
|
|
|
7112
7301
|
options?.defaultFont?.sizePt
|
|
7113
7302
|
);
|
|
7114
7303
|
const defaultRowHeight = Number(sheetFormatNode?.getAttribute("defaultRowHeight") ?? 15);
|
|
7304
|
+
const digitWidthPt = measureOfficeDigitWidthPt(options?.defaultFont?.family, options?.defaultFont?.sizePt);
|
|
7305
|
+
const storedColumnPixels = (width) => Math.max(0, Math.floor(
|
|
7306
|
+
(256 * width + Math.floor(128 / digitWidthPt)) / 256 * digitWidthPt
|
|
7307
|
+
) * (4 / 3));
|
|
7308
|
+
const explicitDefaultWidth = Number(sheetFormatNode?.getAttribute("defaultColWidth") ?? Number.NaN);
|
|
7309
|
+
const baseWidth = Number(sheetFormatNode?.getAttribute("baseColWidth") ?? 8);
|
|
7310
|
+
const officeLayout = {
|
|
7311
|
+
defaultColumnPx: Number.isFinite(explicitDefaultWidth) && explicitDefaultWidth > 0 ? storedColumnPixels(explicitDefaultWidth) : ((Number.isFinite(baseWidth) && baseWidth > 0 ? baseWidth : 8) * digitWidthPt + 5) * (4 / 3),
|
|
7312
|
+
defaultRowPx: (Number.isFinite(defaultRowHeight) && defaultRowHeight > 0 ? defaultRowHeight : 15) * (4 / 3),
|
|
7313
|
+
columns: {},
|
|
7314
|
+
rows: {}
|
|
7315
|
+
};
|
|
7115
7316
|
const defaultColWidth = Number(
|
|
7116
7317
|
sheetFormatNode?.getAttribute("defaultColWidth") ?? sheetFormatNode?.getAttribute("baseColWidth") ?? 8.43
|
|
7117
7318
|
);
|
|
@@ -7145,6 +7346,7 @@ function parseSheetState(archive, path, options) {
|
|
|
7145
7346
|
const styleId = Number(rowNode.getAttribute("s") ?? Number.NaN);
|
|
7146
7347
|
if (rowIndex >= 0 && Number.isFinite(height)) {
|
|
7147
7348
|
rowHeightOverridesPx[rowIndex] = Math.max(MIN_ROW_HEIGHT_PX, Math.round(height * 1.33));
|
|
7349
|
+
officeLayout.rows[rowIndex] = { sourcePx: rowHeightOverridesPx[rowIndex], sizePx: Math.max(0, height * (4 / 3)) };
|
|
7148
7350
|
}
|
|
7149
7351
|
if (rowIndex >= 0 && Number.isFinite(styleId)) {
|
|
7150
7352
|
rowStyleIds[rowIndex] = styleId;
|
|
@@ -7183,6 +7385,7 @@ function parseSheetState(archive, path, options) {
|
|
|
7183
7385
|
if (Number.isFinite(width)) {
|
|
7184
7386
|
const widthPx = sheetColumnWidthToPixels(width, columnWidthCharacterWidthPx);
|
|
7185
7387
|
colWidthOverridesPx[col] = widthPx;
|
|
7388
|
+
officeLayout.columns[col] = { sourcePx: widthPx, sizePx: storedColumnPixels(width) };
|
|
7186
7389
|
}
|
|
7187
7390
|
if (Number.isFinite(styleId)) {
|
|
7188
7391
|
colStyleIds[col] = styleId;
|
|
@@ -7199,6 +7402,7 @@ function parseSheetState(archive, path, options) {
|
|
|
7199
7402
|
colStyleIds,
|
|
7200
7403
|
conditionalFormatRules,
|
|
7201
7404
|
defaultColWidthPx: sheetColumnWidthToPixels(defaultColWidth, columnWidthCharacterWidthPx),
|
|
7405
|
+
officeLayout,
|
|
7202
7406
|
defaultRowHeightPx: Math.max(MIN_ROW_HEIGHT_PX, Math.round(defaultRowHeight * 1.33)),
|
|
7203
7407
|
hasHorizontalMerges: false,
|
|
7204
7408
|
hasVerticalMerges: false,
|
|
@@ -8018,6 +8222,7 @@ function buildSheetList(nextWorkbook, themePalette, structureAssets, sheetLayout
|
|
|
8018
8222
|
colWidths: [],
|
|
8019
8223
|
conditionalFormatRules: sheetState?.conditionalFormatRules ?? [],
|
|
8020
8224
|
dataValidations: parseWorksheetDataValidations(worksheet),
|
|
8225
|
+
officeLayout: sheetState?.officeLayout,
|
|
8021
8226
|
defaultColWidthPx,
|
|
8022
8227
|
defaultRowHeightPx,
|
|
8023
8228
|
freezePanes: parseWorksheetFreezePanes(worksheet),
|
|
@@ -8081,6 +8286,7 @@ function buildSheetList(nextWorkbook, themePalette, structureAssets, sheetLayout
|
|
|
8081
8286
|
colWidths: visibleCols.map(resolveColumnWidthPx),
|
|
8082
8287
|
conditionalFormatRules: sheetState?.conditionalFormatRules ?? [],
|
|
8083
8288
|
dataValidations: parseWorksheetDataValidations(worksheet),
|
|
8289
|
+
officeLayout: sheetState?.officeLayout,
|
|
8084
8290
|
defaultColWidthPx,
|
|
8085
8291
|
defaultRowHeightPx,
|
|
8086
8292
|
freezePanes: parseWorksheetFreezePanes(worksheet),
|
|
@@ -8278,7 +8484,7 @@ async function loadWorkbook(buffer, skipXmlParsing = false, showHiddenSheets = f
|
|
|
8278
8484
|
)
|
|
8279
8485
|
);
|
|
8280
8486
|
const visibleSheetIndexByWorkbookSheetIndex = new Map(sheets.map((sheet, index) => [sheet.workbookSheetIndex, index]));
|
|
8281
|
-
const hasCharts = Array.from({ length: nextWorkbook.sheetCount }, (_, workbookSheetIndex) => {
|
|
8487
|
+
const hasCharts = nextWorkbook.chartsheetCount > 0 || Array.from({ length: nextWorkbook.sheetCount }, (_, workbookSheetIndex) => {
|
|
8282
8488
|
const worksheet = nextWorkbook.getSheet(workbookSheetIndex);
|
|
8283
8489
|
const hasClassicCharts = Array.isArray(worksheet.charts) && worksheet.charts.length > 0;
|
|
8284
8490
|
const hasModernCharts = Array.isArray(worksheet.chartsEx) && worksheet.chartsEx.length > 0;
|