Hi,
I have tested your scenario/ case using the following sample code and it works absolutely fine and as expected. Please find attached the output file for your reference. You should first refer to my code and run it on your end to get the output file, then you should write your own code accordingly for your needs:
e.g
Sample code:
[C#]
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create range
Range cellRange = worksheet.Cells.CreateRange(“A1:A10”);
for (int i = 0; i < 10; i++)
{
worksheet.Cells[“A” + (i + 1).ToString()].PutValue(123456.24329512 + i);
}
Style styleObject = workbook.CreateStyle();
styleObject.Custom = “#,##0.00000;#,##0.00000”;
styleObject.Font.Name = “Arial”;
styleObject.Font.Size = 8;
StyleFlag flag = new StyleFlag();
flag.NumberFormat = true;
flag.FontName = true;
flag.FontSize = true;
cellRange.ApplyStyle(styleObject, flag);
worksheet.AutoFitColumn(0);
workbook.Save(“e:\test2\outNumbersFormat1.xlsx”);
[VB]
Dim workbook As New Workbook()
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Create range
Dim cellRange As Range = worksheet.Cells.CreateRange(“A1:A10”)
For i As Integer = 0 To 9
worksheet.Cells(“A” & (i + 1).ToString()).PutValue(123456.24329512 + i)
Next i
Dim styleObject As Style = workbook.CreateStyle()
styleObject.Custom = “#,##0.00000;#,##0.00000”
styleObject.Font.Name = “Arial”
styleObject.Font.Size = 8
Dim flag As New StyleFlag()
flag.NumberFormat = True
flag.FontName = True
flag.FontSize = True
cellRange.ApplyStyle(styleObject, flag)
worksheet.AutoFitColumn(0)
workbook.Save(“e:\test2\outNumbersFormat1.xlsx”)
And regarding your other issue “Also for sub-total reports I am getting extra ’ (single quote)…”, please start a new thread with complete details, template files (output file and expected output file (you may create the file with desired results in MS Excel manually)) and sample code, we will check and help you soon there.
Thank you.