@extend-ai/react-xlsx 0.14.0 → 0.15.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/README.md +54 -2
- package/dist/duke_sheets_wasm_bg.wasm +0 -0
- package/dist/index.cjs +1125 -1181
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -37
- package/dist/index.d.ts +107 -37
- package/dist/index.js +1125 -1181
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +290 -78
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
package/dist/xlsx-worker.js
CHANGED
|
@@ -1758,7 +1758,7 @@ function normalizeChartExLegend(raw) {
|
|
|
1758
1758
|
return null;
|
|
1759
1759
|
}
|
|
1760
1760
|
const legend = raw;
|
|
1761
|
-
const position = typeof legend.
|
|
1761
|
+
const position = typeof legend.position === "string" ? normalizeLegendPosition(String(legend.position)) : void 0;
|
|
1762
1762
|
return {
|
|
1763
1763
|
overlay: typeof legend.overlay === "boolean" ? legend.overlay : void 0,
|
|
1764
1764
|
position,
|
|
@@ -1879,11 +1879,11 @@ function buildChartExHistogramBins(values, rawSeries, sortByFrequency) {
|
|
|
1879
1879
|
return [];
|
|
1880
1880
|
}
|
|
1881
1881
|
const rawRecord = rawSeries && typeof rawSeries === "object" ? rawSeries : null;
|
|
1882
|
-
const layoutProperties = rawRecord?.
|
|
1882
|
+
const layoutProperties = rawRecord?.layoutProperties && typeof rawRecord.layoutProperties === "object" ? rawRecord.layoutProperties : null;
|
|
1883
1883
|
const rawBinning = layoutProperties?.binning && typeof layoutProperties.binning === "object" ? layoutProperties.binning : null;
|
|
1884
1884
|
const minValue = Math.min(...values);
|
|
1885
1885
|
const maxValue = Math.max(...values);
|
|
1886
|
-
const explicitWidth = typeof rawBinning?.
|
|
1886
|
+
const explicitWidth = typeof rawBinning?.binSize === "number" && Number.isFinite(rawBinning.binSize) && rawBinning.binSize > 0 ? rawBinning.binSize : void 0;
|
|
1887
1887
|
const explicitCount = typeof rawBinning?.binCount === "number" && Number.isFinite(rawBinning.binCount) && rawBinning.binCount > 0 ? rawBinning.binCount : typeof rawBinning?.count === "number" && Number.isFinite(rawBinning.count) && rawBinning.count > 0 ? rawBinning.count : void 0;
|
|
1888
1888
|
const closedRight = rawBinning?.intervalClosed === "r" || rawBinning?.intervalClosed === "right";
|
|
1889
1889
|
const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
@@ -1936,7 +1936,7 @@ function buildChartExHistogramSeries(series, rawSeries, sortByFrequency) {
|
|
|
1936
1936
|
const layout = resolveChartExSeriesLayout(rawSeries);
|
|
1937
1937
|
const rawRecord = rawSeries && typeof rawSeries === "object" ? rawSeries : null;
|
|
1938
1938
|
const hasBinning = Boolean(
|
|
1939
|
-
layout === "clusteredColumn" && rawRecord?.
|
|
1939
|
+
layout === "clusteredColumn" && rawRecord?.layoutProperties && typeof rawRecord.layoutProperties === "object" && rawRecord.layoutProperties.binning != null
|
|
1940
1940
|
);
|
|
1941
1941
|
if (!hasBinning) {
|
|
1942
1942
|
return series;
|
|
@@ -2148,7 +2148,8 @@ function collapseChartExPointSeries(chartType, series) {
|
|
|
2148
2148
|
];
|
|
2149
2149
|
}
|
|
2150
2150
|
function normalizeChartExChart(workbook2, workbookSheetIndex, visibleSheetIndex, raw, index, themePalette) {
|
|
2151
|
-
const
|
|
2151
|
+
const drawing = raw && typeof raw === "object" ? raw : {};
|
|
2152
|
+
const chart = drawing.chartEx && typeof drawing.chartEx === "object" ? drawing.chartEx : {};
|
|
2152
2153
|
const plotArea = chart.plotArea && typeof chart.plotArea === "object" ? chart.plotArea : {};
|
|
2153
2154
|
const rawSeries = Array.isArray(plotArea.series) ? plotArea.series : [];
|
|
2154
2155
|
const seriesLayouts = rawSeries.map(resolveChartExSeriesLayout);
|
|
@@ -2203,7 +2204,7 @@ function normalizeChartExChart(workbook2, workbookSheetIndex, visibleSheetIndex,
|
|
|
2203
2204
|
}
|
|
2204
2205
|
] : [];
|
|
2205
2206
|
const normalizedChart = {
|
|
2206
|
-
anchor: normalizeChartAnchor(
|
|
2207
|
+
anchor: normalizeChartAnchor(drawing.anchor),
|
|
2207
2208
|
autoTitleDeleted: void 0,
|
|
2208
2209
|
axes,
|
|
2209
2210
|
axisLabelColor: void 0,
|
|
@@ -2227,7 +2228,7 @@ function normalizeChartExChart(workbook2, workbookSheetIndex, visibleSheetIndex,
|
|
|
2227
2228
|
id: `chart-ex-${workbookSheetIndex}-${index}`,
|
|
2228
2229
|
is3d: void 0,
|
|
2229
2230
|
legend: normalizeChartExLegend(chart.legend),
|
|
2230
|
-
name: chartTitle,
|
|
2231
|
+
name: typeof drawing.name === "string" ? drawing.name : chartTitle,
|
|
2231
2232
|
overlap: void 0,
|
|
2232
2233
|
plotVisibleOnly: void 0,
|
|
2233
2234
|
raw: chart,
|
|
@@ -2255,7 +2256,7 @@ function normalizeChartExChart(workbook2, workbookSheetIndex, visibleSheetIndex,
|
|
|
2255
2256
|
view3d: void 0,
|
|
2256
2257
|
wireframe: void 0,
|
|
2257
2258
|
workbookSheetIndex,
|
|
2258
|
-
zIndex: index
|
|
2259
|
+
zIndex: Array.isArray(drawing.drawingPath) && typeof drawing.drawingPath[0] === "number" ? drawing.drawingPath[0] + 1 : index + 1
|
|
2259
2260
|
};
|
|
2260
2261
|
applyBuiltinChartDefaults(normalizedChart, themePalette);
|
|
2261
2262
|
return normalizedChart;
|
|
@@ -2376,10 +2377,11 @@ function normalizeChartReference(raw) {
|
|
|
2376
2377
|
return null;
|
|
2377
2378
|
}
|
|
2378
2379
|
const record = raw;
|
|
2380
|
+
const values = Array.isArray(record.numbers) ? record.numbers : Array.isArray(record.strings) ? record.strings : void 0;
|
|
2379
2381
|
return {
|
|
2380
2382
|
formula: typeof record.formula === "string" ? record.formula : void 0,
|
|
2381
2383
|
refType: typeof record.refType === "string" ? record.refType : void 0,
|
|
2382
|
-
values
|
|
2384
|
+
values
|
|
2383
2385
|
};
|
|
2384
2386
|
}
|
|
2385
2387
|
function normalizeChartAxis(raw) {
|
|
@@ -2399,8 +2401,8 @@ function normalizeChartAxis(raw) {
|
|
|
2399
2401
|
logBase: typeof axis.logBase === "number" ? axis.logBase : void 0,
|
|
2400
2402
|
orientation: typeof axis.orientation === "string" ? axis.orientation : void 0,
|
|
2401
2403
|
majorUnit: typeof axis.majorUnit === "number" ? axis.majorUnit : void 0,
|
|
2402
|
-
max: typeof axis.
|
|
2403
|
-
min: typeof axis.
|
|
2404
|
+
max: typeof axis.maximum === "number" ? axis.maximum : void 0,
|
|
2405
|
+
min: typeof axis.minimum === "number" ? axis.minimum : void 0,
|
|
2404
2406
|
majorGridlines: typeof axis.majorGridlines === "boolean" ? axis.majorGridlines : void 0,
|
|
2405
2407
|
majorTickMark: typeof axis.majorTickMark === "string" ? axis.majorTickMark : void 0,
|
|
2406
2408
|
minorUnit: typeof axis.minorUnit === "number" ? axis.minorUnit : void 0,
|
|
@@ -2523,11 +2525,11 @@ function normalizeChartDataLabels(raw) {
|
|
|
2523
2525
|
pointLabels: pointLabels && pointLabels.length > 0 ? pointLabels : void 0,
|
|
2524
2526
|
raw: labels,
|
|
2525
2527
|
showBubbleSize: typeof labels.showBubbleSize === "boolean" ? labels.showBubbleSize : void 0,
|
|
2526
|
-
showCategoryName: typeof labels.showCategoryName === "boolean" ? labels.showCategoryName : void 0,
|
|
2528
|
+
showCategoryName: typeof (labels.showCategoryName ?? labels.visibilityCategoryName) === "boolean" ? Boolean(labels.showCategoryName ?? labels.visibilityCategoryName) : void 0,
|
|
2527
2529
|
showLegendKey: typeof labels.showLegendKey === "boolean" ? labels.showLegendKey : void 0,
|
|
2528
2530
|
showPercent: typeof labels.showPercent === "boolean" ? labels.showPercent : void 0,
|
|
2529
|
-
showSeriesName: typeof labels.showSeriesName === "boolean" ? labels.showSeriesName : void 0,
|
|
2530
|
-
showValue: typeof labels.showValue === "boolean" ? labels.showValue : void 0
|
|
2531
|
+
showSeriesName: typeof (labels.showSeriesName ?? labels.visibilitySeriesName) === "boolean" ? Boolean(labels.showSeriesName ?? labels.visibilitySeriesName) : void 0,
|
|
2532
|
+
showValue: typeof (labels.showValue ?? labels.visibilityValue) === "boolean" ? Boolean(labels.showValue ?? labels.visibilityValue) : void 0
|
|
2531
2533
|
};
|
|
2532
2534
|
}
|
|
2533
2535
|
function normalizeChartAnchor(raw) {
|
|
@@ -2539,19 +2541,52 @@ function normalizeChartAnchor(raw) {
|
|
|
2539
2541
|
};
|
|
2540
2542
|
}
|
|
2541
2543
|
const anchor = raw;
|
|
2542
|
-
const
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2544
|
+
const from = anchor.from && typeof anchor.from === "object" ? anchor.from : null;
|
|
2545
|
+
if (anchor.type === "oneCell") {
|
|
2546
|
+
return {
|
|
2547
|
+
from: {
|
|
2548
|
+
col: typeof from?.col === "number" ? from.col : 0,
|
|
2549
|
+
colOffsetEmu: typeof from?.colOffsetEmu === "number" ? from.colOffsetEmu : 0,
|
|
2550
|
+
row: typeof from?.row === "number" ? from.row : 0,
|
|
2551
|
+
rowOffsetEmu: typeof from?.rowOffsetEmu === "number" ? from.rowOffsetEmu : 0
|
|
2552
|
+
},
|
|
2553
|
+
kind: "one-cell",
|
|
2554
|
+
sizeEmu: {
|
|
2555
|
+
cx: typeof anchor.widthEmu === "number" ? anchor.widthEmu : 0,
|
|
2556
|
+
cy: typeof anchor.heightEmu === "number" ? anchor.heightEmu : 0
|
|
2557
|
+
}
|
|
2558
|
+
};
|
|
2559
|
+
}
|
|
2560
|
+
if (anchor.type === "absolute") {
|
|
2561
|
+
return {
|
|
2562
|
+
kind: "absolute",
|
|
2563
|
+
positionEmu: {
|
|
2564
|
+
x: typeof anchor.xEmu === "number" ? anchor.xEmu : 0,
|
|
2565
|
+
y: typeof anchor.yEmu === "number" ? anchor.yEmu : 0
|
|
2566
|
+
},
|
|
2567
|
+
sizeEmu: {
|
|
2568
|
+
cx: typeof anchor.widthEmu === "number" ? anchor.widthEmu : 0,
|
|
2569
|
+
cy: typeof anchor.heightEmu === "number" ? anchor.heightEmu : 0
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
const to = anchor.to && typeof anchor.to === "object" ? anchor.to : null;
|
|
2574
|
+
const fromColValue = from?.col;
|
|
2575
|
+
const fromColOffsetValue = from?.colOffsetEmu;
|
|
2576
|
+
const fromRowValue = from?.row;
|
|
2577
|
+
const fromRowOffsetValue = from?.rowOffsetEmu;
|
|
2578
|
+
const toColValue = to?.col;
|
|
2579
|
+
const toColOffsetValue = to?.colOffsetEmu;
|
|
2580
|
+
const toRowValue = to?.row;
|
|
2581
|
+
const toRowOffsetValue = to?.rowOffsetEmu;
|
|
2582
|
+
const fromCol = typeof fromColValue === "number" ? fromColValue : 0;
|
|
2583
|
+
const fromColOffsetEmu = typeof fromColOffsetValue === "number" ? fromColOffsetValue : 0;
|
|
2584
|
+
const fromRow = typeof fromRowValue === "number" ? fromRowValue : 0;
|
|
2585
|
+
const fromRowOffsetEmu = typeof fromRowOffsetValue === "number" ? fromRowOffsetValue : 0;
|
|
2586
|
+
const rawToCol = typeof toColValue === "number" ? toColValue : 0;
|
|
2587
|
+
const rawToColOffsetEmu = typeof toColOffsetValue === "number" ? toColOffsetValue : 0;
|
|
2588
|
+
const rawToRow = typeof toRowValue === "number" ? toRowValue : 0;
|
|
2589
|
+
const rawToRowOffsetEmu = typeof toRowOffsetValue === "number" ? toRowOffsetValue : 0;
|
|
2555
2590
|
return {
|
|
2556
2591
|
kind: "two-cell",
|
|
2557
2592
|
from: {
|
|
@@ -2561,10 +2596,10 @@ function normalizeChartAnchor(raw) {
|
|
|
2561
2596
|
rowOffsetEmu: fromRowOffsetEmu
|
|
2562
2597
|
},
|
|
2563
2598
|
to: {
|
|
2564
|
-
col:
|
|
2565
|
-
colOffsetEmu:
|
|
2566
|
-
row:
|
|
2567
|
-
rowOffsetEmu:
|
|
2599
|
+
col: rawToCol,
|
|
2600
|
+
colOffsetEmu: rawToColOffsetEmu,
|
|
2601
|
+
row: rawToRow,
|
|
2602
|
+
rowOffsetEmu: rawToRowOffsetEmu
|
|
2568
2603
|
}
|
|
2569
2604
|
};
|
|
2570
2605
|
}
|
|
@@ -2678,7 +2713,7 @@ function normalizeChartTypeGroup(workbook2, workbookSheetIndex, chartId, raw, in
|
|
|
2678
2713
|
chartType: typeof group.chartType === "string" ? group.chartType : "ColumnClustered",
|
|
2679
2714
|
dataLabels: normalizeChartDataLabels(group.dataLabels),
|
|
2680
2715
|
gapWidth: typeof group.gapWidth === "number" && Number.isFinite(group.gapWidth) ? group.gapWidth : void 0,
|
|
2681
|
-
is3d: typeof group.
|
|
2716
|
+
is3d: typeof group.is3D === "boolean" ? group.is3D : void 0,
|
|
2682
2717
|
overlap: typeof group.overlap === "number" && Number.isFinite(group.overlap) ? group.overlap : void 0,
|
|
2683
2718
|
raw: group,
|
|
2684
2719
|
series: rawSeries.map((entry, seriesIndex) => normalizeChartSeries(workbook2, workbookSheetIndex, `${chartId}-group-${index}`, entry, seriesIndex)),
|
|
@@ -2832,20 +2867,25 @@ function applyChartOrigins(chartsByWorkbookSheetIndex2, chartOriginsById, archiv
|
|
|
2832
2867
|
}
|
|
2833
2868
|
}
|
|
2834
2869
|
function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWorkbookSheetIndex, showHiddenSheets = false) {
|
|
2870
|
+
const excludedChartIds = /* @__PURE__ */ new Set();
|
|
2835
2871
|
const chartsByWorkbookSheetIndex2 = Array.from({ length: workbook2.sheetCount }, (_, workbookSheetIndex) => {
|
|
2836
2872
|
const worksheet = workbook2.getSheet(workbookSheetIndex);
|
|
2837
|
-
const rawCharts =
|
|
2838
|
-
const rawChartsEx =
|
|
2873
|
+
const rawCharts = worksheet.charts;
|
|
2874
|
+
const rawChartsEx = worksheet.chartsEx;
|
|
2839
2875
|
const visibleSheetIndex = visibleSheetIndexByWorkbookSheetIndex.get(workbookSheetIndex) ?? workbookSheetIndex;
|
|
2840
2876
|
const classicCharts = rawCharts.map((rawChart, chartIndex) => {
|
|
2841
2877
|
const chartId = `chart-${workbookSheetIndex}-${chartIndex}`;
|
|
2842
|
-
|
|
2843
|
-
|
|
2878
|
+
if (rawChart.hidden || !rawChart.anchor) {
|
|
2879
|
+
excludedChartIds.add(chartId);
|
|
2880
|
+
}
|
|
2881
|
+
const drawing = rawChart && typeof rawChart === "object" ? rawChart : {};
|
|
2882
|
+
const chart = drawing.chart && typeof drawing.chart === "object" ? drawing.chart : {};
|
|
2883
|
+
const rawView3d = chart.view3D && typeof chart.view3D === "object" ? chart.view3D : null;
|
|
2844
2884
|
const rawSeries = Array.isArray(chart.series) ? chart.series : [];
|
|
2845
2885
|
const chartLevelDataLabels = normalizeChartDataLabels(chart.dataLabels);
|
|
2846
2886
|
const firstSeriesDataLabels = rawSeries.length > 0 && rawSeries[0] && typeof rawSeries[0] === "object" ? normalizeChartDataLabels(rawSeries[0].dataLabels) : null;
|
|
2847
2887
|
return {
|
|
2848
|
-
anchor: normalizeChartAnchor(
|
|
2888
|
+
anchor: normalizeChartAnchor(drawing.anchor),
|
|
2849
2889
|
autoTitleDeleted: typeof chart.autoTitleDeleted === "boolean" ? chart.autoTitleDeleted : void 0,
|
|
2850
2890
|
axes: Array.isArray(chart.axes) ? chart.axes.map(normalizeChartAxis).filter((value) => Boolean(value)) : [],
|
|
2851
2891
|
axisLabelColor: void 0,
|
|
@@ -2866,12 +2906,12 @@ function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWork
|
|
|
2866
2906
|
gapWidth: typeof chart.gapWidth === "number" ? chart.gapWidth : void 0,
|
|
2867
2907
|
holeSize: typeof chart.holeSize === "number" ? chart.holeSize : void 0,
|
|
2868
2908
|
id: chartId,
|
|
2869
|
-
is3d: typeof chart.
|
|
2909
|
+
is3d: typeof chart.is3D === "boolean" ? chart.is3D : void 0,
|
|
2870
2910
|
legend: normalizeLegend(chart.legend) ? {
|
|
2871
2911
|
...normalizeLegend(chart.legend),
|
|
2872
2912
|
position: normalizeLegendPosition(normalizeLegend(chart.legend)?.position)
|
|
2873
2913
|
} : null,
|
|
2874
|
-
name: typeof
|
|
2914
|
+
name: typeof drawing.name === "string" ? drawing.name : void 0,
|
|
2875
2915
|
overlap: typeof chart.overlap === "number" ? chart.overlap : void 0,
|
|
2876
2916
|
plotVisibleOnly: typeof chart.plotVisibleOnly === "boolean" ? chart.plotVisibleOnly : void 0,
|
|
2877
2917
|
raw: chart,
|
|
@@ -2905,17 +2945,23 @@ function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWork
|
|
|
2905
2945
|
} : void 0,
|
|
2906
2946
|
wireframe: typeof chart.wireframe === "boolean" ? chart.wireframe : void 0,
|
|
2907
2947
|
workbookSheetIndex,
|
|
2908
|
-
zIndex:
|
|
2948
|
+
zIndex: Array.isArray(drawing.drawingPath) && typeof drawing.drawingPath[0] === "number" ? drawing.drawingPath[0] + 1 : chartIndex + 1
|
|
2909
2949
|
};
|
|
2910
2950
|
});
|
|
2911
|
-
const modernCharts = rawChartsEx.map((rawChartEx, chartExIndex) =>
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2951
|
+
const modernCharts = rawChartsEx.map((rawChartEx, chartExIndex) => {
|
|
2952
|
+
const chartId = `chart-ex-${workbookSheetIndex}-${chartExIndex}`;
|
|
2953
|
+
if (rawChartEx.hidden || !rawChartEx.anchor) {
|
|
2954
|
+
excludedChartIds.add(chartId);
|
|
2955
|
+
}
|
|
2956
|
+
return normalizeChartExChart(
|
|
2957
|
+
workbook2,
|
|
2958
|
+
workbookSheetIndex,
|
|
2959
|
+
visibleSheetIndex,
|
|
2960
|
+
rawChartEx,
|
|
2961
|
+
chartExIndex,
|
|
2962
|
+
imageAssets?.themePalette ?? null
|
|
2963
|
+
);
|
|
2964
|
+
});
|
|
2919
2965
|
return [...classicCharts, ...modernCharts];
|
|
2920
2966
|
});
|
|
2921
2967
|
const chartsheets2 = Array.isArray(workbook2.chartsheets) ? workbook2.chartsheets.map((entry, index) => normalizeChartsheet(entry, index)) : [];
|
|
@@ -2923,6 +2969,12 @@ function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWork
|
|
|
2923
2969
|
const chartOriginsById = /* @__PURE__ */ new Map();
|
|
2924
2970
|
if (imageAssets) {
|
|
2925
2971
|
applyChartOrigins(chartsByWorkbookSheetIndex2, chartOriginsById, imageAssets.archive, imageAssets.sheetOrigins);
|
|
2972
|
+
for (let index = 0; index < chartsByWorkbookSheetIndex2.length; index += 1) {
|
|
2973
|
+
chartsByWorkbookSheetIndex2[index] = (chartsByWorkbookSheetIndex2[index] ?? []).filter((chart) => !excludedChartIds.has(chart.id));
|
|
2974
|
+
}
|
|
2975
|
+
for (const id of excludedChartIds) {
|
|
2976
|
+
chartOriginsById.delete(id);
|
|
2977
|
+
}
|
|
2926
2978
|
for (const charts of chartsByWorkbookSheetIndex2) {
|
|
2927
2979
|
for (const chart of charts) {
|
|
2928
2980
|
applyChartStyleFromXml(chart, chart.chartPath, imageAssets.archive, imageAssets.themePalette);
|
|
@@ -2930,6 +2982,9 @@ function loadWorkbookChartAssets(workbook2, imageAssets, visibleSheetIndexByWork
|
|
|
2930
2982
|
}
|
|
2931
2983
|
}
|
|
2932
2984
|
} else {
|
|
2985
|
+
for (let index = 0; index < chartsByWorkbookSheetIndex2.length; index += 1) {
|
|
2986
|
+
chartsByWorkbookSheetIndex2[index] = (chartsByWorkbookSheetIndex2[index] ?? []).filter((chart) => !excludedChartIds.has(chart.id));
|
|
2987
|
+
}
|
|
2933
2988
|
for (const charts of chartsByWorkbookSheetIndex2) {
|
|
2934
2989
|
for (const chart of charts) {
|
|
2935
2990
|
applyBuiltinChartDefaults(chart, null);
|
|
@@ -4229,55 +4284,138 @@ function normalizeHexColor3(value) {
|
|
|
4229
4284
|
}
|
|
4230
4285
|
return "#000000";
|
|
4231
4286
|
}
|
|
4232
|
-
function
|
|
4287
|
+
function dukeDrawingAnchorToXlsxAnchor(anchor) {
|
|
4288
|
+
if (anchor.type === "absolute") {
|
|
4289
|
+
return {
|
|
4290
|
+
kind: "absolute",
|
|
4291
|
+
positionEmu: { x: anchor.xEmu, y: anchor.yEmu },
|
|
4292
|
+
sizeEmu: { cx: anchor.widthEmu, cy: anchor.heightEmu }
|
|
4293
|
+
};
|
|
4294
|
+
}
|
|
4295
|
+
const from = {
|
|
4296
|
+
col: anchor.from.col,
|
|
4297
|
+
colOffsetEmu: anchor.from.colOffsetEmu ?? 0,
|
|
4298
|
+
row: anchor.from.row,
|
|
4299
|
+
rowOffsetEmu: anchor.from.rowOffsetEmu ?? 0
|
|
4300
|
+
};
|
|
4301
|
+
if (anchor.type === "oneCell") {
|
|
4302
|
+
return {
|
|
4303
|
+
from,
|
|
4304
|
+
kind: "one-cell",
|
|
4305
|
+
sizeEmu: { cx: anchor.widthEmu, cy: anchor.heightEmu }
|
|
4306
|
+
};
|
|
4307
|
+
}
|
|
4233
4308
|
return {
|
|
4234
|
-
from
|
|
4235
|
-
col: anchor.fromCol,
|
|
4236
|
-
colOffsetEmu: anchor.fromColOffset,
|
|
4237
|
-
row: anchor.fromRow,
|
|
4238
|
-
rowOffsetEmu: anchor.fromRowOffset
|
|
4239
|
-
},
|
|
4309
|
+
from,
|
|
4240
4310
|
kind: "two-cell",
|
|
4241
4311
|
to: {
|
|
4242
|
-
col: anchor.
|
|
4243
|
-
colOffsetEmu: anchor.
|
|
4244
|
-
row: anchor.
|
|
4245
|
-
rowOffsetEmu: anchor.
|
|
4312
|
+
col: anchor.to.col,
|
|
4313
|
+
colOffsetEmu: anchor.to.colOffsetEmu ?? 0,
|
|
4314
|
+
row: anchor.to.row,
|
|
4315
|
+
rowOffsetEmu: anchor.to.rowOffsetEmu ?? 0
|
|
4246
4316
|
}
|
|
4247
4317
|
};
|
|
4248
4318
|
}
|
|
4249
|
-
function
|
|
4319
|
+
function mapDukeDrawingColor(color) {
|
|
4320
|
+
if (!color) {
|
|
4321
|
+
return void 0;
|
|
4322
|
+
}
|
|
4323
|
+
switch (color.colorType) {
|
|
4324
|
+
case "auto":
|
|
4325
|
+
return { colorType: "auto" };
|
|
4326
|
+
case "rgb":
|
|
4327
|
+
return { b: color.b, colorType: "rgb", g: color.g, r: color.r };
|
|
4328
|
+
case "argb":
|
|
4329
|
+
return { a: color.a, b: color.b, colorType: "argb", g: color.g, r: color.r };
|
|
4330
|
+
case "theme":
|
|
4331
|
+
return { colorType: "theme", themeIndex: color.index, tint: color.tint };
|
|
4332
|
+
case "indexed":
|
|
4333
|
+
return { colorType: "indexed", paletteIndex: color.index };
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
function mapDukeDrawingFont(font) {
|
|
4337
|
+
if (!font) {
|
|
4338
|
+
return void 0;
|
|
4339
|
+
}
|
|
4340
|
+
return {
|
|
4341
|
+
bold: font.bold,
|
|
4342
|
+
charset: font.charset,
|
|
4343
|
+
color: mapDukeDrawingColor(font.color),
|
|
4344
|
+
family: font.family,
|
|
4345
|
+
italic: font.italic,
|
|
4346
|
+
name: font.name,
|
|
4347
|
+
scheme: font.scheme,
|
|
4348
|
+
size: font.size,
|
|
4349
|
+
strikethrough: font.strikethrough,
|
|
4350
|
+
underline: font.underline,
|
|
4351
|
+
verticalAlign: font.verticalAlign
|
|
4352
|
+
};
|
|
4353
|
+
}
|
|
4354
|
+
function mapDukeDrawingText(text) {
|
|
4355
|
+
return {
|
|
4356
|
+
horizontalAlignment: text.horizontalAlignment,
|
|
4357
|
+
runs: text.runs.map((run) => ({ font: mapDukeDrawingFont(run.font), text: run.text })),
|
|
4358
|
+
verticalAlignment: text.verticalAlignment
|
|
4359
|
+
};
|
|
4360
|
+
}
|
|
4361
|
+
function resolveDukeDrawingColor(color, themePalette) {
|
|
4362
|
+
if (!color) {
|
|
4363
|
+
return void 0;
|
|
4364
|
+
}
|
|
4365
|
+
switch (color.colorType) {
|
|
4366
|
+
case "rgb":
|
|
4367
|
+
return resolveWorkbookColor({ rgb: [color.r, color.g, color.b].map((value) => value.toString(16).padStart(2, "0")).join("") }) ?? void 0;
|
|
4368
|
+
case "argb":
|
|
4369
|
+
return resolveWorkbookColor({ argb: [color.a, color.r, color.g, color.b].map((value) => value.toString(16).padStart(2, "0")).join("") }) ?? void 0;
|
|
4370
|
+
case "theme":
|
|
4371
|
+
return resolveWorkbookColor({ theme: color.index, tint: color.tint }, themePalette) ?? void 0;
|
|
4372
|
+
default:
|
|
4373
|
+
return void 0;
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
function resolveDukeDrawingText(text, themePalette) {
|
|
4377
|
+
const caption = mapDukeDrawingText(text);
|
|
4378
|
+
const label = normalizeControlLabel(text.runs.map((run) => run.text).join(""));
|
|
4379
|
+
const firstStyledRun = text.runs.find((run) => run.font)?.font;
|
|
4380
|
+
const horizontalAlignment = text.horizontalAlignment;
|
|
4381
|
+
return {
|
|
4382
|
+
caption,
|
|
4383
|
+
fontFamily: firstStyledRun?.name,
|
|
4384
|
+
fontSizePt: firstStyledRun?.size,
|
|
4385
|
+
label,
|
|
4386
|
+
textAlign: horizontalAlignment === "left" || horizontalAlignment === "center" || horizontalAlignment === "right" ? horizontalAlignment : void 0,
|
|
4387
|
+
textColor: resolveDukeDrawingColor(firstStyledRun?.color, themePalette)
|
|
4388
|
+
};
|
|
4389
|
+
}
|
|
4390
|
+
function mapDukeFormControlKind(kind, themePalette) {
|
|
4250
4391
|
switch (kind.kind) {
|
|
4251
4392
|
case "button":
|
|
4252
|
-
return {
|
|
4393
|
+
return { ...resolveDukeDrawingText(kind.caption, themePalette), kind: "button" };
|
|
4253
4394
|
case "checkbox":
|
|
4254
4395
|
return {
|
|
4255
|
-
|
|
4396
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
4256
4397
|
checked: kind.state === "checked",
|
|
4257
4398
|
kind: "checkbox",
|
|
4258
|
-
label: normalizeControlLabel(kind.caption),
|
|
4259
4399
|
linkedCell: kind.cellLink,
|
|
4260
4400
|
no3D: kind.no3D,
|
|
4261
4401
|
state: kind.state
|
|
4262
4402
|
};
|
|
4263
4403
|
case "optionButton":
|
|
4264
4404
|
return {
|
|
4265
|
-
|
|
4405
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
4266
4406
|
checked: kind.state === "checked",
|
|
4267
4407
|
firstInGroup: kind.firstInGroup,
|
|
4268
4408
|
kind: "radio",
|
|
4269
|
-
label: normalizeControlLabel(kind.caption),
|
|
4270
4409
|
linkedCell: kind.cellLink,
|
|
4271
4410
|
no3D: kind.no3D,
|
|
4272
4411
|
state: kind.state
|
|
4273
4412
|
};
|
|
4274
4413
|
case "label":
|
|
4275
|
-
return {
|
|
4414
|
+
return { ...resolveDukeDrawingText(kind.caption, themePalette), kind: "label" };
|
|
4276
4415
|
case "groupBox":
|
|
4277
4416
|
return {
|
|
4278
|
-
|
|
4417
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
4279
4418
|
kind: "group-box",
|
|
4280
|
-
label: normalizeControlLabel(kind.caption),
|
|
4281
4419
|
no3D: kind.no3D
|
|
4282
4420
|
};
|
|
4283
4421
|
case "listBox":
|
|
@@ -4318,30 +4456,42 @@ function mapDukeFormControlKind(kind) {
|
|
|
4318
4456
|
min: kind.min,
|
|
4319
4457
|
value: kind.value
|
|
4320
4458
|
};
|
|
4459
|
+
case "unknown":
|
|
4460
|
+
return {
|
|
4461
|
+
...resolveDukeDrawingText(kind.caption, themePalette),
|
|
4462
|
+
kind: kind.objectType.toLowerCase() === "editbox" ? "editbox" : "unknown",
|
|
4463
|
+
legacyObjectType: kind.legacyObjectType,
|
|
4464
|
+
objectType: kind.objectType,
|
|
4465
|
+
rawObj: kind.rawObj,
|
|
4466
|
+
rawProperties: kind.rawProperties
|
|
4467
|
+
};
|
|
4321
4468
|
}
|
|
4322
4469
|
}
|
|
4323
|
-
function mapDukeFormControl(control, controlIndex, workbookSheetIndex) {
|
|
4470
|
+
function mapDukeFormControl(control, controlIndex, workbookSheetIndex, themePalette) {
|
|
4324
4471
|
return {
|
|
4325
|
-
|
|
4472
|
+
altText: control.altText,
|
|
4473
|
+
anchor: dukeDrawingAnchorToXlsxAnchor(control.anchor),
|
|
4326
4474
|
controlIndex,
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
hidden: false,
|
|
4475
|
+
editAs: control.anchor.type === "twoCell" ? control.anchor.editAs : void 0,
|
|
4476
|
+
hidden: control.hidden,
|
|
4330
4477
|
id: `form-control-${workbookSheetIndex}-${controlIndex}`,
|
|
4331
4478
|
locked: control.locked,
|
|
4479
|
+
macroName: control.formControl.macroName,
|
|
4332
4480
|
name: control.name,
|
|
4333
4481
|
printable: control.printable,
|
|
4482
|
+
rawClientData: control.formControl.rawClientData,
|
|
4334
4483
|
sheetIndex: workbookSheetIndex,
|
|
4484
|
+
title: control.title,
|
|
4335
4485
|
workbookSheetIndex,
|
|
4336
|
-
zIndex: controlIndex + 1,
|
|
4337
|
-
...mapDukeFormControlKind(control.kind)
|
|
4486
|
+
zIndex: (control.drawingPath[0] ?? controlIndex) + 1,
|
|
4487
|
+
...mapDukeFormControlKind(control.formControl.kind, themePalette)
|
|
4338
4488
|
};
|
|
4339
4489
|
}
|
|
4340
|
-
function collectWorkbookFormControls(workbook2) {
|
|
4490
|
+
function collectWorkbookFormControls(workbook2, themePalette) {
|
|
4341
4491
|
return Array.from({ length: workbook2.sheetCount }, (_, workbookSheetIndex) => {
|
|
4342
4492
|
try {
|
|
4343
4493
|
const controls = workbook2.getSheet(workbookSheetIndex).formControls;
|
|
4344
|
-
return Array.isArray(controls) ? controls.
|
|
4494
|
+
return Array.isArray(controls) ? controls.flatMap((control, controlIndex) => control.anchor ? [mapDukeFormControl(control, controlIndex, workbookSheetIndex, themePalette)] : []) : [];
|
|
4345
4495
|
} catch {
|
|
4346
4496
|
return [];
|
|
4347
4497
|
}
|
|
@@ -4697,6 +4847,60 @@ function parseA1RangeReference2(reference) {
|
|
|
4697
4847
|
}
|
|
4698
4848
|
return normalizeRange({ end, start });
|
|
4699
4849
|
}
|
|
4850
|
+
function resolveWorkbookReference(targetWorkbook, defaultWorkbookSheetIndex, rawReference, resolvingNamedRange = false) {
|
|
4851
|
+
const reference = rawReference.trim().replace(/^=/, "");
|
|
4852
|
+
if (!reference) {
|
|
4853
|
+
return null;
|
|
4854
|
+
}
|
|
4855
|
+
let workbookSheetIndex = defaultWorkbookSheetIndex;
|
|
4856
|
+
let rangeReference = reference;
|
|
4857
|
+
const bangIndex = reference.lastIndexOf("!");
|
|
4858
|
+
if (bangIndex >= 0) {
|
|
4859
|
+
let sheetName = reference.slice(0, bangIndex).trim();
|
|
4860
|
+
rangeReference = reference.slice(bangIndex + 1).trim();
|
|
4861
|
+
if (sheetName.startsWith("'") && sheetName.endsWith("'")) {
|
|
4862
|
+
sheetName = sheetName.slice(1, -1).replace(/''/g, "'");
|
|
4863
|
+
}
|
|
4864
|
+
const resolvedSheetIndex = targetWorkbook.sheetIndex(sheetName);
|
|
4865
|
+
if (resolvedSheetIndex === void 0) {
|
|
4866
|
+
return null;
|
|
4867
|
+
}
|
|
4868
|
+
workbookSheetIndex = resolvedSheetIndex;
|
|
4869
|
+
} else if (!resolvingNamedRange) {
|
|
4870
|
+
const namedRange = targetWorkbook.getNamedRange(reference);
|
|
4871
|
+
if (namedRange) {
|
|
4872
|
+
return resolveWorkbookReference(targetWorkbook, defaultWorkbookSheetIndex, namedRange, true);
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
const range = parseA1RangeReference2(rangeReference.replace(/\$/g, ""));
|
|
4876
|
+
if (!range || workbookSheetIndex < 0 || workbookSheetIndex >= targetWorkbook.sheetCount) {
|
|
4877
|
+
return null;
|
|
4878
|
+
}
|
|
4879
|
+
try {
|
|
4880
|
+
return {
|
|
4881
|
+
range,
|
|
4882
|
+
worksheet: targetWorkbook.getSheet(workbookSheetIndex)
|
|
4883
|
+
};
|
|
4884
|
+
} catch {
|
|
4885
|
+
return null;
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
function resolveFormControlItems(targetWorkbook, workbookSheetIndex, control) {
|
|
4889
|
+
if (control.kind !== "dropdown" && control.kind !== "listbox" || !control.inputRange) {
|
|
4890
|
+
return [];
|
|
4891
|
+
}
|
|
4892
|
+
const source = resolveWorkbookReference(targetWorkbook, workbookSheetIndex, control.inputRange);
|
|
4893
|
+
if (!source) {
|
|
4894
|
+
return [];
|
|
4895
|
+
}
|
|
4896
|
+
const items = [];
|
|
4897
|
+
for (let row = source.range.start.row; row <= source.range.end.row; row += 1) {
|
|
4898
|
+
for (let col = source.range.start.col; col <= source.range.end.col; col += 1) {
|
|
4899
|
+
items.push(source.worksheet.getFormattedValueAt(row, col));
|
|
4900
|
+
}
|
|
4901
|
+
}
|
|
4902
|
+
return items;
|
|
4903
|
+
}
|
|
4700
4904
|
function parseWorksheetFreezePanes(worksheet) {
|
|
4701
4905
|
const rawFreezePanes = worksheet.freezePanes;
|
|
4702
4906
|
const row = typeof rawFreezePanes?.row === "number" && rawFreezePanes.row >= 0 ? rawFreezePanes.row : null;
|
|
@@ -5017,11 +5221,19 @@ async function loadWorkbook(buffer, skipXmlParsing = false, showHiddenSheets = f
|
|
|
5017
5221
|
activeWorkbook = result.workbook;
|
|
5018
5222
|
}
|
|
5019
5223
|
const nextWorkbook = activeWorkbook;
|
|
5020
|
-
formControlsByWorkbookSheetIndex = collectWorkbookFormControls(nextWorkbook);
|
|
5021
5224
|
const shouldUseFastStructureParse = bytes.byteLength >= FAST_STRUCTURE_PARSE_THRESHOLD_BYTES && totalFormulas <= FORMULA_COUNT_THRESHOLD;
|
|
5022
5225
|
const structureAssets = effectiveSkipXmlParsing || shouldUseFastStructureParse || !canParseXmlInWorker() ? null : parseWorkbookStructureAssets(bytes, {
|
|
5023
5226
|
includeCachedFormulaValues: true
|
|
5024
5227
|
});
|
|
5228
|
+
formControlsByWorkbookSheetIndex = collectWorkbookFormControls(
|
|
5229
|
+
nextWorkbook,
|
|
5230
|
+
structureAssets?.themePalette
|
|
5231
|
+
).map(
|
|
5232
|
+
(controls, workbookSheetIndex) => controls.map((control) => ({
|
|
5233
|
+
...control,
|
|
5234
|
+
items: resolveFormControlItems(nextWorkbook, workbookSheetIndex, control)
|
|
5235
|
+
}))
|
|
5236
|
+
);
|
|
5025
5237
|
const sheetLayoutStates = structureAssets ? void 0 : parseWorkerSheetLayoutAssets(bytes, nextWorkbook.sheetCount);
|
|
5026
5238
|
workbook = nextWorkbook;
|
|
5027
5239
|
sheets = buildSheetList(nextWorkbook, structureAssets, sheetLayoutStates, showHiddenSheets);
|