Dates not getting imported properly


#1

I am using version 2.8.5.0 of your Excel component. When I upload the attached file, the dates in column B don’t come in correctly. For example cell B2 has 3/21/2005 as the date. When it is read with the following call…


private DateTime GetDateTimeFromExcelCell(Cell cell)
{
DateTime dateTime = Constant.DBNULL_DATE;
if ((cell.Type == CellValueType.IsNumeric) || (cell.Type == CellValueType.IsDateTime))
dateTime = cell.DateTimeValue;
   return dateTime;
}

The date returned by

cell.DateTimeValue
is 10/25/1969.

Can you help me determine what the problem is here?

Thanks,
John



#2

The date returned by cell.DateTimeValue is 10/25/1969.

Have you debugged into your program to see which cell return this value? I checked and found it’s cell A2.

Please change your code to:

private DateTime GetDateTimeFromExcelCell(Cell cell)
{
DateTime dateTime = Constant.DBNULL_DATE;
if (cell.Type == CellValueType.IsDateTime)
dateTime = cell.DateTimeValue;

 return dateTime;
}

And you can also try the latest hotfix at http://www.aspose.com/Products/Aspose.Excel/Downloads.html