I'm using OleDb to read data from an Excel file. The piece of code that reads the data is the following:
OleDbCommand oleDbCommand = new OleDbCommand(selectCommandText, oleDbConnection);
using (OleDbDataReader dr = oleDbCommand.ExecuteReader())
{
DataTable dt = new DataTable();
dt.Load(dr);
return dt;
}
The problem is that the data readed appears randomly as a string sometimes (for example "16.02.1995") or like a number - timestamp (41187), something like this convert Excel Date Serial Number to Regular Date.
Is there any way to solve this? I would like to read the data always as a format, don't matter if it's a number or a string.
Edit: I found that when I have the Excel file opened the date readed is in number format (date serial number) and when I don't have the file opened the date is in string format. Does somebody know why?
Edit2: The personalized format used in the date cell