Cell.PutValue and Cell.Type

Dear Sir, Madam,

When a cell is empty (cell.Type == IsNull), and I call cell.PutValue(DateTime.Now) I would expect the cell.Type to become IsDateTime, instead the cell.Type becomes numeric. And cell.Value.GetType() returns System.Double. So my DateTime gets actively converted by Aspose.Cells to Double and I don't understand why.

How can I make Aspose.Cells set the cell.Type to IsDateTime?

Immediate window dump:
_cell.Type
IsNull

_cell.PutValue(DateTime.Now)
Expression has been evaluated and has no value

_cell.Type
IsNumeric

_cell.Value.GetType().FullName
"System.Double"

Kind regards,

Jorre Meijrink


This message was posted using Aspose.Live 2 Forum

Hi,

Thank you for considering Aspose.

Please set the display format of cell before or after putting the value in a cell. Following is my sample code regarding your requirement.

Workbook book = new Workbook();
book.Worksheets[0].Cells["A1"].PutValue(DateTime.Now.Date);
book.Worksheets[0].Cells["A1"].Style.Number = 15;
book.Save("c:\\Test.xls");

Please check the following documentation link for further details regarding setting display format of cells.
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-display-formats-of-numbers-dates.html

Thank You & Best Regards,

Thank you.

Style.Number = 14 does the trick for me.