I'm using ClosedXML to create a excel spreadsheet. The issue takes place while formatting cells, containg percentages.
The format I came up to is 0.##%
.
It works well when the decimal part is not zero, it shows: 1,15%
; but when it's integral-valued, it leaves the decimal separator visible, while hiding zeroes, for example: 5,%
.
How can I make it hide the decimal separator as well?
Here is a small program, demonstrating the issue:
XLWorkbook wb = new XLWorkbook();
var ws = wb.AddWorksheet("test");
string format = "0.##%";
var cell = ws.Cell(1, 1);
cell.SetValue(5.2M / 100);
cell.Style.NumberFormat.Format = format;
cell = ws.Cell(1, 2);
cell.SetValue(5M / 100);
cell.Style.NumberFormat.Format = format;
wb.SaveAs("test.xlsx");
and the output is