Preserve QExcell hidden rows and columns in XLSX
This commit is contained in:
@@ -25,6 +25,8 @@ import {
|
||||
worksheetXmlToCellFormats,
|
||||
worksheetXmlToColumnWidths,
|
||||
worksheetXmlToFrozenPane,
|
||||
worksheetXmlToHiddenColumns,
|
||||
worksheetXmlToHiddenRows,
|
||||
worksheetXmlToHyperlinks,
|
||||
worksheetXmlToMergedCells,
|
||||
worksheetXmlToRowHeights,
|
||||
@@ -912,6 +914,62 @@ describe("excellOffice OOXML helpers", () => {
|
||||
expect(imported.sheets[0].rowHeights).toEqual({ "1": 24, "4": 30.5 });
|
||||
});
|
||||
|
||||
it("читает и записывает скрытые колонки и строки XLSX", async () => {
|
||||
expect(
|
||||
worksheetXmlToHiddenColumns({
|
||||
worksheet: {
|
||||
cols: {
|
||||
col: [
|
||||
{ min: "2", max: "3", hidden: "1" },
|
||||
{ min: "5", max: "5", width: "12", hidden: "true" }
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
).toEqual({ B: true, C: true, E: true });
|
||||
expect(
|
||||
worksheetXmlToHiddenRows({
|
||||
worksheet: {
|
||||
sheetData: {
|
||||
row: [{ r: "4", hidden: "1" }, { r: "6", ht: "21", hidden: "true" }]
|
||||
}
|
||||
}
|
||||
})
|
||||
).toEqual({ "4": true, "6": true });
|
||||
expect(buildColumnWidthsXml({ E: 12 }, { B: true, C: true, E: true })).toBe(
|
||||
'<cols><col min="2" max="2" hidden="1"/><col min="3" max="3" hidden="1"/><col min="5" max="5" width="12" customWidth="1" hidden="1"/></cols>'
|
||||
);
|
||||
|
||||
const blob = await exportXlsxBlob({
|
||||
id: "book-1",
|
||||
title: "Hidden rows and columns.xlsx",
|
||||
updatedAt: "2026-06-01T00:00:00.000Z",
|
||||
activeSheet: "sheet-1",
|
||||
sheets: [
|
||||
{
|
||||
id: "sheet-1",
|
||||
name: "Hidden",
|
||||
columnWidths: { E: 12 },
|
||||
rowHeights: { "6": 21 },
|
||||
hiddenColumns: { B: true, C: true, E: true },
|
||||
hiddenRows: { "4": true, "6": true },
|
||||
cells: { A1: "Visible" }
|
||||
}
|
||||
]
|
||||
});
|
||||
const zip = await JSZip.loadAsync(await blob.arrayBuffer());
|
||||
const sheetXml = (await zip.file("xl/worksheets/sheet1.xml")?.async("string")) ?? "";
|
||||
const imported = await importXlsxFile(new File([blob], "Hidden rows and columns.xlsx", { type: blob.type }));
|
||||
|
||||
expect(sheetXml).toContain(
|
||||
'<cols><col min="2" max="2" hidden="1"/><col min="3" max="3" hidden="1"/><col min="5" max="5" width="12" customWidth="1" hidden="1"/></cols>'
|
||||
);
|
||||
expect(sheetXml).toContain('<row r="4" hidden="1"/>');
|
||||
expect(sheetXml).toContain('<row r="6" ht="21" customHeight="1" hidden="1"/>');
|
||||
expect(imported.sheets[0].hiddenColumns).toEqual({ B: true, C: true, E: true });
|
||||
expect(imported.sheets[0].hiddenRows).toEqual({ "4": true, "6": true });
|
||||
});
|
||||
|
||||
it("создает OOXML chart part для диаграммы XLSX", () => {
|
||||
const xml = buildChartXml(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user