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
+6 -4
View File
@@ -936,12 +936,12 @@ function cellFormatKey(format: CellFormat | undefined) {
return "";
}
return `${normalized.bold ? "1" : "0"}|${normalized.italics ? "1" : "0"}|${normalized.underline ? "1" : "0"}|${normalized.fontSize ?? ""}|${normalized.textColor ?? ""}|${normalized.fillColor ?? ""}|${normalized.horizontalAlign ?? ""}|${normalized.numberFormat ?? ""}`;
return `${normalized.bold ? "1" : "0"}|${normalized.italics ? "1" : "0"}|${normalized.underline ? "1" : "0"}|${normalized.strike ? "1" : "0"}|${normalized.fontSize ?? ""}|${normalized.textColor ?? ""}|${normalized.fillColor ?? ""}|${normalized.horizontalAlign ?? ""}|${normalized.numberFormat ?? ""}`;
}
function fontStyleKey(format: CellFormat) {
return format.bold || format.italics || format.underline || format.fontSize || format.textColor
? `${format.bold ? "1" : "0"}|${format.italics ? "1" : "0"}|${format.underline ? "1" : "0"}|${format.fontSize ?? ""}|${format.textColor ?? ""}`
return format.bold || format.italics || format.underline || format.strike || format.fontSize || format.textColor
? `${format.bold ? "1" : "0"}|${format.italics ? "1" : "0"}|${format.underline ? "1" : "0"}|${format.strike ? "1" : "0"}|${format.fontSize ?? ""}|${format.textColor ?? ""}`
: "";
}
@@ -955,6 +955,7 @@ function normalizedCellFormat(format: CellFormat | undefined): CellFormat | null
...(format?.bold ? { bold: true } : {}),
...(format?.italics ? { italics: true } : {}),
...(format?.underline ? { underline: true } : {}),
...(format?.strike ? { strike: true } : {}),
...(fontSize ? { fontSize } : {}),
...(textColor ? { textColor } : {}),
...(fillColor ? { fillColor } : {}),
@@ -974,6 +975,7 @@ function fontXmlToCellFormat(font: unknown): CellFormat {
bold: hasXmlElement(record, "b"),
italics: hasXmlElement(record, "i"),
underline: hasXmlElement(record, "u"),
strike: hasXmlElement(record, "strike"),
...(fontSize ? { fontSize } : {}),
...(textColor ? { textColor } : {})
}) ?? {}
@@ -991,7 +993,7 @@ function baseFontXml() {
}
function formatFontXml(format: CellFormat) {
const flags = `${format.bold ? "<b/>" : ""}${format.italics ? "<i/>" : ""}${format.underline ? "<u/>" : ""}`;
const flags = `${format.bold ? "<b/>" : ""}${format.italics ? "<i/>" : ""}${format.underline ? "<u/>" : ""}${format.strike ? "<strike/>" : ""}`;
const color = format.textColor ? `<color rgb="FF${format.textColor}"/>` : '<color theme="1"/>';
return `<font>${flags}<sz val="${format.fontSize ?? 11}"/>${color}<name val="Calibri"/><family val="2"/></font>`;
}