Preserve QExcell vertical alignment

This commit is contained in:
Курнат Андрей
2026-06-01 07:42:53 +03:00
parent 4822ba84a0
commit 25d42363dd
6 changed files with 115 additions and 8 deletions
+27 -3
View File
@@ -155,6 +155,28 @@ describe("excellOffice OOXML helpers", () => {
expect(stylesXml).toContain('wrapText="1"');
});
it("записывает вертикальное выравнивание ячейки XLSX в styles.xml", async () => {
const blob = await exportXlsxBlob({
id: "workbook",
title: "VerticalAlign.xlsx",
updatedAt: "2026-06-01T00:00:00.000Z",
activeSheet: "sheet-1",
sheets: [
{
id: "sheet-1",
name: "Sheet 1",
cells: { A1: "Centered" },
cellFormats: { A1: { verticalAlign: "middle" } }
}
]
});
const zip = await JSZip.loadAsync(await blob.arrayBuffer());
const stylesXml = await zip.file("xl/styles.xml")?.async("string");
expect(stylesXml).toContain('applyAlignment="1"');
expect(stylesXml).toContain('vertical="center"');
});
it("читает базовое форматирование ячеек XLSX из styles.xml и XML листа", () => {
const styleTable = xlsxStylesXmlToCellFormatTable({
styleSheet: {
@@ -170,7 +192,7 @@ describe("excellOffice OOXML helpers", () => {
cellXfs: {
xf: [
{ fontId: "0", fillId: "0" },
{ fontId: "1", fillId: "2", numFmtId: "164", alignment: { horizontal: "center", wrapText: "1" } },
{ fontId: "1", fillId: "2", numFmtId: "164", alignment: { horizontal: "center", vertical: "center", wrapText: "1" } },
{ fontId: "0", fillId: "0", numFmtId: "14" }
]
}
@@ -187,6 +209,7 @@ describe("excellOffice OOXML helpers", () => {
textColor: "0F5FAE",
fillColor: "FFF2CC",
horizontalAlign: "center",
verticalAlign: "middle",
wrapText: true,
numberFormat: "dd.mm.yyyy"
});
@@ -216,6 +239,7 @@ describe("excellOffice OOXML helpers", () => {
textColor: "0F5FAE",
fillColor: "FFF2CC",
horizontalAlign: "center",
verticalAlign: "middle",
wrapText: true,
numberFormat: "dd.mm.yyyy"
}
@@ -418,7 +442,7 @@ describe("excellOffice OOXML helpers", () => {
mergedCells: [{ start: "A1", end: "C1" }],
hyperlinks: { A1: "https://example.com/budget" },
cellFormats: {
A1: { bold: true, strike: true, fontSize: 14, fontFamily: "Arial", textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center", wrapText: true },
A1: { bold: true, strike: true, fontSize: 14, fontFamily: "Arial", textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center", verticalAlign: "middle", wrapText: true },
AC20: { underline: true },
D20: { numberFormat: "dd.mm.yyyy" },
E20: { numberFormat: "0%" }
@@ -452,7 +476,7 @@ describe("excellOffice OOXML helpers", () => {
expect(imported.sheets[0].mergedCells).toEqual([{ start: "A1", end: "C1" }]);
expect(imported.sheets[0].hyperlinks).toEqual({ A1: "https://example.com/budget" });
expect(imported.sheets[0].cellFormats).toEqual({
A1: { bold: true, strike: true, fontSize: 14, fontFamily: "Arial", textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center", wrapText: true },
A1: { bold: true, strike: true, fontSize: 14, fontFamily: "Arial", textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center", verticalAlign: "middle", wrapText: true },
AC20: { underline: true },
D20: { numberFormat: "dd.mm.yyyy" },
E20: { numberFormat: "0%" }