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

Free Support Forum - aspose.com


I use the Style.Number property to set the format but how do i change the value of the cell to match the format?

value may be 145.256000022235
format to 145.26

what i really want is the value to be 145.26

There is not an easy way to get the value according to the format. For this specific case, you can try:

Workbook wb = new Workbook();
Cells cells = wb.Worksheets[0].Cells;

cells["B1"].Formula = "=ROUND(A1,2)";




thanks for your quick reply. unfortunately, the cells get populated using a datareader or a datatable and also, i can make no changes to the workbook besides the inserting of data.

any other suggestions?

You can round the number before inserting data into workbook.

For example:

cell.PutValue(Math.Round(123.45600011, 2);

Or you can change the value in this way:

for(int i = 0; i < cells.Count; i ++)


Cell cell = cellsIdea [I];

if(cell.Type == CellValueType.IsNumeric)

cell.PutValue(Math.Round(cell.DoubleValue), 2);


thanks laurence, this works well. :slight_smile:

question: what’s the performance cost of calling the clearcontents method several times throughout the application?

There is some overhead when calling ClearContents method multiple times. I optimized this method in this attached version. Please try it.