EPPlusSoftware / EPPlus

EPPlus-Excel spreadsheets for .NET
https://epplussoftware.com
Other
1.83k stars 279 forks source link

Style.Numberformat.Format on column not working properly in 7.5.0 #1707

Closed CyberBotX closed 5 days ago

CyberBotX commented 6 days ago

EPPlus usage

Personal use

Environment

Windows

Epplus version

7.5.0

Spreadsheet application

LibreOffice Calc

Description

With 7.4.2, setting a ws.Column(col).Style.Numberformat.Format to anything works fine. But since 7.5.0, this no longer works. Newly setting a column's number format results in nothing being done when the resulting file is opened. Setting it on an individual cell works in every case.

Strangely, though, if I had set a column's number format and saved, then set a different column's number format and save, the previous column's number format is applied while the new one's is not. Saving the file multiple times without edits does not work, though, only if an edit is done between saves does it seem to work.

I was using the following code in LINQPad to test with:

using ExcelPackage ep = new(new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "EPPlus Numberformat Test.xlsx")));
var ws = ep.Workbook.Worksheets[0];

ws.Cells[1, "I".ToExcelColumnNumber()].Value = "7.5.0";
ws.Cells[2, "I".ToExcelColumnNumber()].Value = 123.456789;

ws.Column("I".ToExcelColumnNumber()).Style.Numberformat.Format = "0.00%";

await ep.SaveAsync();

(ToExcelColumnNumber is an extension method on string that returns the integer representation of the column number, so "A" becomes 1, "B" becomes 2 and so on.)

Basically, if I run the above and load the file, the value in column I does not have the format. But if I change the column to the next one over and run it again, column J does not have the format but column I does, despite column I being untouched the second time.

JanKallman commented 5 days ago

Yes, this is the same issue as #1699. We will release 7.5.1 today with a fix for this.

JanKallman commented 5 days ago

Fixed in EPPlus 7.5.1