Hi Jiaguo,
Thanks for your posting and using Aspose.Cells.
Actually you are entering string in cell A1. You should add a number so that it could be formatted in custom number format.
So either you should use this code to enter number with quotes
cell.PutValue(-0.123456);
or you should use second parameter as true so that Aspose.Cells automatically convert your string into number.
cell.PutValue("-0.123456", true);
Please see the following code for your reference.
C#
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells.SetColumnWidth(0, 30);
Cell cell = worksheet.Cells[“A1”];
cell.PutValue("-0.123456", true);
Style stl = cell.GetStyle();
// stl.Number = 2;
stl.Custom = “0.000000”;
// stl.CultureCustom = “0.000000”;
cell.SetStyle(stl);
workbook.Save(“book2.xls”);
Thank you for your help very much ! Your suggestion works great !
Hi Jiaguo,
Thanks for your posting and using Aspose.Cells.
It is good to know that your issue is sorted out with the above code change. Let us know if you encounter any other issue, we will be glad to look into it and help you further.