EPPlus
EPPlus copied to clipboard
Font Style Doesn't Stick Sometimes (Starting in 6.2.3)
I recently upgraded from EPPlus 6.1.1 to the latest version and noticed an issue. I am setting the entire worksheet to default to Arial 12pt, but certain cells do not keep this and revert to Calibri 11pt. I have narrowed it down to see that the issue began in 6.2.3. Previous versions are ok.
Here is an example Program.cs
test to reproduce.
using OfficeOpenXml;
var filepath = "./test.xlsx";
File.Delete(filepath);
using var stream = new FileStream(filepath, FileMode.CreateNew);
using var package = new ExcelPackage(stream);
var worksheet = package.Workbook.Worksheets.Add("Worksheet");
// Default entire worksheet to Arial 12pt
worksheet.Cells["A:XFD"].Style.Font.Name = "Arial";
worksheet.Cells["A:XFD"].Style.Font.Size = 12;
// Header row
worksheet.Row(1).Style.Font.Bold = true;
worksheet.Cells[1, 1].Value = "COL1";
worksheet.Cells[1, 2].Value = "COL2";
worksheet.Cells[1, 3].Value = "COL3";
package.Save();
The expected result is that all cells will stay as Arial since I am never changing the font. However, the header row columns 2-3 are getting reverted to Calibri 11pt for some reason. All other cells in the entire worksheet (including COL1 header) remain as Arial.
In version 6.2.2, they continue as Arial as expected:
Starting in version 6.2.3, the lose their Arial-ness:
This seems to be the same issue as #1096, but when I try 6.2.11 (the supposed fix) and even the latest version (7.0.9) the issue is still present.
Thanks for reporting this. I will have a look and get back to you.
Yes, this is a bug. I will provide a fix shortly.
Fixed in 7.0.10