Preserve QExcell cell borders
This commit is contained in:
@@ -177,6 +177,32 @@ describe("excellOffice OOXML helpers", () => {
|
||||
expect(stylesXml).toContain('vertical="center"');
|
||||
});
|
||||
|
||||
it("записывает границы ячейки XLSX в styles.xml", async () => {
|
||||
const blob = await exportXlsxBlob({
|
||||
id: "workbook",
|
||||
title: "Borders.xlsx",
|
||||
updatedAt: "2026-06-01T00:00:00.000Z",
|
||||
activeSheet: "sheet-1",
|
||||
sheets: [
|
||||
{
|
||||
id: "sheet-1",
|
||||
name: "Sheet 1",
|
||||
cells: { A1: "Bordered" },
|
||||
cellFormats: { A1: { border: true } }
|
||||
}
|
||||
]
|
||||
});
|
||||
const zip = await JSZip.loadAsync(await blob.arrayBuffer());
|
||||
const stylesXml = await zip.file("xl/styles.xml")?.async("string");
|
||||
|
||||
expect(stylesXml).toContain('<borders count="2">');
|
||||
expect(stylesXml).toContain('applyBorder="1"');
|
||||
expect(stylesXml).toContain('<left style="thin">');
|
||||
expect(stylesXml).toContain('<right style="thin">');
|
||||
expect(stylesXml).toContain('<top style="thin">');
|
||||
expect(stylesXml).toContain('<bottom style="thin">');
|
||||
});
|
||||
|
||||
it("читает базовое форматирование ячеек XLSX из styles.xml и XML листа", () => {
|
||||
const styleTable = xlsxStylesXmlToCellFormatTable({
|
||||
styleSheet: {
|
||||
@@ -189,10 +215,13 @@ describe("excellOffice OOXML helpers", () => {
|
||||
fills: {
|
||||
fill: [{}, {}, { patternFill: { fgColor: { rgb: "FFFFF2CC" } } }]
|
||||
},
|
||||
borders: {
|
||||
border: [{}, { left: { style: "thin" }, right: { style: "thin" }, top: { style: "thin" }, bottom: { style: "thin" } }]
|
||||
},
|
||||
cellXfs: {
|
||||
xf: [
|
||||
{ fontId: "0", fillId: "0" },
|
||||
{ fontId: "1", fillId: "2", numFmtId: "164", alignment: { horizontal: "center", vertical: "center", wrapText: "1" } },
|
||||
{ fontId: "1", fillId: "2", borderId: "1", numFmtId: "164", alignment: { horizontal: "center", vertical: "center", wrapText: "1" } },
|
||||
{ fontId: "0", fillId: "0", numFmtId: "14" }
|
||||
]
|
||||
}
|
||||
@@ -211,6 +240,7 @@ describe("excellOffice OOXML helpers", () => {
|
||||
horizontalAlign: "center",
|
||||
verticalAlign: "middle",
|
||||
wrapText: true,
|
||||
border: true,
|
||||
numberFormat: "dd.mm.yyyy"
|
||||
});
|
||||
expect(styleTable[2]).toEqual({ numberFormat: "m/d/yy" });
|
||||
@@ -241,6 +271,7 @@ describe("excellOffice OOXML helpers", () => {
|
||||
horizontalAlign: "center",
|
||||
verticalAlign: "middle",
|
||||
wrapText: true,
|
||||
border: true,
|
||||
numberFormat: "dd.mm.yyyy"
|
||||
}
|
||||
});
|
||||
@@ -442,7 +473,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", verticalAlign: "middle", wrapText: true },
|
||||
A1: { bold: true, strike: true, fontSize: 14, fontFamily: "Arial", textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center", verticalAlign: "middle", wrapText: true, border: true },
|
||||
AC20: { underline: true },
|
||||
D20: { numberFormat: "dd.mm.yyyy" },
|
||||
E20: { numberFormat: "0%" }
|
||||
@@ -476,7 +507,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", verticalAlign: "middle", wrapText: true },
|
||||
A1: { bold: true, strike: true, fontSize: 14, fontFamily: "Arial", textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center", verticalAlign: "middle", wrapText: true, border: true },
|
||||
AC20: { underline: true },
|
||||
D20: { numberFormat: "dd.mm.yyyy" },
|
||||
E20: { numberFormat: "0%" }
|
||||
|
||||
Reference in New Issue
Block a user