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.
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:
(
ToExcelColumnNumber
is an extension method onstring
that returns the integer representation of the column number, so"A"
becomes1
,"B"
becomes2
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, columnJ
does not have the format but columnI
does, despite columnI
being untouched the second time.