I have an excel file which contains a lot of fields. I use the dataset to store the data fetched from this excel file. In excel sheet I have a date column that is set to the correct format. But when retrieved, the format is changed to a number in the dataset..
I don't know the reason for this issue.
Excel Value: 01/12/2015, changed to 42016 in the dataset.
Any pointers to this issue will be appreciated.
My code is
private static DataSet GetExcelDataAsDataSet(string path)
{
return GetExcelDataReader(path).AsDataSet();
}
private static IExcelDataReader GetExcelDataReader(string path)
{
FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
var data = excelReader.ResultsCount;
DataSet result = excelReader.AsDataSet();
excelReader.IsFirstRowAsColumnNames = true;
return excelReader;
}