Add QExcell cell alignment

This commit is contained in:
Курнат Андрей
2026-06-01 06:22:37 +03:00
parent 9c48e1d8b1
commit 24206eb8bb
6 changed files with 82 additions and 17 deletions
+28 -6
View File
@@ -76,7 +76,7 @@ describe("excellOffice OOXML helpers", () => {
it("сохраняет базовое форматирование ячеек XLSX в XML листа", () => {
const cellFormats = {
A1: { bold: true, textColor: "0f5fae", fillColor: "fff2cc" },
A1: { bold: true, textColor: "0f5fae", fillColor: "fff2cc", horizontalAlign: "center" as const },
B2: { italics: true, underline: true },
C3: { fillColor: "bad-color" }
};
@@ -103,12 +103,24 @@ describe("excellOffice OOXML helpers", () => {
fill: [{}, {}, { patternFill: { fgColor: { rgb: "FFFFF2CC" } } }]
},
cellXfs: {
xf: [{ fontId: "0", fillId: "0" }, { fontId: "1", fillId: "2", numFmtId: "164" }, { fontId: "0", fillId: "0", numFmtId: "14" }]
xf: [
{ fontId: "0", fillId: "0" },
{ fontId: "1", fillId: "2", numFmtId: "164", alignment: { horizontal: "center" } },
{ fontId: "0", fillId: "0", numFmtId: "14" }
]
}
}
});
expect(styleTable[1]).toEqual({ bold: true, italics: true, underline: true, textColor: "0F5FAE", fillColor: "FFF2CC", numberFormat: "dd.mm.yyyy" });
expect(styleTable[1]).toEqual({
bold: true,
italics: true,
underline: true,
textColor: "0F5FAE",
fillColor: "FFF2CC",
horizontalAlign: "center",
numberFormat: "dd.mm.yyyy"
});
expect(styleTable[2]).toEqual({ numberFormat: "m/d/yy" });
expect(
worksheetXmlToCellFormats(
@@ -124,7 +136,17 @@ describe("excellOffice OOXML helpers", () => {
},
styleTable
)
).toEqual({ A1: { bold: true, italics: true, underline: true, textColor: "0F5FAE", fillColor: "FFF2CC", numberFormat: "dd.mm.yyyy" } });
).toEqual({
A1: {
bold: true,
italics: true,
underline: true,
textColor: "0F5FAE",
fillColor: "FFF2CC",
horizontalAlign: "center",
numberFormat: "dd.mm.yyyy"
}
});
});
it("преобразует XML листа в модель QExcell", () => {
@@ -323,7 +345,7 @@ describe("excellOffice OOXML helpers", () => {
mergedCells: [{ start: "A1", end: "C1" }],
hyperlinks: { A1: "https://example.com/budget" },
cellFormats: {
A1: { bold: true, textColor: "0F5FAE", fillColor: "FFF2CC" },
A1: { bold: true, textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center" },
AC20: { underline: true },
D20: { numberFormat: "dd.mm.yyyy" },
E20: { numberFormat: "0%" }
@@ -357,7 +379,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, textColor: "0F5FAE", fillColor: "FFF2CC" },
A1: { bold: true, textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center" },
AC20: { underline: true },
D20: { numberFormat: "dd.mm.yyyy" },
E20: { numberFormat: "0%" }