Currency format for 0.01 does not work

Using this code works for all other types of data I’ve used except 0.01. Even sending in 0 results in $0.00 but sending in 0.01 stays as 0.01 in the excel sheet.

 var style = cell.GetStyle();
                style.Number = 8;
                cell.SetStyle(style);

@jojoshua,

Thanks for providing us sample code segment and details.

Well, it works absolutely fine as I have tested using the following sample code. I have also attached the output file for your reference:
e.g
Sample code:

        Workbook workbook = new Workbook();
        Worksheet sheet = workbook.Worksheets[0];
        string val = "0.01";
        sheet.Cells["A1"].PutValue(val.ToString(), true);
        Style style = workbook.CreateStyle();
        style.Number = 8;
        sheet.Cells["A1"].SetStyle(style);

        workbook.Save("e:\\test2\\out1.xlsx");

I suspect your value is string/text and not numeric, so it is not applying the currency formatting properly. Mind you, your data should be of proper data type if you need to apply formatting to the cell.
file1.zip (6.2 KB)

Thanks for the quick response. I noticed from your code, you added the isConverted parameter as true. If I add this parameter to my code, it works. Can you explain why I need to add this and what is it doing? Is there any unintended side-effects of setting this to true?

@jojoshua,

Well, isConverted Boolean parameter (when true) will make sure the so called numeric value (which is actually inserted as string) will be converted to numbers/decimals. The sample code which I provided is just an example for your reference. You may directly input numeric/decimal data into the cell using the following line of code instead (input data without any quotes):
e.g
Sample code:

...........
sheet.Cells["A1"].PutValue(0.01);
........ 

The output file will be same.

Hope, this helps a bit.