Free Support Forum - aspose.com

Cell.PutData not setting the correct Cell format

Hi,



I’m busy evaluating the Aspose.Excel component. I’m trying to get an
integer value to display correctly in Excel. When I run the following
code:



Excel excel = new Excel();

Cells cells = excel.Worksheets[0].Cells;

Cell cell = cells[0, 0];

cell.PutValue(8938489129389);

excel.Save(“c:\temp\aspose.xls”);



And then open the spreadsheed in Excel, the integer value is displayed as:



8.93849E+12

Ideally it should be displayed as:

8938489129389

I notice that the cell number format in Excel is "General". If I change it to "Number" it displays correctly. Surely Cell.PutValue(integer) should set the Cell number format to "Number"? Any idea how to get the value to display correctly the first time?

Thanks,
Luke Venediger.

Fixed:



Excel excel = new Excel();

Cells cells = excel.Worksheets[0].Cells;

Cell cell = cells[0, 0];

cell.Style.Number = 1;

cell.PutValue(8938489129389);

excel.Save(“c:\temp\aspose.xls”);



Thanks to this Wiki entry:

http://www.aspose.com/wiki/default.aspx/Aspose.Excel/NumberFormat.html