I am assinging DateTime object to a cell using cell.PutValue method.
When I open up the excel sheet in the MS Excel, I don’t see date string,
instead I see a big Float number.
This is what happening.
I have date value of “6/30/2005”. I have constructed DateTime object directly from the Oracle data base using OracleDataReader.GetDateTime method. I am putting this value into a cell using PutValue method. There is no error when calling this function.
When I open the excel sheet, I see date value as “38533.4753587963”.
If I change the format of cell to Date, then the real date “6/30/2005” appears.
Why it is happening like this, why Excel is not recognizing this cell value as Date/Time type?
Please check http://www.aspose.com/Wiki/default.aspx/Aspose.Excel/FormatDate.html for reference.
Thanks for you quick reply.
Now I am facing different kind of problem.
I am assiging style to a range of cells.(Range Object). This style
object basically sets the Font type, size, Cell color and text alignment.
To one/more of the cells in the above range(which has style set), DateTime
value is put. I am assigning the style type of these cells to date format, as
specified in the link you gave me. i.e Cell.Style.Number = 14; I am using
this style only for the cell to which I am putting DateTime object.
Now the problem is, when I open the sheet in Excel, all cells which are numbers
in the cell range are displayed as Date. I am wondering what should I do, to just
dispaly the cell of DateTime as Date format. Do I need to create a new style and
assign to these cell??
After using a different style object for the Cell, now it is working.