@extend-ai/react-xlsx 0.17.3 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -0
- package/dist/Carlito-OFL.txt +94 -0
- package/dist/chart-renderer-HQSQHDCB.js +5040 -0
- package/dist/chart-renderer-HQSQHDCB.js.map +1 -0
- package/dist/chart-renderer-ZUWRNNZT.cjs +5041 -0
- package/dist/chart-renderer-ZUWRNNZT.cjs.map +1 -0
- package/dist/chunk-5ERNVHSO.cjs +94 -0
- package/dist/chunk-5ERNVHSO.cjs.map +1 -0
- package/dist/chunk-BAAMDEDS.js +104 -0
- package/dist/chunk-BAAMDEDS.js.map +1 -0
- package/dist/chunk-E2VSYCP2.cjs +104 -0
- package/dist/chunk-E2VSYCP2.cjs.map +1 -0
- package/dist/chunk-FO6MIHX4.cjs +8 -0
- package/dist/chunk-FO6MIHX4.cjs.map +1 -0
- package/dist/chunk-OZLJPZUX.js +70 -0
- package/dist/chunk-OZLJPZUX.js.map +1 -0
- package/dist/chunk-VWGKYABF.js +94 -0
- package/dist/chunk-VWGKYABF.js.map +1 -0
- package/dist/chunk-WFQGZI2Z.cjs +70 -0
- package/dist/chunk-WFQGZI2Z.cjs.map +1 -0
- package/dist/index.cjs +2739 -9039
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -4
- package/dist/index.d.ts +53 -4
- package/dist/index.js +980 -7247
- package/dist/index.js.map +1 -1
- package/dist/region-map-geography-5E5SVPGS.cjs +184 -0
- package/dist/region-map-geography-5E5SVPGS.cjs.map +1 -0
- package/dist/region-map-geography-YD54DI3H.js +182 -0
- package/dist/region-map-geography-YD54DI3H.js.map +1 -0
- package/dist/spreadsheet-font-assets-7QMV43XD.cjs +121 -0
- package/dist/spreadsheet-font-assets-7QMV43XD.cjs.map +1 -0
- package/dist/spreadsheet-font-assets-V366MXRM.js +119 -0
- package/dist/spreadsheet-font-assets-V366MXRM.js.map +1 -0
- package/dist/surface-regl-NWR5ZZ5D.js +720 -0
- package/dist/surface-regl-NWR5ZZ5D.js.map +1 -0
- package/dist/surface-regl-WVLW3SEA.cjs +721 -0
- package/dist/surface-regl-WVLW3SEA.cjs.map +1 -0
- package/dist/xlsx-worker.js +234 -267
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
package/dist/xlsx-worker.js
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
// src/xlsx-worker.ts
|
|
2
2
|
import { strFromU8 as strFromU83, unzipSync as unzipSync2 } from "fflate";
|
|
3
3
|
|
|
4
|
+
// src/builtin-chart-styles.ts
|
|
5
|
+
function decodeSrgb(channel) {
|
|
6
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
7
|
+
}
|
|
8
|
+
function encodeSrgb(channel) {
|
|
9
|
+
return channel <= 31308e-7 ? channel * 12.92 : 1.055 * channel ** (1 / 2.4) - 0.055;
|
|
10
|
+
}
|
|
11
|
+
function quantizeLinear(channel) {
|
|
12
|
+
return Math.round(channel * 1e5) / 1e5;
|
|
13
|
+
}
|
|
14
|
+
function resolveBuiltinChartColor(color, colorsByIndex) {
|
|
15
|
+
if (!color) return void 0;
|
|
16
|
+
const hex = colorsByIndex[color.themeIndex]?.replace(/^#/, "");
|
|
17
|
+
if (!hex || !/^[\da-f]{6}$/i.test(hex)) return void 0;
|
|
18
|
+
if (color.transforms.length === 0) return `#${hex.toLowerCase()}`;
|
|
19
|
+
const channels = [0, 2, 4].map((offset) => Math.fround(quantizeLinear(decodeSrgb(Number.parseInt(hex.slice(offset, offset + 2), 16) / 255))));
|
|
20
|
+
for (const transform of color.transforms) {
|
|
21
|
+
const amount = Math.fround(Math.max(0, Math.min(1, transform.value)));
|
|
22
|
+
for (let index = 0; index < channels.length; index += 1) {
|
|
23
|
+
const channel = channels[index];
|
|
24
|
+
channels[index] = transform.type === "tint" ? Math.fround(Math.fround(1 - amount) + Math.fround(amount * channel)) : Math.fround(amount * channel);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return `#${channels.map((channel) => Math.round(encodeSrgb(quantizeLinear(channel)) * 255).toString(16).padStart(2, "0")).join("")}`;
|
|
28
|
+
}
|
|
29
|
+
var GRAYSCALE_TINTS = [88, 55, 78, 92, 70, 30];
|
|
30
|
+
var DARK_GRAYSCALE_TINTS = [5, 55, 78, 15, 70, 30];
|
|
31
|
+
function normalizeClassicStyle(styleId) {
|
|
32
|
+
if (styleId === void 0 || !Number.isInteger(styleId)) return void 0;
|
|
33
|
+
if (styleId >= 1 && styleId <= 48) return styleId;
|
|
34
|
+
if (styleId >= 101 && styleId <= 148) return styleId - 100;
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
function themeColor(themeIndex, tint) {
|
|
38
|
+
return {
|
|
39
|
+
themeIndex,
|
|
40
|
+
transforms: tint === void 0 ? [] : [{ type: "tint", value: tint / 100 }]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function appendBrightness(color, percent) {
|
|
44
|
+
if (percent > 0) color.transforms.push({ type: "tint", value: (100 - percent) / 100 });
|
|
45
|
+
if (percent < 0) color.transforms.push({ type: "shade", value: (100 + percent) / 100 });
|
|
46
|
+
return color;
|
|
47
|
+
}
|
|
48
|
+
function getBuiltinChartColor(styleId, index, count) {
|
|
49
|
+
const style = normalizeClassicStyle(styleId);
|
|
50
|
+
if (style === void 0 || !Number.isInteger(index) || index < 0 || !Number.isInteger(count) || count < 1) {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
const palette = style === 41 ? 9 : (style - 1) % 8 + 1;
|
|
54
|
+
const monochrome = palette >= 3 && palette <= 8;
|
|
55
|
+
const color = monochrome ? themeColor(palette + 1) : palette === 2 ? themeColor(4 + index % 6) : themeColor(1, (palette === 9 ? DARK_GRAYSCALE_TINTS : GRAYSCALE_TINTS)[index % 6]);
|
|
56
|
+
const numerator = 140 * (monochrome ? index + 1 : Math.floor(index / 6) + 1);
|
|
57
|
+
const denominator = monochrome ? count + 1 : Math.floor(count / 6) + 2;
|
|
58
|
+
const brightness = (Math.trunc(Math.fround(Math.fround(numerator) / Math.fround(denominator))) - 70) % 100;
|
|
59
|
+
return appendBrightness(color, brightness);
|
|
60
|
+
}
|
|
61
|
+
function getBuiltinChartSurfaceStyle(styleId) {
|
|
62
|
+
const style = normalizeClassicStyle(styleId);
|
|
63
|
+
if (style === void 0) return void 0;
|
|
64
|
+
let fill = null;
|
|
65
|
+
if (style === 33 || style === 34) fill = themeColor(1, 20);
|
|
66
|
+
if (style >= 35 && style <= 40) fill = themeColor(style - 31, (styleId ?? 0) >= 100 ? 20 : void 0);
|
|
67
|
+
if (style >= 41) fill = themeColor(1, 95);
|
|
68
|
+
return {
|
|
69
|
+
floor: { fill, line: style <= 40 ? themeColor(1, 75) : null },
|
|
70
|
+
wall: { fill, line: null },
|
|
71
|
+
majorGridline: themeColor(1, (styleId ?? 0) >= 100 ? 75 : void 0),
|
|
72
|
+
minorGridline: themeColor(1, style >= 41 ? 90 : 50)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
4
76
|
// src/charts.ts
|
|
5
77
|
import { strFromU8, strToU8 } from "fflate";
|
|
6
78
|
var CHART_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
|
@@ -223,63 +295,6 @@ function parseFallbackBubbleSizesFromChartXml(chartXml) {
|
|
|
223
295
|
return parseNumericPointCacheFromXmlFragment(bubbleSizeBlock);
|
|
224
296
|
});
|
|
225
297
|
}
|
|
226
|
-
function decodeChartXmlText(value) {
|
|
227
|
-
return value.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
|
|
228
|
-
}
|
|
229
|
-
function normalizeChartTitleForMatch(value) {
|
|
230
|
-
return (value ?? "").trim().replace(/\s+/g, " ").toLowerCase();
|
|
231
|
-
}
|
|
232
|
-
function extractChartTitleFromXml(chartXml) {
|
|
233
|
-
const match = chartXml.match(/<c:title\b[\s\S]*?<a:t>([\s\S]*?)<\/a:t>/i);
|
|
234
|
-
if (!match?.[1]) {
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
|
-
const decoded = decodeChartXmlText(match[1]).trim();
|
|
238
|
-
return decoded.length > 0 ? decoded : null;
|
|
239
|
-
}
|
|
240
|
-
function resolveArchiveFallbackBubbleSizes(archive, preferredTitle) {
|
|
241
|
-
const preferred = normalizeChartTitleForMatch(preferredTitle);
|
|
242
|
-
let bestScore = Number.NEGATIVE_INFINITY;
|
|
243
|
-
let bestCandidate = [];
|
|
244
|
-
for (const [path, bytes] of Object.entries(archive)) {
|
|
245
|
-
if (!/\/charts\/chart\d+\.xml$/i.test(path)) {
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
const chartXml = strFromU8(bytes);
|
|
249
|
-
if (!/<c:bubbleChart\b/i.test(chartXml)) {
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
const candidateBubbleSizes = parseFallbackBubbleSizesFromChartXml(chartXml);
|
|
253
|
-
const hasCandidateValues = candidateBubbleSizes.some((seriesValues) => seriesValues.some((value) => value != null));
|
|
254
|
-
if (!hasCandidateValues) {
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
let score = 0;
|
|
258
|
-
const candidateTitle = normalizeChartTitleForMatch(extractChartTitleFromXml(chartXml));
|
|
259
|
-
if (preferred.length > 0 && candidateTitle.length > 0 && preferred === candidateTitle) {
|
|
260
|
-
score += 100;
|
|
261
|
-
}
|
|
262
|
-
if (bestCandidate.length === 0) {
|
|
263
|
-
score += 1;
|
|
264
|
-
}
|
|
265
|
-
if (score > bestScore) {
|
|
266
|
-
bestScore = score;
|
|
267
|
-
bestCandidate = candidateBubbleSizes;
|
|
268
|
-
if (score >= 100) {
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return bestCandidate;
|
|
274
|
-
}
|
|
275
|
-
function parseChartTypeFromXml(chartXml) {
|
|
276
|
-
for (const chartType of PRIMARY_CHART_TYPE_LOCAL_NAMES) {
|
|
277
|
-
if (new RegExp(`<c:${chartType}\\b`, "i").test(chartXml)) {
|
|
278
|
-
return chartType;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return "";
|
|
282
|
-
}
|
|
283
298
|
function findPrimaryChartTypeNode(plotAreaNode) {
|
|
284
299
|
if (!plotAreaNode) {
|
|
285
300
|
return null;
|
|
@@ -304,46 +319,6 @@ function resolveScatterChartType(scatterStyle) {
|
|
|
304
319
|
return "Scatter";
|
|
305
320
|
}
|
|
306
321
|
}
|
|
307
|
-
function resolveArchiveFallbackPointStyles(archive, preferredTitle, preferredChartXmlType, themePalette) {
|
|
308
|
-
const preferred = normalizeChartTitleForMatch(preferredTitle);
|
|
309
|
-
const preferredType = (preferredChartXmlType ?? "").trim();
|
|
310
|
-
let bestScore = Number.NEGATIVE_INFINITY;
|
|
311
|
-
let bestCandidate = [];
|
|
312
|
-
for (const [path, bytes] of Object.entries(archive)) {
|
|
313
|
-
if (!/\/charts\/chart\d+\.xml$/i.test(path)) {
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
const chartXml = strFromU8(bytes);
|
|
317
|
-
const candidateType = parseChartTypeFromXml(chartXml);
|
|
318
|
-
if (!candidateType) {
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const candidatePointStyles = parseFallbackPointStylesFromChartXml(chartXml, themePalette);
|
|
322
|
-
const hasCandidateValues = candidatePointStyles.some((seriesStyles) => seriesStyles.some((style) => typeof style.color === "string" && style.color.length > 0 || typeof style.explosion === "number"));
|
|
323
|
-
if (!hasCandidateValues) {
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
let score = 0;
|
|
327
|
-
const candidateTitle = normalizeChartTitleForMatch(extractChartTitleFromXml(chartXml));
|
|
328
|
-
if (preferred.length > 0 && candidateTitle.length > 0 && preferred === candidateTitle) {
|
|
329
|
-
score += 100;
|
|
330
|
-
}
|
|
331
|
-
if (preferredType && candidateType === preferredType) {
|
|
332
|
-
score += 20;
|
|
333
|
-
}
|
|
334
|
-
if (bestCandidate.length === 0) {
|
|
335
|
-
score += 1;
|
|
336
|
-
}
|
|
337
|
-
if (score > bestScore) {
|
|
338
|
-
bestScore = score;
|
|
339
|
-
bestCandidate = candidatePointStyles;
|
|
340
|
-
if (score >= 120) {
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return bestCandidate;
|
|
346
|
-
}
|
|
347
322
|
function parseHexColor(color) {
|
|
348
323
|
const normalized = normalizeHexColor(color);
|
|
349
324
|
if (!normalized) {
|
|
@@ -730,49 +705,37 @@ function buildThemeSeriesPalette(themePalette) {
|
|
|
730
705
|
const themeColors = [4, 5, 6, 7, 8, 9].map((index) => themePalette?.colorsByIndex[index] ?? null).filter((color) => Boolean(color));
|
|
731
706
|
return themeColors.length > 0 ? themeColors : SERIES_COLORS;
|
|
732
707
|
}
|
|
733
|
-
function
|
|
734
|
-
if (typeof styleId !== "number" || !Number.isFinite(styleId)) {
|
|
735
|
-
return null;
|
|
736
|
-
}
|
|
737
|
-
return styleId >= 100 ? styleId - 100 : styleId;
|
|
738
|
-
}
|
|
739
|
-
function getBuiltinSurfacePalette(styleId, wireframe) {
|
|
740
|
-
const normalized = normalizeBuiltinSurfaceStyleId(styleId);
|
|
741
|
-
if (normalized === 34 || wireframe === true && normalized == null) {
|
|
742
|
-
return ["#5b9bd5", "#ed7d31", "#a5a5a5"];
|
|
743
|
-
}
|
|
744
|
-
if (normalized === 35 || normalized === 36 || wireframe !== true && normalized == null) {
|
|
745
|
-
return ["#2f5597", "#4472c4", "#5b9bd5", "#8faadc", "#d9e2f3"];
|
|
746
|
-
}
|
|
747
|
-
return null;
|
|
748
|
-
}
|
|
749
|
-
function applyBuiltinSurfaceDefaults(chart) {
|
|
708
|
+
function applyBuiltinSurfaceDefaults(chart, themePalette) {
|
|
750
709
|
if (chart.chartType !== "Surface") {
|
|
751
710
|
return;
|
|
752
711
|
}
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
712
|
+
const builtin = chart.raw?.hasCustomChartColorStyle !== true ? getBuiltinChartSurfaceStyle(chart.chartStyleId) : void 0;
|
|
713
|
+
const colors = themePalette?.colorsByIndex ?? {};
|
|
714
|
+
const wallFill = resolveBuiltinChartColor(builtin?.wall.fill, colors) ?? (chart.wireframe ? "#d0d0d0" : "#d9d9df");
|
|
715
|
+
const floorFill = resolveBuiltinChartColor(builtin?.floor.fill, colors) ?? wallFill;
|
|
716
|
+
const gridlineColor = resolveBuiltinChartColor(builtin?.majorGridline, colors);
|
|
717
|
+
for (const axis of [chart.categoryAxis, chart.valueAxis, chart.seriesAxis]) {
|
|
718
|
+
if (axis && !axis.majorGridlineColor) axis.majorGridlineColor = gridlineColor;
|
|
756
719
|
}
|
|
757
|
-
const wallFill = chart.wireframe ? "#d0d0d0" : "#d9d9df";
|
|
758
720
|
const wallLine = chart.wireframe ? "#a6a6a6" : "#a8adb7";
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
fillColor:
|
|
767
|
-
lineColor:
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
721
|
+
const previousDefaults = chart.raw?.builtinSurfaceDefaults;
|
|
722
|
+
const nextDefaults = {};
|
|
723
|
+
for (const key of ["floor", "sideWall", "backWall"]) {
|
|
724
|
+
const wall = chart[key] ?? {};
|
|
725
|
+
const previous = previousDefaults?.[key];
|
|
726
|
+
const fillIsDefault = wall.fillColor === void 0 || wall.fillColor === previous?.fillColor;
|
|
727
|
+
const lineIsDefault = wall.lineColor === void 0 || wall.lineColor === previous?.lineColor;
|
|
728
|
+
const fillColor = fillIsDefault ? key === "floor" ? floorFill : wallFill : wall.fillColor;
|
|
729
|
+
const lineColor = lineIsDefault ? wallLine : wall.lineColor;
|
|
730
|
+
chart[key] = { ...wall, fillColor, lineColor };
|
|
731
|
+
nextDefaults[key] = {
|
|
732
|
+
fillColor: fillIsDefault ? fillColor : void 0,
|
|
733
|
+
lineColor: lineIsDefault ? lineColor : void 0
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
chart.raw = { ...chart.raw, builtinSurfaceDefaults: nextDefaults };
|
|
774
737
|
if (!chart.surfaceMaterial && chart.wireframe !== true) {
|
|
775
|
-
chart.surfaceMaterial = "
|
|
738
|
+
chart.surfaceMaterial = "matte";
|
|
776
739
|
}
|
|
777
740
|
}
|
|
778
741
|
function applyBuiltinChartDefaults(chart, themePalette) {
|
|
@@ -796,34 +759,48 @@ function applyBuiltinChartDefaults(chart, themePalette) {
|
|
|
796
759
|
chart.axisLineColor = chart.axisLineColor ?? derivedAxisColor ?? textColor ?? void 0;
|
|
797
760
|
chart.fontFamily = chart.fontFamily ?? minorTypeface;
|
|
798
761
|
chart.titleFontFamily = chart.titleFontFamily ?? chart.fontFamily ?? minorTypeface;
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
803
|
-
chart.
|
|
762
|
+
const themeColors = themePalette?.colorsByIndex;
|
|
763
|
+
const useBuiltin = chart.raw?.hasCustomChartColorStyle !== true && themeColors && getBuiltinChartColor(chart.chartStyleId, 0, 1) !== void 0;
|
|
764
|
+
const colorCount = Math.max(1, chart.series.length, chart.typeGroups?.reduce((total, group) => total + group.series.length, 0) ?? 0);
|
|
765
|
+
const seriesPalette = useBuiltin && chart.chartType !== "Surface" ? Array.from({ length: colorCount }, (_, index) => resolveBuiltinChartColor(getBuiltinChartColor(chart.chartStyleId, index, colorCount), themeColors) ?? SERIES_COLORS[index % SERIES_COLORS.length]) : chart.chartColorPalette?.length ? chart.chartColorPalette : buildThemeSeriesPalette(themePalette);
|
|
766
|
+
chart.chartColorPalette = seriesPalette;
|
|
767
|
+
chart.raw = { ...chart.raw, builtinThemeColors: useBuiltin ? themeColors : void 0 };
|
|
768
|
+
const applySeriesDefaults = (series, index) => {
|
|
804
769
|
const fallbackColor = seriesPalette[index % seriesPalette.length];
|
|
770
|
+
const properties = series.shapeProperties ?? {};
|
|
771
|
+
const previous = properties.builtinDefaultColors;
|
|
772
|
+
const generated = {};
|
|
773
|
+
const resolveColor = (key, explicit, fallback) => {
|
|
774
|
+
const value = series[key];
|
|
775
|
+
if (!explicit && (value == null || value === previous?.[key] || (key === "color" || key === "lineColor") && useBuiltin && chart.raw?.xmlChartType)) {
|
|
776
|
+
generated[key] = fallback;
|
|
777
|
+
return fallback;
|
|
778
|
+
}
|
|
779
|
+
return value ?? fallback;
|
|
780
|
+
};
|
|
781
|
+
const explicitFill = properties.xmlFillColor ?? properties.solidFillHex ?? properties.xmlFillHidden;
|
|
782
|
+
const explicitLine = properties.xmlLineColor ?? properties.lineColorHex ?? properties.xmlLineHidden;
|
|
783
|
+
const color = explicitFill ? series.color ?? series.lineColor ?? fallbackColor : explicitLine ? series.lineColor ?? series.color ?? fallbackColor : resolveColor("color", false, fallbackColor);
|
|
784
|
+
const lineColor = explicitLine ? series.lineColor ?? color : explicitFill ? color : resolveColor("lineColor", false, color ?? fallbackColor);
|
|
785
|
+
const markerColor = resolveColor("markerColor", properties.xmlMarkerFillColor ?? properties.xmlMarkerFillHidden, color ?? lineColor ?? fallbackColor);
|
|
786
|
+
const markerLineColor = resolveColor("markerLineColor", properties.xmlMarkerLineColor ?? properties.xmlMarkerLineHidden, lineColor ?? color ?? fallbackColor);
|
|
805
787
|
return {
|
|
806
788
|
...series,
|
|
807
|
-
color
|
|
808
|
-
lineColor
|
|
809
|
-
markerColor
|
|
810
|
-
markerLineColor
|
|
789
|
+
color,
|
|
790
|
+
lineColor,
|
|
791
|
+
markerColor,
|
|
792
|
+
markerLineColor,
|
|
793
|
+
shapeProperties: { ...properties, builtinDefaultColors: generated }
|
|
811
794
|
};
|
|
795
|
+
};
|
|
796
|
+
chart.series = chart.series.map(applySeriesDefaults);
|
|
797
|
+
let groupSeriesOffset = 0;
|
|
798
|
+
chart.typeGroups = chart.typeGroups?.map((group) => {
|
|
799
|
+
const series = group.series.map((entry, index) => applySeriesDefaults(entry, groupSeriesOffset + index));
|
|
800
|
+
groupSeriesOffset += group.series.length;
|
|
801
|
+
return { ...group, series };
|
|
812
802
|
});
|
|
813
|
-
chart
|
|
814
|
-
...group,
|
|
815
|
-
series: group.series.map((series, seriesIndex) => {
|
|
816
|
-
const fallbackColor = seriesPalette[(groupIndex + seriesIndex) % seriesPalette.length];
|
|
817
|
-
return {
|
|
818
|
-
...series,
|
|
819
|
-
color: series.color ?? series.lineColor ?? fallbackColor,
|
|
820
|
-
lineColor: series.lineColor ?? series.color ?? fallbackColor,
|
|
821
|
-
markerColor: series.markerColor ?? series.color ?? series.lineColor ?? fallbackColor,
|
|
822
|
-
markerLineColor: series.markerLineColor ?? series.lineColor ?? series.color ?? fallbackColor
|
|
823
|
-
};
|
|
824
|
-
})
|
|
825
|
-
}));
|
|
826
|
-
applyBuiltinSurfaceDefaults(chart);
|
|
803
|
+
applyBuiltinSurfaceDefaults(chart, themePalette);
|
|
827
804
|
}
|
|
828
805
|
function parseChartPointStyles(seriesNode, themePalette) {
|
|
829
806
|
const pointStyles = [];
|
|
@@ -863,7 +840,7 @@ function parseChartCacheValues(parentNode, cacheName, mode) {
|
|
|
863
840
|
return null;
|
|
864
841
|
}
|
|
865
842
|
const referenceNode = getFirstLocalChild(parentNode, "numRef") ?? getFirstLocalChild(parentNode, "strRef") ?? parentNode;
|
|
866
|
-
const cacheNode = getFirstLocalChild(referenceNode, cacheName);
|
|
843
|
+
const cacheNode = getFirstLocalChild(referenceNode, cacheName) ?? getFirstLocalChild(parentNode, cacheName === "numCache" ? "numLit" : "strLit");
|
|
867
844
|
if (!cacheNode) {
|
|
868
845
|
return null;
|
|
869
846
|
}
|
|
@@ -950,7 +927,7 @@ function applyChartSeriesStyleFromXml(chart, chartTypeNode, themePalette) {
|
|
|
950
927
|
const fillColor = resolveChartFillColor(shapeProperties, themePalette);
|
|
951
928
|
const markerSize = readChartNumericAttribute(markerNode, "size");
|
|
952
929
|
const markerSymbolNode = markerNode ? getFirstLocalChild(markerNode, "symbol") : null;
|
|
953
|
-
const markerSymbol = markerSymbolNode?.getAttribute("val") ??
|
|
930
|
+
const markerSymbol = markerSymbolNode?.getAttribute("val") ?? (markerNode || chart.chartType === "Scatter" || ["marker", "lineMarker", "smoothMarker"].includes(chart.scatterStyle ?? "") || readChartBooleanAttribute(chartTypeNode, "marker") === true ? "auto" : series.markerSymbol);
|
|
954
931
|
const pointStyles = parseChartPointStyles(seriesNode, themePalette);
|
|
955
932
|
const seriesExplosion = readChartNumericAttribute(seriesNode, "explosion");
|
|
956
933
|
const invertNegativeStyle = parseInvertNegativeStyle(seriesNode, themePalette);
|
|
@@ -974,8 +951,8 @@ function applyChartSeriesStyleFromXml(chart, chartTypeNode, themePalette) {
|
|
|
974
951
|
dataPointStyles: pointStyles.length > 0 ? pointStyles : series.dataPointStyles,
|
|
975
952
|
lineColor: resolvedLineColor,
|
|
976
953
|
lineWidthPx: lineStyle.hidden ? void 0 : lineStyle.widthPx ?? series.lineWidthPx,
|
|
977
|
-
markerColor:
|
|
978
|
-
markerLineColor:
|
|
954
|
+
markerColor: resolveChartFillColor(markerShapeProperties, themePalette) ?? rawFillColor ?? rawLineColor ?? fillColor ?? lineStyle.color ?? void 0,
|
|
955
|
+
markerLineColor: markerLineStyle.color ?? rawLineColor ?? rawFillColor ?? lineStyle.color ?? fillColor ?? void 0,
|
|
979
956
|
markerSize: markerSize ?? series.markerSize,
|
|
980
957
|
markerSymbol,
|
|
981
958
|
smooth: readChartBooleanAttribute(seriesNode, "smooth") ?? series.smooth,
|
|
@@ -983,10 +960,15 @@ function applyChartSeriesStyleFromXml(chart, chartTypeNode, themePalette) {
|
|
|
983
960
|
shapeProperties: {
|
|
984
961
|
...series.shapeProperties,
|
|
985
962
|
xmlExplosion: seriesExplosion ?? void 0,
|
|
963
|
+
xmlFillHidden: getFirstLocalChild(shapeProperties, "noFill") ? true : void 0,
|
|
986
964
|
xmlFillColor: fillColor ?? void 0,
|
|
987
965
|
xmlLineHidden: lineStyle.hidden ? true : void 0,
|
|
988
966
|
xmlLineColor: lineStyle.color ?? void 0,
|
|
989
967
|
xmlLineWidthPx: lineStyle.widthPx ?? void 0,
|
|
968
|
+
xmlMarkerFillColor: resolveChartFillColor(markerShapeProperties, themePalette) ?? void 0,
|
|
969
|
+
xmlMarkerFillHidden: getFirstLocalChild(markerShapeProperties, "noFill") ? true : void 0,
|
|
970
|
+
xmlMarkerLineColor: markerLineStyle.color ?? void 0,
|
|
971
|
+
xmlMarkerLineHidden: markerLineStyle.hidden ? true : void 0,
|
|
990
972
|
xmlNegativeFillColor: invertNegativeStyle.color ?? void 0,
|
|
991
973
|
xmlNegativeLineColor: invertNegativeStyle.lineColor ?? void 0
|
|
992
974
|
},
|
|
@@ -1068,6 +1050,7 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
1068
1050
|
};
|
|
1069
1051
|
const applyRelationshipStyles = () => {
|
|
1070
1052
|
chart.chartColorPalette = readChartColorPalette(archive, relationships.get(CHART_COLOR_STYLE_REL_TYPE), themePalette);
|
|
1053
|
+
chart.raw = { ...chart.raw, hasCustomChartColorStyle: Boolean(chart.chartColorPalette?.length) };
|
|
1071
1054
|
const styleAppearance2 = readChartStyleAppearance(
|
|
1072
1055
|
archive,
|
|
1073
1056
|
relationships.get(CHART_STYLE_REL_TYPE),
|
|
@@ -1347,20 +1330,30 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
1347
1330
|
chart.surfaceMaterial = seriesSp3dNode?.getAttribute("prstMaterial") ?? chart.surfaceMaterial;
|
|
1348
1331
|
const bandFormatsNode = getLocalChildren(chartTypeNode, "bandFmts")[0] ?? null;
|
|
1349
1332
|
const bandFormatNodes = bandFormatsNode ? getLocalChildren(bandFormatsNode, "bandFmt") : [];
|
|
1350
|
-
const bandFormatColors =
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1333
|
+
const bandFormatColors = /* @__PURE__ */ Object.create(null);
|
|
1334
|
+
const bandFormatLineColors = /* @__PURE__ */ Object.create(null);
|
|
1335
|
+
const bandFormatLineWidths = /* @__PURE__ */ Object.create(null);
|
|
1336
|
+
for (const bandFormatNode of bandFormatNodes) {
|
|
1337
|
+
const index = readChartNumericAttribute(bandFormatNode, "idx");
|
|
1338
|
+
if (index == null || !Number.isInteger(index) || index < 0 || index > 4294967295) {
|
|
1339
|
+
continue;
|
|
1340
|
+
}
|
|
1355
1341
|
const shapeProperties = getFirstLocalChild(bandFormatNode, "spPr");
|
|
1356
|
-
|
|
1357
|
-
|
|
1342
|
+
const fillColor = getFirstLocalChild(shapeProperties, "noFill") ? "transparent" : resolveChartFillColor(shapeProperties, themePalette);
|
|
1343
|
+
const lineStyle = resolveChartLineStyle(shapeProperties, themePalette);
|
|
1344
|
+
const lineColor = lineStyle.hidden ? "transparent" : lineStyle.color;
|
|
1345
|
+
const lineWidth = Number(getFirstLocalChild(shapeProperties, "ln")?.getAttribute("w") ?? Number.NaN);
|
|
1346
|
+
if (fillColor) bandFormatColors[index] = fillColor;
|
|
1347
|
+
if (lineColor) bandFormatLineColors[index] = lineColor;
|
|
1348
|
+
if (Number.isFinite(lineWidth) && lineWidth >= 0) bandFormatLineWidths[index] = lineWidth / EMU_PER_PIXEL;
|
|
1349
|
+
}
|
|
1358
1350
|
chart.raw = {
|
|
1359
1351
|
...chart.raw ?? {},
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1352
|
+
bandFormatColors: Object.keys(bandFormatColors).length > 0 ? bandFormatColors : void 0,
|
|
1353
|
+
bandFormatLineColors: Object.keys(bandFormatLineColors).length > 0 ? bandFormatLineColors : void 0,
|
|
1354
|
+
bandFormatLineWidths: Object.keys(bandFormatLineWidths).length > 0 ? bandFormatLineWidths : void 0,
|
|
1363
1355
|
date1904: readChartBooleanAttribute(chartDocument?.documentElement ?? null, "date1904"),
|
|
1356
|
+
titleOverlay: readChartBooleanAttribute(getFirstLocalChild(chartNode, "title"), "overlay"),
|
|
1364
1357
|
bubble3d: chart.bubble3d,
|
|
1365
1358
|
grouping: getFirstLocalChild(chartTypeNode, "grouping")?.getAttribute("val") ?? void 0,
|
|
1366
1359
|
ofPieType: getFirstLocalChild(chartTypeNode, "ofPieType")?.getAttribute("val") ?? void 0,
|
|
@@ -1375,15 +1368,21 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
1375
1368
|
if (view3dNode) {
|
|
1376
1369
|
chart.view3d = {
|
|
1377
1370
|
depthPercent: readChartNumericAttribute(view3dNode, "depthPercent"),
|
|
1371
|
+
heightPercent: readChartNumericAttribute(view3dNode, "hPercent"),
|
|
1378
1372
|
perspective: readChartNumericAttribute(view3dNode, "perspective"),
|
|
1379
1373
|
rAngAx: getFirstLocalChild(view3dNode, "rAngAx")?.getAttribute("val") === "1",
|
|
1380
1374
|
rotX: readChartNumericAttribute(view3dNode, "rotX"),
|
|
1381
1375
|
rotY: readChartNumericAttribute(view3dNode, "rotY")
|
|
1382
1376
|
};
|
|
1383
1377
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1378
|
+
for (const key of ["floor", "sideWall", "backWall"]) {
|
|
1379
|
+
const wall = readChartWallFromXml(getFirstLocalChild(chartNode, key), themePalette);
|
|
1380
|
+
if (wall) {
|
|
1381
|
+
chart[key] = wall;
|
|
1382
|
+
const defaults = chart.raw?.builtinSurfaceDefaults;
|
|
1383
|
+
if (defaults) chart.raw = { ...chart.raw, builtinSurfaceDefaults: { ...defaults, [key]: void 0 } };
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1387
1386
|
const styleAppearance = applyRelationshipStyles();
|
|
1388
1387
|
const chartTextTypeface = readChartTextTypeface(getFirstLocalChild(chartNode, "txPr"), themePalette);
|
|
1389
1388
|
const titleTypeface = readChartTextTypeface(getFirstLocalDescendant(chartNode, "title"), themePalette);
|
|
@@ -1396,7 +1395,9 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
1396
1395
|
chart.raw = {
|
|
1397
1396
|
...chart.raw ?? {},
|
|
1398
1397
|
chartAreaNoFill: styleAppearance.chartAreaNoFill === true || chartAreaNoFill,
|
|
1399
|
-
plotAreaNoFill
|
|
1398
|
+
plotAreaNoFill,
|
|
1399
|
+
plotAreaFillColor: resolveChartFillColor(plotAreaShapeProperties, themePalette) ?? void 0,
|
|
1400
|
+
plotAreaLineColor: resolveChartLineStyle(plotAreaShapeProperties, themePalette).color ?? void 0
|
|
1400
1401
|
};
|
|
1401
1402
|
if (chartAreaShapeProperties) {
|
|
1402
1403
|
const chartAreaFillColor = resolveChartFillColor(chartAreaShapeProperties, themePalette);
|
|
@@ -1434,88 +1435,18 @@ function applyChartStyleFromXml(chart, chartPath, archive, themePalette) {
|
|
|
1434
1435
|
return position === "l" || position === "r";
|
|
1435
1436
|
}) ?? valueAxisNodes[1] ?? valueAxisNodes[0];
|
|
1436
1437
|
}
|
|
1437
|
-
chart.categoryAxis = mergeChartAxis(chart.categoryAxis, readChartAxisFromXml(categoryAxisNode));
|
|
1438
|
-
chart.valueAxis = mergeChartAxis(chart.valueAxis, readChartAxisFromXml(valueAxisNode));
|
|
1439
|
-
chart.seriesAxis = mergeChartAxis(chart.seriesAxis, readChartAxisFromXml(seriesAxisNode));
|
|
1440
|
-
chart.axes = chart.axes.length > 0 ? chart.axes.map((axis, index) => index === 0 && categoryAxisNode ? { ...axis, ...readChartAxisFromXml(categoryAxisNode) } : index === 1 && valueAxisNode ? { ...axis, ...readChartAxisFromXml(valueAxisNode) } : axis) : chart.axes;
|
|
1438
|
+
chart.categoryAxis = mergeChartAxis(chart.categoryAxis, readChartAxisFromXml(categoryAxisNode, themePalette));
|
|
1439
|
+
chart.valueAxis = mergeChartAxis(chart.valueAxis, readChartAxisFromXml(valueAxisNode, themePalette));
|
|
1440
|
+
chart.seriesAxis = mergeChartAxis(chart.seriesAxis, readChartAxisFromXml(seriesAxisNode, themePalette));
|
|
1441
|
+
chart.axes = chart.axes.length > 0 ? chart.axes.map((axis, index) => index === 0 && categoryAxisNode ? { ...axis, ...readChartAxisFromXml(categoryAxisNode, themePalette) } : index === 1 && valueAxisNode ? { ...axis, ...readChartAxisFromXml(valueAxisNode, themePalette) } : axis) : chart.axes;
|
|
1441
1442
|
if (seriesAxisNode) {
|
|
1442
|
-
const seriesAxis = readChartAxisFromXml(seriesAxisNode);
|
|
1443
|
+
const seriesAxis = readChartAxisFromXml(seriesAxisNode, themePalette);
|
|
1443
1444
|
if (seriesAxis && !chart.axes.some((axis) => axis.id != null && axis.id === seriesAxis.id)) {
|
|
1444
1445
|
chart.axes = [...chart.axes, seriesAxis];
|
|
1445
1446
|
}
|
|
1446
1447
|
}
|
|
1447
1448
|
applyChartSeriesStyleFromXml(chart, chartTypeNode, themePalette);
|
|
1448
1449
|
applyFallbackSeriesStyles();
|
|
1449
|
-
if (chart.chartType === "Bubble") {
|
|
1450
|
-
const archiveFallbackBubbleSizes = resolveArchiveFallbackBubbleSizes(archive, chart.title);
|
|
1451
|
-
if (archiveFallbackBubbleSizes.length > 0) {
|
|
1452
|
-
chart.series = chart.series.map((series, seriesIndex) => {
|
|
1453
|
-
const pointCount = Math.max(series.values.length, series.categories.length);
|
|
1454
|
-
if (pointCount <= 1) {
|
|
1455
|
-
return series;
|
|
1456
|
-
}
|
|
1457
|
-
const numericBubbleCount = (series.bubbleSizes ?? []).filter(
|
|
1458
|
-
(value) => typeof value === "number" && Number.isFinite(value)
|
|
1459
|
-
).length;
|
|
1460
|
-
if (numericBubbleCount >= pointCount) {
|
|
1461
|
-
return series;
|
|
1462
|
-
}
|
|
1463
|
-
const fallbackCandidate = archiveFallbackBubbleSizes[seriesIndex] ?? archiveFallbackBubbleSizes[0] ?? [];
|
|
1464
|
-
const fallbackNumericCount = fallbackCandidate.filter(
|
|
1465
|
-
(value) => typeof value === "number" && Number.isFinite(value)
|
|
1466
|
-
).length;
|
|
1467
|
-
if (fallbackNumericCount < pointCount) {
|
|
1468
|
-
return series;
|
|
1469
|
-
}
|
|
1470
|
-
return {
|
|
1471
|
-
...series,
|
|
1472
|
-
bubbleSizes: fallbackCandidate
|
|
1473
|
-
};
|
|
1474
|
-
});
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
if (chart.chartType === "Pie" || chart.chartType === "Pie3D" || chart.chartType === "PieExploded" || chart.chartType === "Doughnut" || chart.chartType === "BarOfPie") {
|
|
1478
|
-
const needsPointColorFallback = chart.series.some((series) => {
|
|
1479
|
-
const pointCount = Math.max(series.values.length, series.categories.length);
|
|
1480
|
-
if (pointCount <= 0) {
|
|
1481
|
-
return false;
|
|
1482
|
-
}
|
|
1483
|
-
const coloredPointCount = (series.dataPointStyles ?? []).filter(
|
|
1484
|
-
(style) => typeof style.color === "string" && style.color.length > 0
|
|
1485
|
-
).length;
|
|
1486
|
-
return coloredPointCount === 0;
|
|
1487
|
-
});
|
|
1488
|
-
if (needsPointColorFallback) {
|
|
1489
|
-
const archiveFallbackPointStyles = resolveArchiveFallbackPointStyles(
|
|
1490
|
-
archive,
|
|
1491
|
-
chart.title,
|
|
1492
|
-
chartTypeNode.localName,
|
|
1493
|
-
themePalette
|
|
1494
|
-
);
|
|
1495
|
-
if (archiveFallbackPointStyles.length > 0) {
|
|
1496
|
-
chart.series = chart.series.map((series, seriesIndex) => {
|
|
1497
|
-
const fallbackStyles = archiveFallbackPointStyles[seriesIndex] ?? archiveFallbackPointStyles[0] ?? [];
|
|
1498
|
-
if (fallbackStyles.length === 0) {
|
|
1499
|
-
return series;
|
|
1500
|
-
}
|
|
1501
|
-
const existingByIndex = new Map((series.dataPointStyles ?? []).map((entry) => [entry.index, entry]));
|
|
1502
|
-
for (const fallbackStyle of fallbackStyles) {
|
|
1503
|
-
const existing = existingByIndex.get(fallbackStyle.index);
|
|
1504
|
-
existingByIndex.set(fallbackStyle.index, {
|
|
1505
|
-
color: existing?.color ?? fallbackStyle.color,
|
|
1506
|
-
explosion: existing?.explosion ?? fallbackStyle.explosion,
|
|
1507
|
-
index: fallbackStyle.index,
|
|
1508
|
-
lineColor: existing?.lineColor ?? fallbackStyle.lineColor
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
return {
|
|
1512
|
-
...series,
|
|
1513
|
-
dataPointStyles: Array.from(existingByIndex.values()).sort((left, right) => left.index - right.index)
|
|
1514
|
-
};
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
1450
|
applyBuiltinChartDefaults(chart, themePalette);
|
|
1520
1451
|
}
|
|
1521
1452
|
function normalizeArchivePath(path) {
|
|
@@ -1578,12 +1509,12 @@ function parseXml(xml) {
|
|
|
1578
1509
|
}
|
|
1579
1510
|
}
|
|
1580
1511
|
function getLocalChildren(parent, localName) {
|
|
1581
|
-
return Array.from(parent
|
|
1512
|
+
return Array.from(parent?.childNodes ?? []).filter(
|
|
1582
1513
|
(node) => node.nodeType === Node.ELEMENT_NODE && node.localName === localName
|
|
1583
1514
|
);
|
|
1584
1515
|
}
|
|
1585
1516
|
function getLocalDescendants(parent, localName) {
|
|
1586
|
-
return Array.from(parent
|
|
1517
|
+
return Array.from(parent?.getElementsByTagName("*") ?? []).filter(
|
|
1587
1518
|
(node) => node.localName === localName
|
|
1588
1519
|
);
|
|
1589
1520
|
}
|
|
@@ -2060,9 +1991,10 @@ function normalizeChartExSeries(workbook2, workbookSheetIndex, chartId, raw, dat
|
|
|
2060
1991
|
const valuesRef = valueDimension ? normalizeChartReference({
|
|
2061
1992
|
formula: valueDimensionFormula
|
|
2062
1993
|
}) : null;
|
|
2063
|
-
const
|
|
1994
|
+
const isCategoricalMap = chartType === "RegionMap" && valueDimension?.dimType === "colorStr";
|
|
1995
|
+
const resolvedValueCells = resolveReferenceValues(workbook2, workbookSheetIndex, valuesRef, isCategoricalMap ? "category" : "value");
|
|
2064
1996
|
const values = resolvedValueCells.map((value) => typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
2065
|
-
const colorStrings =
|
|
1997
|
+
const colorStrings = isCategoricalMap ? resolvedValueCells.map((value) => {
|
|
2066
1998
|
if (typeof value === "string") {
|
|
2067
1999
|
const trimmed = value.trim();
|
|
2068
2000
|
return trimmed.length > 0 ? trimmed : null;
|
|
@@ -2072,7 +2004,8 @@ function normalizeChartExSeries(workbook2, workbookSheetIndex, chartId, raw, dat
|
|
|
2072
2004
|
}
|
|
2073
2005
|
return null;
|
|
2074
2006
|
}) : [];
|
|
2075
|
-
const
|
|
2007
|
+
const categoryRows = chartType === "RegionMap" ? resolveReferenceRowPaths(workbook2, workbookSheetIndex, categoriesRef) : [];
|
|
2008
|
+
const categories = categoryRows.length === resolvedValueCells.length && categoryRows.length > 0 ? categoryRows.map((parts) => parts[0] ?? "") : resolveReferenceValues(workbook2, workbookSheetIndex, categoriesRef, "category");
|
|
2076
2009
|
const hierarchyCategories = chartType === "Sunburst" || chartType === "Treemap" ? resolveReferenceRowPaths(workbook2, workbookSheetIndex, categoriesRef) : [];
|
|
2077
2010
|
const seriesTextFormula = resolveChartExTextFormula(series.text);
|
|
2078
2011
|
const shapeProperties = series.shapeProperties && typeof series.shapeProperties === "object" ? series.shapeProperties : void 0;
|
|
@@ -2428,7 +2361,7 @@ function mergeChartAxis(target, patch) {
|
|
|
2428
2361
|
...patch
|
|
2429
2362
|
};
|
|
2430
2363
|
}
|
|
2431
|
-
function readChartAxisFromXml(axisNode) {
|
|
2364
|
+
function readChartAxisFromXml(axisNode, themePalette) {
|
|
2432
2365
|
if (!axisNode) {
|
|
2433
2366
|
return null;
|
|
2434
2367
|
}
|
|
@@ -2444,6 +2377,10 @@ function readChartAxisFromXml(axisNode) {
|
|
|
2444
2377
|
logBase: readChartNumericAttribute(getFirstLocalChild(axisNode, "scaling"), "logBase"),
|
|
2445
2378
|
orientation: getFirstLocalChild(scalingNode ?? axisNode, "orientation")?.getAttribute("val") ?? void 0,
|
|
2446
2379
|
majorGridlines: Boolean(getFirstLocalChild(axisNode, "majorGridlines")),
|
|
2380
|
+
majorGridlineColor: (() => {
|
|
2381
|
+
const style = resolveChartLineStyle(getFirstLocalChild(getFirstLocalChild(axisNode, "majorGridlines"), "spPr"), themePalette);
|
|
2382
|
+
return style.hidden ? "transparent" : style.color ?? void 0;
|
|
2383
|
+
})(),
|
|
2447
2384
|
majorTickMark: getFirstLocalChild(axisNode, "majorTickMark")?.getAttribute("val") ?? void 0,
|
|
2448
2385
|
majorUnit: readChartNumericAttribute(axisNode, "majorUnit"),
|
|
2449
2386
|
max: readChartNumericAttribute(scalingNode, "max"),
|
|
@@ -2949,6 +2886,7 @@ function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWork
|
|
|
2949
2886
|
varyColors: typeof chart.varyColors === "boolean" ? chart.varyColors : void 0,
|
|
2950
2887
|
view3d: rawView3d ? {
|
|
2951
2888
|
depthPercent: typeof rawView3d.depthPercent === "number" ? rawView3d.depthPercent : void 0,
|
|
2889
|
+
heightPercent: typeof rawView3d.heightPercent === "number" ? rawView3d.heightPercent : void 0,
|
|
2952
2890
|
perspective: typeof rawView3d.perspective === "number" ? rawView3d.perspective : void 0,
|
|
2953
2891
|
rAngAx: typeof rawView3d.rAngAx === "boolean" ? rawView3d.rAngAx : typeof rawView3d.rightAngleAxes === "boolean" ? rawView3d.rightAngleAxes : void 0,
|
|
2954
2892
|
rotX: typeof rawView3d.rotX === "number" ? rawView3d.rotX : typeof rawView3d.rotateX === "number" ? rawView3d.rotateX : void 0,
|
|
@@ -3118,13 +3056,25 @@ function resolveWorkbookColor(color, themePalette) {
|
|
|
3118
3056
|
}
|
|
3119
3057
|
const themeValue = color.theme ?? color.themeIndex;
|
|
3120
3058
|
const numericTheme = typeof themeValue === "number" ? themeValue : typeof themeValue === "string" && themeValue.trim().length > 0 ? Number(themeValue) : Number.NaN;
|
|
3121
|
-
const
|
|
3122
|
-
if (!
|
|
3059
|
+
const themeColor2 = Number.isFinite(numericTheme) ? themePalette?.colorsByIndex[numericTheme] ?? null : null;
|
|
3060
|
+
if (!themeColor2) {
|
|
3123
3061
|
return null;
|
|
3124
3062
|
}
|
|
3125
3063
|
const tintValue = color.tint;
|
|
3126
3064
|
const tint = typeof tintValue === "number" ? tintValue : typeof tintValue === "string" && tintValue.trim().length > 0 ? Number(tintValue) : Number.NaN;
|
|
3127
|
-
return Number.isFinite(tint) ? applyExcelTint(
|
|
3065
|
+
return Number.isFinite(tint) ? applyExcelTint(themeColor2, tint) : themeColor2;
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
// src/cell-alignment.ts
|
|
3069
|
+
function getCellGeneralAlignment(worksheet, row, col) {
|
|
3070
|
+
const value = worksheet.getCalculatedValueAt(row, col);
|
|
3071
|
+
try {
|
|
3072
|
+
if (value.is_number) return "right";
|
|
3073
|
+
if (value.is_boolean || value.is_error) return "center";
|
|
3074
|
+
return "left";
|
|
3075
|
+
} finally {
|
|
3076
|
+
value.free();
|
|
3077
|
+
}
|
|
3128
3078
|
}
|
|
3129
3079
|
|
|
3130
3080
|
// src/images.ts
|
|
@@ -3148,7 +3098,9 @@ function measureColumnCharacterWidthPx(fontFamily, fontSizePt) {
|
|
|
3148
3098
|
return cached;
|
|
3149
3099
|
}
|
|
3150
3100
|
const fontSizePx = normalizedSizePt * (96 / 72);
|
|
3151
|
-
const
|
|
3101
|
+
const family = JSON.stringify(normalizedFamily);
|
|
3102
|
+
const fallback = normalizedFamily.toLowerCase() === "calibri" || normalizedFamily.toLowerCase() === "carlito" ? ', "Carlito", "React XLSX Carlito"' : "";
|
|
3103
|
+
const font = `${fontSizePx}px ${family}${fallback}`;
|
|
3152
3104
|
let width = DEFAULT_COLUMN_CHARACTER_WIDTH_PX;
|
|
3153
3105
|
try {
|
|
3154
3106
|
const context = typeof document !== "undefined" ? document.createElement("canvas").getContext("2d") : typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(32, 32).getContext("2d") : null;
|
|
@@ -3762,7 +3714,7 @@ function parseSpreadsheetAlignment(node) {
|
|
|
3762
3714
|
if (textRotation !== null) {
|
|
3763
3715
|
const parsedRotation = Number(textRotation);
|
|
3764
3716
|
if (Number.isFinite(parsedRotation)) {
|
|
3765
|
-
alignment.
|
|
3717
|
+
alignment.rotation = parsedRotation;
|
|
3766
3718
|
}
|
|
3767
3719
|
}
|
|
3768
3720
|
return Object.keys(alignment).length > 0 ? alignment : void 0;
|
|
@@ -4887,6 +4839,9 @@ function parseWorkerSheetLayoutAssets(bytes, sheetCount) {
|
|
|
4887
4839
|
if (!xml) {
|
|
4888
4840
|
return null;
|
|
4889
4841
|
}
|
|
4842
|
+
const sheetFormatTag = /<(?:[\w.-]+:)?sheetFormatPr\b[^>]*>/.exec(xml)?.[0] ?? "";
|
|
4843
|
+
const defaultRowHeight = Number(readXmlAttribute(sheetFormatTag, "defaultRowHeight") ?? Number.NaN);
|
|
4844
|
+
const defaultColWidth = Number(readXmlAttribute(sheetFormatTag, "defaultColWidth") ?? readXmlAttribute(sheetFormatTag, "baseColWidth") ?? Number.NaN);
|
|
4890
4845
|
const rowHeightOverridesPx = {};
|
|
4891
4846
|
for (const match of xml.matchAll(/<row\b[^>]*>/g)) {
|
|
4892
4847
|
const tag = match[0];
|
|
@@ -4897,7 +4852,11 @@ function parseWorkerSheetLayoutAssets(bytes, sheetCount) {
|
|
|
4897
4852
|
rowHeightOverridesPx[rowIndex] = Math.max(MIN_ROW_HEIGHT_PX2, Math.round(height * 1.33));
|
|
4898
4853
|
}
|
|
4899
4854
|
}
|
|
4900
|
-
return {
|
|
4855
|
+
return {
|
|
4856
|
+
defaultRowHeightPx: Number.isFinite(defaultRowHeight) && defaultRowHeight > 0 ? Math.max(MIN_ROW_HEIGHT_PX2, Math.round(defaultRowHeight * 1.33)) : void 0,
|
|
4857
|
+
defaultColWidthPx: Number.isFinite(defaultColWidth) && defaultColWidth > 0 ? resolveSheetColumnWidthPixels(defaultColWidth) : void 0,
|
|
4858
|
+
rowHeightOverridesPx
|
|
4859
|
+
};
|
|
4901
4860
|
});
|
|
4902
4861
|
} catch {
|
|
4903
4862
|
return [];
|
|
@@ -5087,14 +5046,14 @@ function buildSheetList(nextWorkbook, themePalette, structureAssets, sheetLayout
|
|
|
5087
5046
|
...sheetState,
|
|
5088
5047
|
...mergeMetadata
|
|
5089
5048
|
};
|
|
5090
|
-
const defaultColWidthPx = resolveWorksheetDefaultColumnWidthPixels(
|
|
5049
|
+
const defaultColWidthPx = sheetState?.defaultColWidthPx ?? resolveWorksheetDefaultColumnWidthPixels(
|
|
5091
5050
|
worksheet,
|
|
5092
5051
|
sheetState?.columnWidthCharacterWidthPx,
|
|
5093
|
-
|
|
5052
|
+
DEFAULT_COL_WIDTH
|
|
5094
5053
|
);
|
|
5095
|
-
const defaultRowHeightPx = resolveWorksheetDefaultRowHeightPixels(
|
|
5054
|
+
const defaultRowHeightPx = sheetState?.defaultRowHeightPx ?? resolveWorksheetDefaultRowHeightPixels(
|
|
5096
5055
|
worksheet,
|
|
5097
|
-
|
|
5056
|
+
DEFAULT_ROW_HEIGHT
|
|
5098
5057
|
);
|
|
5099
5058
|
const visibility = normalizeWorksheetVisibility2(worksheet.visibility);
|
|
5100
5059
|
if (!showHiddenSheets && visibility !== "visible") {
|
|
@@ -5480,13 +5439,21 @@ async function handleMessage(message) {
|
|
|
5480
5439
|
if (typeof worksheet.getRowsBatch !== "function") {
|
|
5481
5440
|
return null;
|
|
5482
5441
|
}
|
|
5483
|
-
|
|
5442
|
+
const rows = worksheet.getRowsBatch(message.payload.startRow, message.payload.rowCount, {
|
|
5484
5443
|
includeFormulas: true,
|
|
5485
5444
|
includeHyperlinks: true,
|
|
5486
5445
|
includeMergeInfo: true,
|
|
5487
5446
|
includeStyles: true,
|
|
5488
5447
|
useFormattedValues: true
|
|
5489
5448
|
});
|
|
5449
|
+
for (const row of rows ?? []) {
|
|
5450
|
+
for (const cell of row.cells) {
|
|
5451
|
+
if (!cell.isMergedSecondary) {
|
|
5452
|
+
cell.generalAlignment = getCellGeneralAlignment(worksheet, row.index, cell.col);
|
|
5453
|
+
}
|
|
5454
|
+
}
|
|
5455
|
+
}
|
|
5456
|
+
return rows;
|
|
5490
5457
|
}
|
|
5491
5458
|
default:
|
|
5492
5459
|
return null;
|