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

Free Support Forum - aspose.com

How to Set DataType of a Cell


Please let me know How to set DataType of a Cell and How to Set Function to Get Totals of a Cell at end of Reports.


Hi,<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” />

Thank you for considering Aspose.

Yes, you can use Cells[index].Style.Number property to set different Cell data formats. Please see the sample code for setting the cell style.

Sample Code:

Workbook wb = new Workbook();


Worksheet sheet = wb.Worksheets[0];

sheet.Cells[7, 1].Style.Number = 15;

sheet.Cells[7, 1].PutValue("10/12/2008");


Please see the following link for supported format styles by Aspose.Cells,


Also you can use Cells.Formula property to set the formula to get the totals.

worksheet.Cells[51].Formula = "=SUM(A1:A50)";

Thank you & Best Regards,

Thanks nausherwan.

Aspose.Cells will automatic adjust to Right and Also if Want to Fix .00 say Rs. 12456.26 then format setting upto 2 decimal.



Well, you can Set Cells.Style.Number = 2 to get your desired result.

Thank you & Best Regards,

Hi Sunil,

Since you are using Aspose.Cells for Java I think, So, refer to the following sample Java code for your need.

Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().addSheet();
Cells cells = worksheet.getCells();
Cell cell = cells.getCell("A1");
//Setting the display format with decimal points for the number
Style style = cell.getStyle();

Thank you.