I have a c# application where data is read from an MS excel file. The excel cell format is [$-10409]m-d-yyyy h:mm:ss AM/PM
I am using ExcelDataReader from NuGet to read data from the excel file.
var file = new FileInfo(strFilePath);
using (var stream = new FileStream(strFilePath, FileMode.Open))
{
IExcelDataReader reader = null;
if (file.Extension == ".xls")
{
reader = ExcelReaderFactory.CreateBinaryReader(stream);
}
else if (file.Extension == ".xlsx")
{
reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
}
ds = reader.AsDataSet();
dt = ds.Tables[0];
}
When I read data, the value is changed. e.g. 7-1-2016 11:05:00 AM
is converted to 42552.4618055556
.
Is there any way to get the correct value while reading?