Hello,
I'm trying to set a number to a decimal value through a style setting:
Style totStyleLast = workbook.Styles[workbook.Styles.Add()];
totStyleLast.Font.IsBold = true;
totStyleLast.Font.Size = 9;
Ideally, I'd like to set:
totStyleLast.Number = Decimal;
so that the number displayed in Excel 2010 will be displayed as a decimal value. Nothing I've tried does this. Looking at the class it seems that this can't be done.
Does anyone know how I can do this?
thanks,
Paul
Hi,
Well, it is simple. See the following sample code for your reference:
Sample code:
Workbook wb = new Workbook();
Cells cell = wb.Worksheets[0].Cells;
//or
cell[0, 0].PutValue(123.3456);
Style style = wb.Styles[wb.Styles.Add()];
style.Number = 4;//Set decimal style in the format i.e.: #,##0.00
style.Font.IsBold = true;
style.Font.Size = 9;
cell[0, 0].SetStyle(style);
wb.Save(“e:\test2\Decimalstylefile.xls”);
Also, check the document for your complete reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-display-formats-of-numbers-dates.html
Thanks.