Preserve QExcell strikethrough formatting

This commit is contained in:
Курнат Андрей
2026-06-01 07:19:23 +03:00
parent ea26f5c55d
commit c2eaff87c6
5 changed files with 51 additions and 12 deletions
+28 -4
View File
@@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest";
import JSZip from "jszip";
import {
buildChartXml,
buildCellXml,
@@ -77,7 +78,7 @@ describe("excellOffice OOXML helpers", () => {
it("сохраняет базовое форматирование ячеек XLSX в XML листа", () => {
const cellFormats = {
A1: { bold: true, fontSize: 14, textColor: "0f5fae", fillColor: "fff2cc", horizontalAlign: "center" as const },
B2: { italics: true, underline: true },
B2: { italics: true, underline: true, strike: true },
C3: { fillColor: "bad-color" }
};
const registry = createCellStyleRegistry([cellFormats]);
@@ -90,6 +91,27 @@ describe("excellOffice OOXML helpers", () => {
expect(emptyCellXml).toContain('<c r="C3" s="1"/>');
});
it("записывает зачеркивание ячейки XLSX в styles.xml", async () => {
const blob = await exportXlsxBlob({
id: "workbook",
title: "Strike.xlsx",
updatedAt: "2026-06-01T00:00:00.000Z",
activeSheet: "sheet-1",
sheets: [
{
id: "sheet-1",
name: "Sheet 1",
cells: { A1: "Deleted" },
cellFormats: { A1: { strike: true } }
}
]
});
const zip = await JSZip.loadAsync(await blob.arrayBuffer());
const stylesXml = await zip.file("xl/styles.xml")?.async("string");
expect(stylesXml).toContain("<strike/>");
});
it("читает базовое форматирование ячеек XLSX из styles.xml и XML листа", () => {
const styleTable = xlsxStylesXmlToCellFormatTable({
styleSheet: {
@@ -97,7 +119,7 @@ describe("excellOffice OOXML helpers", () => {
numFmt: { numFmtId: "164", formatCode: "dd.mm.yyyy" }
},
fonts: {
font: [{}, { b: {}, i: {}, u: {}, sz: { val: "14" }, color: { rgb: "FF0F5FAE" } }]
font: [{}, { b: {}, i: {}, u: {}, strike: {}, sz: { val: "14" }, color: { rgb: "FF0F5FAE" } }]
},
fills: {
fill: [{}, {}, { patternFill: { fgColor: { rgb: "FFFFF2CC" } } }]
@@ -116,6 +138,7 @@ describe("excellOffice OOXML helpers", () => {
bold: true,
italics: true,
underline: true,
strike: true,
fontSize: 14,
textColor: "0F5FAE",
fillColor: "FFF2CC",
@@ -142,6 +165,7 @@ describe("excellOffice OOXML helpers", () => {
bold: true,
italics: true,
underline: true,
strike: true,
fontSize: 14,
textColor: "0F5FAE",
fillColor: "FFF2CC",
@@ -347,7 +371,7 @@ describe("excellOffice OOXML helpers", () => {
mergedCells: [{ start: "A1", end: "C1" }],
hyperlinks: { A1: "https://example.com/budget" },
cellFormats: {
A1: { bold: true, fontSize: 14, textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center" },
A1: { bold: true, strike: true, fontSize: 14, textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center" },
AC20: { underline: true },
D20: { numberFormat: "dd.mm.yyyy" },
E20: { numberFormat: "0%" }
@@ -381,7 +405,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, fontSize: 14, textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center" },
A1: { bold: true, strike: true, fontSize: 14, textColor: "0F5FAE", fillColor: "FFF2CC", horizontalAlign: "center" },
AC20: { underline: true },
D20: { numberFormat: "dd.mm.yyyy" },
E20: { numberFormat: "0%" }