We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting the type through 'Style' class to decimal


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?




Well, it is simple. See the following sample code for your reference:

Sample code:

Workbook wb = new Workbook();
Cells cell = wb.Worksheets[0].Cells;
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);

Also, check the document for your complete reference: