I am reading the Excel sheet from C# interop services cell by cell. Whereas my Excel sheet has Date cells. It generates some double values, I am converting them in date by:
double dbl = Convert.ToDouble(((Excel.Range)worksheet.Cells[iRowindex, colIndex_q17]).Value2);
string strDate3 = DateTime.FromOADate(dbl).ToShortDateString();
drRow[dtSourceEXLData.Columns[constants.VisualDate]] = strDate3;
OK? But some time happening the value of
((Excel.Range)worksheet.Cells[iRowindex,colIndex_q17]).Value2
getting date format. Why is this happening? It throws an exception of "input string not in correct format". Why is it not generating a double value like other cells of same column?