Reading a cell with a date

Topics: Developer Forum
Sep 30, 2011 at 4:11 PM

I must be missing something here but I am trying to read a cell with a date and I receive a datetime format error as the value returned from worksheet.cell is a number. Any ideas? Thanks.

var myDate = Convert.ToDateTime(worksheet.Cell(iRow, 3).ToString());

Oct 4, 2011 at 12:50 PM

The answer is to use-

DateTime.FromOADate(Convert.ToDouble(worksheet.Cell(iRow, 1).Value));