EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

Font Style Doesn't Stick Sometimes (Starting in 6.2.3)

Open robertmiles3 opened this issue 11 months ago • 3 comments

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: image

Starting in version 6.2.3, the lose their Arial-ness: image

robertmiles3 avatar Feb 29 '24 09:02 robertmiles3

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.

robertmiles3 avatar Feb 29 '24 10:02 robertmiles3

Thanks for reporting this. I will have a look and get back to you.

JanKallman avatar Feb 29 '24 15:02 JanKallman

Yes, this is a bug. I will provide a fix shortly.

JanKallman avatar Mar 01 '24 10:03 JanKallman

Fixed in 7.0.10

JanKallman avatar Mar 12 '24 08:03 JanKallman