Search code examples
c#.netclosedxmlformat-string

How to append % symbol in numbers format without multiplying by 100 in ClosedXML


When I set format of a cell as %, and Export it automatically multiply the value with 100 & show the value. So 1.9 becomes 190%, I have use this code to add Symbol of %.

worksheet.Cell(2, 2).Style.NumberFormat.SetFormat("0.00%");

Can anybody help me to solve this?


Solution

  • Finally Got a solution by Own. You can do it in a simple way. If you want to apply it on single cell then do this,

    worksheet.Cell(9, 10).Style.NumberFormat.Format = "#,##0.00\\%"; 
    

    And If you want to apply it on a Range of Cells then do this,

    worksheet.Range(9, 10, 15, 10).Style.NumberFormat.Format = "#,##0.00\\%"; 
    

    you can also find more formats Here, and also you can find the same from Excel as well.