@extend-ai/react-xlsx 0.12.2 → 0.12.3
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/duke_sheets_wasm_bg.wasm +0 -0
- package/dist/index.cjs +136 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +136 -134
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +133 -133
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
|
Binary file
|
package/dist/index.cjs
CHANGED
|
@@ -3508,6 +3508,85 @@ function sheetColumnWidthToPixels(width, columnCharacterWidthPx = DEFAULT_COLUMN
|
|
|
3508
3508
|
const pixels = width < 1 ? Math.floor(width * (digitWidth + 5) + 0.5) : Math.floor((256 * width + Math.floor(128 / digitWidth)) / 256 * digitWidth);
|
|
3509
3509
|
return Math.max(MIN_COL_WIDTH_PX, pixels);
|
|
3510
3510
|
}
|
|
3511
|
+
function resolveWorksheetDefaultColumnWidthPixels(worksheet, columnCharacterWidthPx = DEFAULT_COLUMN_CHARACTER_WIDTH_PX, fallbackPx = sheetColumnWidthToPixels(8.43, columnCharacterWidthPx)) {
|
|
3512
|
+
const width = typeof worksheet.defaultColumnWidth === "number" ? worksheet.defaultColumnWidth : Number.NaN;
|
|
3513
|
+
return Number.isFinite(width) && width > 0 ? sheetColumnWidthToPixels(width, columnCharacterWidthPx) : fallbackPx;
|
|
3514
|
+
}
|
|
3515
|
+
function resolveWorksheetDefaultRowHeightPixels(worksheet, fallbackPx = Math.max(MIN_ROW_HEIGHT_PX, Math.round(15 * 1.33))) {
|
|
3516
|
+
const height = typeof worksheet.defaultRowHeight === "number" ? worksheet.defaultRowHeight : Number.NaN;
|
|
3517
|
+
return Number.isFinite(height) && height > 0 ? Math.max(MIN_ROW_HEIGHT_PX, Math.round(height * 1.33)) : fallbackPx;
|
|
3518
|
+
}
|
|
3519
|
+
function resolveWorksheetHiddenRows(worksheet, maxRow) {
|
|
3520
|
+
if (!Number.isFinite(maxRow) || maxRow < 0 || typeof worksheet.isRowHidden !== "function") {
|
|
3521
|
+
return [];
|
|
3522
|
+
}
|
|
3523
|
+
const hiddenRows = [];
|
|
3524
|
+
for (let row = 0; row <= maxRow; row += 1) {
|
|
3525
|
+
if (worksheet.isRowHidden(row)) {
|
|
3526
|
+
hiddenRows.push(row);
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
return hiddenRows;
|
|
3530
|
+
}
|
|
3531
|
+
function resolveWorksheetHiddenCols(worksheet, maxCol) {
|
|
3532
|
+
if (!Number.isFinite(maxCol) || maxCol < 0 || typeof worksheet.isColumnHidden !== "function") {
|
|
3533
|
+
return [];
|
|
3534
|
+
}
|
|
3535
|
+
const hiddenCols = [];
|
|
3536
|
+
for (let col = 0; col <= maxCol; col += 1) {
|
|
3537
|
+
if (worksheet.isColumnHidden(col)) {
|
|
3538
|
+
hiddenCols.push(col);
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
return hiddenCols;
|
|
3542
|
+
}
|
|
3543
|
+
function resolveWorksheetMergeMetadata(worksheet) {
|
|
3544
|
+
const mergeMetadata = {
|
|
3545
|
+
hasHorizontalMerges: false,
|
|
3546
|
+
hasVerticalMerges: false,
|
|
3547
|
+
maxHorizontalMergeEndCol: -1,
|
|
3548
|
+
maxVerticalMergeEndRow: -1
|
|
3549
|
+
};
|
|
3550
|
+
const mergedRegions = Array.isArray(worksheet.mergedRegions) ? worksheet.mergedRegions : [];
|
|
3551
|
+
for (const rawRegion of mergedRegions) {
|
|
3552
|
+
let range = null;
|
|
3553
|
+
if (typeof rawRegion === "string") {
|
|
3554
|
+
range = parseA1RangeReference(rawRegion);
|
|
3555
|
+
} else if (rawRegion && typeof rawRegion === "object") {
|
|
3556
|
+
const region = rawRegion;
|
|
3557
|
+
const startRow = typeof region.startRow === "number" ? region.startRow : Number.NaN;
|
|
3558
|
+
const startCol = typeof region.startCol === "number" ? region.startCol : Number.NaN;
|
|
3559
|
+
const endRow = typeof region.endRow === "number" ? region.endRow : Number.NaN;
|
|
3560
|
+
const endCol = typeof region.endCol === "number" ? region.endCol : Number.NaN;
|
|
3561
|
+
if ([startRow, startCol, endRow, endCol].every((value) => Number.isFinite(value) && value >= 0)) {
|
|
3562
|
+
range = {
|
|
3563
|
+
end: {
|
|
3564
|
+
col: Math.max(startCol, endCol),
|
|
3565
|
+
row: Math.max(startRow, endRow)
|
|
3566
|
+
},
|
|
3567
|
+
start: {
|
|
3568
|
+
col: Math.min(startCol, endCol),
|
|
3569
|
+
row: Math.min(startRow, endRow)
|
|
3570
|
+
}
|
|
3571
|
+
};
|
|
3572
|
+
} else if (typeof region.range === "string") {
|
|
3573
|
+
range = parseA1RangeReference(region.range);
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
if (!range) {
|
|
3577
|
+
continue;
|
|
3578
|
+
}
|
|
3579
|
+
if (range.end.col > range.start.col) {
|
|
3580
|
+
mergeMetadata.hasHorizontalMerges = true;
|
|
3581
|
+
mergeMetadata.maxHorizontalMergeEndCol = Math.max(mergeMetadata.maxHorizontalMergeEndCol, range.end.col);
|
|
3582
|
+
}
|
|
3583
|
+
if (range.end.row > range.start.row) {
|
|
3584
|
+
mergeMetadata.hasVerticalMerges = true;
|
|
3585
|
+
mergeMetadata.maxVerticalMergeEndRow = Math.max(mergeMetadata.maxVerticalMergeEndRow, range.end.row);
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
return mergeMetadata;
|
|
3589
|
+
}
|
|
3511
3590
|
function buildThemePalette(theme) {
|
|
3512
3591
|
const themeOrder = ["lt1", "dk1", "lt2", "dk2", "accent1", "accent2", "accent3", "accent4", "accent5", "accent6", "hlink", "folHlink"];
|
|
3513
3592
|
const colorsByIndex = {};
|
|
@@ -4239,67 +4318,6 @@ function parseWorkbookStyles(archive) {
|
|
|
4239
4318
|
tableStyleByName
|
|
4240
4319
|
};
|
|
4241
4320
|
}
|
|
4242
|
-
function parseWorkbookTableMetadata(archive, workbookSheets) {
|
|
4243
|
-
return workbookSheets.map((sheet) => {
|
|
4244
|
-
const sheetRelationships = parseRelationships(archive, relsPathForDocument(sheet.path), sheet.path);
|
|
4245
|
-
const sheetXml = readArchiveText2(archive, sheet.path);
|
|
4246
|
-
if (!sheetXml) {
|
|
4247
|
-
return [];
|
|
4248
|
-
}
|
|
4249
|
-
const sheetDocument = parseXml2(sheetXml);
|
|
4250
|
-
if (!sheetDocument) {
|
|
4251
|
-
return [];
|
|
4252
|
-
}
|
|
4253
|
-
return getLocalElements(sheetDocument, "tablePart").flatMap((tablePartNode) => {
|
|
4254
|
-
const relationshipId = getRelationshipId(tablePartNode);
|
|
4255
|
-
if (!relationshipId) {
|
|
4256
|
-
return [];
|
|
4257
|
-
}
|
|
4258
|
-
const relationship = sheetRelationships.get(relationshipId);
|
|
4259
|
-
if (!relationship) {
|
|
4260
|
-
return [];
|
|
4261
|
-
}
|
|
4262
|
-
const tableXml = readArchiveText2(archive, relationship.target);
|
|
4263
|
-
if (!tableXml) {
|
|
4264
|
-
return [];
|
|
4265
|
-
}
|
|
4266
|
-
const tableDocument = parseXml2(tableXml);
|
|
4267
|
-
const tableNode = tableDocument?.documentElement;
|
|
4268
|
-
if (!tableNode || tableNode.localName !== "table") {
|
|
4269
|
-
return [];
|
|
4270
|
-
}
|
|
4271
|
-
return [{
|
|
4272
|
-
displayName: tableNode.getAttribute("displayName") ?? void 0,
|
|
4273
|
-
headerRowCount: parseWorkbookTableCount(tableNode.getAttribute("headerRowCount"), 1),
|
|
4274
|
-
headerRowCellStyle: tableNode.getAttribute("headerRowCellStyle") ?? void 0,
|
|
4275
|
-
name: tableNode.getAttribute("name") ?? void 0,
|
|
4276
|
-
reference: tableNode.getAttribute("ref") ?? void 0,
|
|
4277
|
-
totalsRowCount: parseWorkbookTableCount(tableNode.getAttribute("totalsRowCount"), 0),
|
|
4278
|
-
totalsRowShown: parseWorkbookTableBoolean(tableNode.getAttribute("totalsRowShown"), false)
|
|
4279
|
-
}];
|
|
4280
|
-
});
|
|
4281
|
-
});
|
|
4282
|
-
}
|
|
4283
|
-
function parseWorkbookTableCount(value, fallback) {
|
|
4284
|
-
if (value === null) {
|
|
4285
|
-
return fallback;
|
|
4286
|
-
}
|
|
4287
|
-
const parsed = Number.parseInt(value, 10);
|
|
4288
|
-
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
|
|
4289
|
-
}
|
|
4290
|
-
function parseWorkbookTableBoolean(value, fallback) {
|
|
4291
|
-
if (value === null) {
|
|
4292
|
-
return fallback;
|
|
4293
|
-
}
|
|
4294
|
-
const normalized = value.trim().toLowerCase();
|
|
4295
|
-
if (normalized === "0" || normalized === "false" || normalized === "") {
|
|
4296
|
-
return false;
|
|
4297
|
-
}
|
|
4298
|
-
if (normalized === "1" || normalized === "true") {
|
|
4299
|
-
return true;
|
|
4300
|
-
}
|
|
4301
|
-
return fallback;
|
|
4302
|
-
}
|
|
4303
4321
|
function parseSqrefRanges(sqref) {
|
|
4304
4322
|
if (!sqref) {
|
|
4305
4323
|
return [];
|
|
@@ -4571,12 +4589,6 @@ function parseSheetState(archive, path, options) {
|
|
|
4571
4589
|
const colWidthOverridesPx = {};
|
|
4572
4590
|
const rowStyleIds = {};
|
|
4573
4591
|
const colStyleIds = {};
|
|
4574
|
-
const hiddenRows = /* @__PURE__ */ new Set();
|
|
4575
|
-
const hiddenCols = /* @__PURE__ */ new Set();
|
|
4576
|
-
let hasHorizontalMerges = false;
|
|
4577
|
-
let hasVerticalMerges = false;
|
|
4578
|
-
let maxHorizontalMergeEndCol = -1;
|
|
4579
|
-
let maxVerticalMergeEndRow = -1;
|
|
4580
4592
|
let minContentCol = Number.POSITIVE_INFINITY;
|
|
4581
4593
|
let minContentRow = Number.POSITIVE_INFINITY;
|
|
4582
4594
|
let maxContentCol = -1;
|
|
@@ -4617,16 +4629,12 @@ function parseSheetState(archive, path, options) {
|
|
|
4617
4629
|
const rowIndex = Number(rowNode.getAttribute("r") ?? 0) - 1;
|
|
4618
4630
|
const height = Number(rowNode.getAttribute("ht") ?? Number.NaN);
|
|
4619
4631
|
const styleId = Number(rowNode.getAttribute("s") ?? Number.NaN);
|
|
4620
|
-
const isHidden = (rowNode.getAttribute("hidden") ?? "0") === "1";
|
|
4621
4632
|
if (rowIndex >= 0 && Number.isFinite(height)) {
|
|
4622
4633
|
rowHeightOverridesPx[rowIndex] = Math.max(MIN_ROW_HEIGHT_PX, Math.round(height * 1.33));
|
|
4623
4634
|
}
|
|
4624
4635
|
if (rowIndex >= 0 && Number.isFinite(styleId)) {
|
|
4625
4636
|
rowStyleIds[rowIndex] = styleId;
|
|
4626
4637
|
}
|
|
4627
|
-
if (rowIndex >= 0 && isHidden) {
|
|
4628
|
-
hiddenRows.add(rowIndex);
|
|
4629
|
-
}
|
|
4630
4638
|
getChildElements(rowNode, "c").forEach((cellNode) => {
|
|
4631
4639
|
const cellRef = cellNode.getAttribute("r");
|
|
4632
4640
|
if (isMeaningfulCellNode(cellNode)) {
|
|
@@ -4641,28 +4649,12 @@ function parseSheetState(archive, path, options) {
|
|
|
4641
4649
|
}
|
|
4642
4650
|
});
|
|
4643
4651
|
});
|
|
4644
|
-
|
|
4645
|
-
const reference = mergeNode.getAttribute("ref");
|
|
4646
|
-
const range = reference ? parseA1RangeReference(reference) : null;
|
|
4647
|
-
if (!range) {
|
|
4648
|
-
return;
|
|
4649
|
-
}
|
|
4650
|
-
if (range.end.col > range.start.col) {
|
|
4651
|
-
hasHorizontalMerges = true;
|
|
4652
|
-
maxHorizontalMergeEndCol = Math.max(maxHorizontalMergeEndCol, range.end.col);
|
|
4653
|
-
}
|
|
4654
|
-
if (range.end.row > range.start.row) {
|
|
4655
|
-
hasVerticalMerges = true;
|
|
4656
|
-
maxVerticalMergeEndRow = Math.max(maxVerticalMergeEndRow, range.end.row);
|
|
4657
|
-
}
|
|
4658
|
-
});
|
|
4659
|
-
const maxMetadataCol = Math.max(maxContentCol, maxHorizontalMergeEndCol, 0) + 256;
|
|
4652
|
+
const maxMetadataCol = Math.max(maxContentCol, 0) + 256;
|
|
4660
4653
|
getLocalElements(document2, "col").forEach((colNode) => {
|
|
4661
4654
|
const min = Number(colNode.getAttribute("min") ?? 0) - 1;
|
|
4662
4655
|
const max = Number(colNode.getAttribute("max") ?? 0) - 1;
|
|
4663
4656
|
const width = Number(colNode.getAttribute("width") ?? Number.NaN);
|
|
4664
4657
|
const styleId = Number(colNode.getAttribute("style") ?? Number.NaN);
|
|
4665
|
-
const isHidden = (colNode.getAttribute("hidden") ?? "0") === "1";
|
|
4666
4658
|
if (!Number.isFinite(width)) {
|
|
4667
4659
|
if (!Number.isFinite(styleId)) {
|
|
4668
4660
|
return;
|
|
@@ -4677,9 +4669,6 @@ function parseSheetState(archive, path, options) {
|
|
|
4677
4669
|
if (Number.isFinite(styleId)) {
|
|
4678
4670
|
colStyleIds[col] = styleId;
|
|
4679
4671
|
}
|
|
4680
|
-
if (isHidden) {
|
|
4681
|
-
hiddenCols.add(col);
|
|
4682
|
-
}
|
|
4683
4672
|
}
|
|
4684
4673
|
}
|
|
4685
4674
|
});
|
|
@@ -4691,16 +4680,16 @@ function parseSheetState(archive, path, options) {
|
|
|
4691
4680
|
conditionalFormatRules,
|
|
4692
4681
|
defaultColWidthPx: sheetColumnWidthToPixels(defaultColWidth, columnWidthCharacterWidthPx),
|
|
4693
4682
|
defaultRowHeightPx: Math.max(MIN_ROW_HEIGHT_PX, Math.round(defaultRowHeight * 1.33)),
|
|
4694
|
-
hasHorizontalMerges,
|
|
4695
|
-
hasVerticalMerges,
|
|
4696
|
-
maxHorizontalMergeEndCol,
|
|
4697
|
-
maxVerticalMergeEndRow,
|
|
4683
|
+
hasHorizontalMerges: false,
|
|
4684
|
+
hasVerticalMerges: false,
|
|
4685
|
+
maxHorizontalMergeEndCol: -1,
|
|
4686
|
+
maxVerticalMergeEndRow: -1,
|
|
4698
4687
|
maxContentCol,
|
|
4699
4688
|
maxContentRow,
|
|
4700
4689
|
minContentCol: Number.isFinite(minContentCol) ? minContentCol : -1,
|
|
4701
4690
|
minContentRow: Number.isFinite(minContentRow) ? minContentRow : -1,
|
|
4702
|
-
hiddenCols: [
|
|
4703
|
-
hiddenRows: [
|
|
4691
|
+
hiddenCols: [],
|
|
4692
|
+
hiddenRows: [],
|
|
4704
4693
|
rowHeightOverridesPx,
|
|
4705
4694
|
rowStyleIds,
|
|
4706
4695
|
showGridLines: (sheetViewNode?.getAttribute("showGridLines") ?? "1") !== "0",
|
|
@@ -5870,7 +5859,6 @@ function parseWorkbookStructureAssetsFromArchive(archive, options) {
|
|
|
5870
5859
|
const theme = parseWorkbookTheme(archive);
|
|
5871
5860
|
const themePalette = buildThemePalette(theme);
|
|
5872
5861
|
const { defaultFont, namedCellStyleByName, styleById, tableStyleByName } = parseWorkbookStyles(archive);
|
|
5873
|
-
const tableMetadataByWorkbookSheetIndex = parseWorkbookTableMetadata(archive, workbookSheets);
|
|
5874
5862
|
return {
|
|
5875
5863
|
contentTypes,
|
|
5876
5864
|
namedCellStyleByName,
|
|
@@ -5880,7 +5868,7 @@ function parseWorkbookStructureAssetsFromArchive(archive, options) {
|
|
|
5880
5868
|
themePalette
|
|
5881
5869
|
})),
|
|
5882
5870
|
styleById,
|
|
5883
|
-
tableMetadataByWorkbookSheetIndex,
|
|
5871
|
+
tableMetadataByWorkbookSheetIndex: workbookSheets.map(() => []),
|
|
5884
5872
|
tableStyleByName,
|
|
5885
5873
|
theme,
|
|
5886
5874
|
themePalette,
|
|
@@ -6777,16 +6765,20 @@ function resolveDisplayFileName(src, fileName) {
|
|
|
6777
6765
|
}
|
|
6778
6766
|
function resolveSheetDisplayUsedRange(usedRange, sheetState) {
|
|
6779
6767
|
const [minRow, minCol, maxRow, maxCol] = usedRange;
|
|
6780
|
-
const
|
|
6781
|
-
const
|
|
6768
|
+
const maxContentRow = sheetState?.maxContentRow ?? -1;
|
|
6769
|
+
const maxContentCol = sheetState?.maxContentCol ?? -1;
|
|
6770
|
+
const maxVerticalMergeEndRow = sheetState?.maxVerticalMergeEndRow ?? -1;
|
|
6771
|
+
const maxHorizontalMergeEndCol = sheetState?.maxHorizontalMergeEndCol ?? -1;
|
|
6772
|
+
const maxMeaningfulRow = Math.max(maxContentRow, maxVerticalMergeEndRow);
|
|
6773
|
+
const maxMeaningfulCol = Math.max(maxContentCol, maxHorizontalMergeEndCol);
|
|
6782
6774
|
if (maxMeaningfulRow < 0 && maxMeaningfulCol < 0) {
|
|
6783
6775
|
return usedRange;
|
|
6784
6776
|
}
|
|
6785
6777
|
return [
|
|
6786
6778
|
sheetState?.minContentRow !== void 0 && sheetState.minContentRow >= 0 ? Math.min(minRow, sheetState.minContentRow) : minRow,
|
|
6787
6779
|
sheetState?.minContentCol !== void 0 && sheetState.minContentCol >= 0 ? Math.min(minCol, sheetState.minContentCol) : minCol,
|
|
6788
|
-
maxMeaningfulRow >= 0 ? Math.min(maxRow, maxMeaningfulRow) : maxRow,
|
|
6789
|
-
maxMeaningfulCol >= 0 ? Math.min(maxCol, maxMeaningfulCol) : maxCol
|
|
6780
|
+
maxMeaningfulRow >= 0 ? maxContentRow >= 0 ? Math.min(maxRow, maxMeaningfulRow) : Math.max(maxRow, maxMeaningfulRow) : maxRow,
|
|
6781
|
+
maxMeaningfulCol >= 0 ? maxContentCol >= 0 ? Math.min(maxCol, maxMeaningfulCol) : Math.max(maxCol, maxMeaningfulCol) : maxCol
|
|
6790
6782
|
];
|
|
6791
6783
|
}
|
|
6792
6784
|
function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette, styleById, namedCellStyleByName, tableStyleByName, showHiddenSheets = false) {
|
|
@@ -6794,6 +6786,20 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
6794
6786
|
for (let index = 0; index < workbook.sheetCount; index += 1) {
|
|
6795
6787
|
const worksheet = workbook.getSheet(index);
|
|
6796
6788
|
const sheetState = sheetStatesByWorkbookSheetIndex?.[index] ?? null;
|
|
6789
|
+
const mergeMetadata = resolveWorksheetMergeMetadata(worksheet);
|
|
6790
|
+
const effectiveSheetState = {
|
|
6791
|
+
...sheetState,
|
|
6792
|
+
...mergeMetadata
|
|
6793
|
+
};
|
|
6794
|
+
const defaultColWidthPx = resolveWorksheetDefaultColumnWidthPixels(
|
|
6795
|
+
worksheet,
|
|
6796
|
+
sheetState?.columnWidthCharacterWidthPx,
|
|
6797
|
+
sheetState?.defaultColWidthPx ?? DEFAULT_COL_WIDTH
|
|
6798
|
+
);
|
|
6799
|
+
const defaultRowHeightPx = resolveWorksheetDefaultRowHeightPixels(
|
|
6800
|
+
worksheet,
|
|
6801
|
+
sheetState?.defaultRowHeightPx ?? DEFAULT_ROW_HEIGHT
|
|
6802
|
+
);
|
|
6797
6803
|
const visibility = normalizeWorksheetVisibility2(worksheet.visibility);
|
|
6798
6804
|
if (!showHiddenSheets && visibility !== "visible") {
|
|
6799
6805
|
continue;
|
|
@@ -6803,14 +6809,14 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
6803
6809
|
if (width !== void 0 && width !== null) {
|
|
6804
6810
|
return resolveSheetColumnWidthPixels(width, sheetState?.columnWidthCharacterWidthPx);
|
|
6805
6811
|
}
|
|
6806
|
-
return sheetState?.colWidthOverridesPx?.[col] ??
|
|
6812
|
+
return sheetState?.colWidthOverridesPx?.[col] ?? defaultColWidthPx;
|
|
6807
6813
|
};
|
|
6808
6814
|
const resolveRowHeightPx = (row) => {
|
|
6809
6815
|
const height = worksheet.getRowHeight(row);
|
|
6810
6816
|
if (height !== void 0 && height !== null) {
|
|
6811
6817
|
return Math.max(Math.round(height * 1.33), MIN_ROW_HEIGHT_PX2);
|
|
6812
6818
|
}
|
|
6813
|
-
return sheetState?.rowHeightOverridesPx?.[row] ??
|
|
6819
|
+
return sheetState?.rowHeightOverridesPx?.[row] ?? defaultRowHeightPx;
|
|
6814
6820
|
};
|
|
6815
6821
|
const usedRange = worksheet.usedRange();
|
|
6816
6822
|
if (!usedRange) {
|
|
@@ -6821,15 +6827,15 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
6821
6827
|
colStyleIds: sheetState?.colStyleIds ?? {},
|
|
6822
6828
|
conditionalFormatRules: sheetState?.conditionalFormatRules ?? [],
|
|
6823
6829
|
dataValidations: parseWorksheetDataValidations(worksheet),
|
|
6824
|
-
defaultColWidthPx
|
|
6825
|
-
defaultRowHeightPx
|
|
6830
|
+
defaultColWidthPx,
|
|
6831
|
+
defaultRowHeightPx,
|
|
6826
6832
|
freezePanes: parseWorksheetFreezePanes(worksheet),
|
|
6827
|
-
hasHorizontalMerges:
|
|
6828
|
-
hasVerticalMerges:
|
|
6829
|
-
maxHorizontalMergeEndCol:
|
|
6830
|
-
maxVerticalMergeEndRow:
|
|
6831
|
-
hiddenCols:
|
|
6832
|
-
hiddenRows:
|
|
6833
|
+
hasHorizontalMerges: mergeMetadata.hasHorizontalMerges,
|
|
6834
|
+
hasVerticalMerges: mergeMetadata.hasVerticalMerges,
|
|
6835
|
+
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
6836
|
+
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
6837
|
+
hiddenCols: [],
|
|
6838
|
+
hiddenRows: [],
|
|
6833
6839
|
minUsedCol: -1,
|
|
6834
6840
|
minUsedRow: -1,
|
|
6835
6841
|
maxUsedCol: -1,
|
|
@@ -6855,7 +6861,7 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
6855
6861
|
});
|
|
6856
6862
|
continue;
|
|
6857
6863
|
}
|
|
6858
|
-
const [minRow, minCol, maxRow, maxCol] = resolveSheetDisplayUsedRange(usedRange,
|
|
6864
|
+
const [minRow, minCol, maxRow, maxCol] = resolveSheetDisplayUsedRange(usedRange, effectiveSheetState);
|
|
6859
6865
|
let visibleRowsCache = null;
|
|
6860
6866
|
let visibleColsCache = null;
|
|
6861
6867
|
let rowHeightsCache = null;
|
|
@@ -6907,15 +6913,15 @@ function buildSheetList(workbook, sheetStatesByWorkbookSheetIndex, themePalette,
|
|
|
6907
6913
|
colStyleIds: sheetState?.colStyleIds ?? {},
|
|
6908
6914
|
conditionalFormatRules: sheetState?.conditionalFormatRules ?? [],
|
|
6909
6915
|
dataValidations: parseWorksheetDataValidations(worksheet),
|
|
6910
|
-
defaultColWidthPx
|
|
6911
|
-
defaultRowHeightPx
|
|
6916
|
+
defaultColWidthPx,
|
|
6917
|
+
defaultRowHeightPx,
|
|
6912
6918
|
freezePanes: parseWorksheetFreezePanes(worksheet),
|
|
6913
|
-
hasHorizontalMerges:
|
|
6914
|
-
hasVerticalMerges:
|
|
6915
|
-
maxHorizontalMergeEndCol:
|
|
6916
|
-
maxVerticalMergeEndRow:
|
|
6917
|
-
hiddenCols:
|
|
6918
|
-
hiddenRows:
|
|
6919
|
+
hasHorizontalMerges: mergeMetadata.hasHorizontalMerges,
|
|
6920
|
+
hasVerticalMerges: mergeMetadata.hasVerticalMerges,
|
|
6921
|
+
maxHorizontalMergeEndCol: mergeMetadata.maxHorizontalMergeEndCol,
|
|
6922
|
+
maxVerticalMergeEndRow: mergeMetadata.maxVerticalMergeEndRow,
|
|
6923
|
+
hiddenCols: resolveWorksheetHiddenCols(worksheet, maxCol),
|
|
6924
|
+
hiddenRows: resolveWorksheetHiddenRows(worksheet, maxRow),
|
|
6919
6925
|
minUsedCol: minCol,
|
|
6920
6926
|
minUsedRow: minRow,
|
|
6921
6927
|
maxUsedCol: maxCol,
|
|
@@ -7074,17 +7080,14 @@ function rangeContainsCell(range, cell) {
|
|
|
7074
7080
|
const normalized = normalizeRange(range);
|
|
7075
7081
|
return cell.row >= normalized.start.row && cell.row <= normalized.end.row && cell.col >= normalized.start.col && cell.col <= normalized.end.col;
|
|
7076
7082
|
}
|
|
7077
|
-
function mapWorksheetTables(worksheet
|
|
7083
|
+
function mapWorksheetTables(worksheet) {
|
|
7078
7084
|
const rawTables = worksheet?.tables ?? [];
|
|
7079
7085
|
return rawTables.flatMap((table, index) => {
|
|
7080
7086
|
const rawColumns = Array.isArray(table.columns) ? table.columns : [];
|
|
7081
7087
|
const rawName = typeof table.name === "string" ? table.name : `Table${index + 1}`;
|
|
7082
7088
|
const rawDisplayName = typeof table.displayName === "string" ? table.displayName : typeof table.name === "string" ? table.name : `Table ${index + 1}`;
|
|
7083
|
-
const metadata = metadataForSheet?.find(
|
|
7084
|
-
(entry) => entry.name && entry.name === rawName || entry.displayName && entry.displayName === rawDisplayName || entry.reference && entry.reference === table.reference
|
|
7085
|
-
);
|
|
7086
7089
|
const rawReference = typeof table.reference === "string" ? table.reference : "";
|
|
7087
|
-
const reference =
|
|
7090
|
+
const reference = rawReference;
|
|
7088
7091
|
const parsedRange = parseA1RangeReference2(reference);
|
|
7089
7092
|
if (!parsedRange) {
|
|
7090
7093
|
return [];
|
|
@@ -7097,14 +7100,14 @@ function mapWorksheetTables(worksheet, metadataForSheet) {
|
|
|
7097
7100
|
})),
|
|
7098
7101
|
displayName: rawDisplayName,
|
|
7099
7102
|
end: parsedRange.end,
|
|
7100
|
-
headerRowCount:
|
|
7101
|
-
headerRowCellStyle:
|
|
7103
|
+
headerRowCount: resolveWorkbookTableCount(table.headerRowCount, 1),
|
|
7104
|
+
headerRowCellStyle: typeof table.headerRowCellStyle === "string" ? table.headerRowCellStyle : void 0,
|
|
7102
7105
|
name: rawName,
|
|
7103
7106
|
reference,
|
|
7104
7107
|
start: parsedRange.start,
|
|
7105
7108
|
styleInfo: table.styleInfo,
|
|
7106
|
-
totalsRowCount:
|
|
7107
|
-
totalsRowShown:
|
|
7109
|
+
totalsRowCount: resolveWorkbookTableCount(table.totalsRowCount, 0),
|
|
7110
|
+
totalsRowShown: resolveWorkbookTableBoolean(table.totalsRowShown)
|
|
7108
7111
|
}];
|
|
7109
7112
|
});
|
|
7110
7113
|
}
|
|
@@ -8579,10 +8582,9 @@ function useXlsxViewerController(options) {
|
|
|
8579
8582
|
}
|
|
8580
8583
|
return workbook.getSheet(activeSheet.workbookSheetIndex);
|
|
8581
8584
|
}, [activeSheet, workbook]);
|
|
8582
|
-
const activeTableMetadata = imageAssetsRef.current?.tableMetadataByWorkbookSheetIndex[activeSheet?.workbookSheetIndex ?? -1] ?? null;
|
|
8583
8585
|
const tables = React.useMemo(
|
|
8584
|
-
() => isWorkerBacked ? workerTablesByWorkbookSheetIndex[activeSheet?.workbookSheetIndex ?? -1] ?? [] : mapWorksheetTables(getActiveWorksheet()
|
|
8585
|
-
[activeSheet?.workbookSheetIndex,
|
|
8586
|
+
() => isWorkerBacked ? workerTablesByWorkbookSheetIndex[activeSheet?.workbookSheetIndex ?? -1] ?? [] : mapWorksheetTables(getActiveWorksheet()),
|
|
8587
|
+
[activeSheet?.workbookSheetIndex, getActiveWorksheet, isWorkerBacked, revision, workerTablesByWorkbookSheetIndex]
|
|
8586
8588
|
);
|
|
8587
8589
|
const getCellSnapshotAsync = React.useCallback((workbookSheetIndex, row, col) => {
|
|
8588
8590
|
if (!isWorkerBacked) {
|