Preserve QExcell print areas in XLSX
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
chartDataPoints,
|
||||
chartXmlToSheetChart,
|
||||
workbookActiveSheetId,
|
||||
workbookPrintAreas,
|
||||
workbookRelationshipTargets,
|
||||
workbookSheetRefs,
|
||||
worksheetXmlToAutoFilter,
|
||||
@@ -576,6 +577,46 @@ describe("excellOffice OOXML helpers", () => {
|
||||
expect(imported.activeSheet).toBe("sheet-2");
|
||||
});
|
||||
|
||||
it("сохраняет и импортирует область печати XLSX через definedName _xlnm.Print_Area", async () => {
|
||||
expect(
|
||||
workbookPrintAreas(
|
||||
{
|
||||
workbook: {
|
||||
definedNames: {
|
||||
definedName: [
|
||||
{ name: "_xlnm.Print_Area", localSheetId: "0", "#text": "'Отчет'!$D$20:$A$1" },
|
||||
{ name: "_xlnm.Print_Area", localSheetId: "1", "#text": "'Архив'!$B$2:$C$4,'Архив'!$E$1:$E$3" }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
[
|
||||
{ id: "sheet-1", name: "Отчет" },
|
||||
{ id: "sheet-2", name: "Архив" }
|
||||
]
|
||||
)
|
||||
).toEqual({ "sheet-1": "A1:D20", "sheet-2": "B2:C4,E1:E3" });
|
||||
|
||||
const blob = await exportXlsxBlob({
|
||||
id: "book-1",
|
||||
title: "Область печати.xlsx",
|
||||
updatedAt: "2026-06-01T00:00:00.000Z",
|
||||
activeSheet: "sheet-1",
|
||||
sheets: [
|
||||
{ id: "sheet-1", name: "Отчет", printArea: "D20:A1", cells: { A1: "Начало", D20: "Итог" } },
|
||||
{ id: "sheet-2", name: "Архив", printArea: "B2:C4,E1:E3", cells: { B2: "Архив" } }
|
||||
]
|
||||
});
|
||||
const zip = await JSZip.loadAsync(await blob.arrayBuffer());
|
||||
const workbookXml = await zip.file("xl/workbook.xml")?.async("string");
|
||||
const imported = await importXlsxFile(new File([blob], "Область печати.xlsx", { type: blob.type }));
|
||||
|
||||
expect(workbookXml).toContain('<definedNames><definedName name="_xlnm.Print_Area" localSheetId="0">\'Отчет\'!$A$1:$D$20</definedName>');
|
||||
expect(workbookXml).toContain('<definedName name="_xlnm.Print_Area" localSheetId="1">\'Архив\'!$B$2:$C$4,\'Архив\'!$E$1:$E$3</definedName></definedNames>');
|
||||
expect(imported.sheets[0].printArea).toBe("A1:D20");
|
||||
expect(imported.sheets[1].printArea).toBe("B2:C4,E1:E3");
|
||||
});
|
||||
|
||||
it("сохраняет и импортирует скрытые листы XLSX через sheet state", async () => {
|
||||
const blob = await exportXlsxBlob({
|
||||
id: "book-1",
|
||||
|
||||
Reference in New Issue
Block a user