I would like to convert the value in to 2 decimal places. I am using EPPlus if the value is 66.6666667 and I would like to show it as 66.66% I tried the following code but its not working.
foreach (var dc in dateColumns)
{
sheet.Cells[2, dc, rowCount + 1, dc].Style.Numberformat.Format = "###,##%";
}
Please help.
I found it!
I tried
foreach (var dc in dateColumns)
{
sheet.Cells[2, dc, rowCount + 1, dc].Style.Numberformat.Format ="#0\\.00%";
}
The correct formula is as follows:
foreach (var dc in dateColumns)
{
sheet.Cells[2, dc, rowCount + 1, dc].Style.Numberformat.Format ="#0.00%";
}
The Double slash in "#0\\.00%" leads to very unusual numbers when you try to expand the decimal places later
As far as I checked format you set via epp is just a common Excel cell format.
In my case this was really helpful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With