• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

Error reading a date from an excel spreadsheet

Hello experts:
I'm having an issue getting a date colum from excel into another field.

double d = 38449.0;
DateTime dt = DateTime.FromOADate(d);
 dt = Convert.ToDateTime(range.Cells[rCnt, cCnt]);

the last statement generates this error:

Invalid cast exception was unhandled
Unable to cast COM object of type 'System.__ComObject' to interface type 'System.IConvertible'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{805E3B62-B5E9-393D-8941-377D8BF4556B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
1 Solution
Anurag ThakurTechnical ManagerCommented:
something wrong is happening here and see this link and according to msdn it will always throw exception

the following link provides how datetime can be initialized in .Net
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now