Date format convert into numeric value while importing excel using openxml
i am using open xml for impoting excel, all data getting imported easily except date column. the date column converts into numeric value(eg,3278).
public DataSet ImportExcelData(Stream excelStream, string extension, string keyColumn = null)
{
DataSet dsExcelData = null;
IExcelDataReader excelReader = null;
try
{
if (excelStream == null)
{
return dsExcelData;
}
if (extension == ".xls")
{
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(excelStream);
}//...
else if (extension == ".xlsx")
{
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(excelStream);
var excelDataSet = excelReader.AsDataSet(true);
var excelDataSetss = excelReader.GetDateTime(4);
}//...
//3. DataSet - The result of each spreadsheet will be created in the result.Tables
DataSet result = null;
if (string.IsNullOrEmpty(keyColumn))
{
excelReader.IsFirstRowAsColumnNames = true;
result = excelReader.AsDataSet();
dsExcelData = result;
}
else
{
result = excelReader.AsDataSet();
dsExcelData = CopyExcelDataSet(result, keyColumn);
}
}
catch (Exception)
{
throw;
}
finally
{
excelReader = null;
}
return dsExcelData;
}