Dll version we are using is 2.1.2.0
How can we solve this issue any idea?
Check the attachment to get better idea.
code we used :
public DataTable getDataTableOfExcel(Stream stream, string filename, bool IsFirstRowHasHeader)
{
try
{
IExcelDataReader excelReader = null;
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Extension.ToLower().Equals(".xls"))
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
else
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
excelReader.IsFirstRowAsColumnNames = IsFirstRowHasHeader;
DataSet ds = excelReader.AsDataSet();
DataTable dt = ds.Tables[0].Copy();
return dt;
}
catch (Exception ex)
{
Logger.logError(logforimportrecipients, ex);
throw ex;
}
}
Comments: ** Comment from web user: anwar_s24 **
Thank you for you reply.
I am using the code as you given above(i.e using bool convertOADate option) but still same issue.
Can you check my code once here,
---------------------------------------------
FileStream Stream = new FileStream(Path.Combine("E:\\", "DOB_Test_XLS.xls"), FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = null;
FileInfo fileInfo = new FileInfo("DOB_Test_XLS.xls");
if (fileInfo.Extension.ToLower().Equals(".xls"))
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(Stream, true);
else
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(Stream);
excelReader.IsFirstRowAsColumnNames = false;
DataSet ds = excelReader.AsDataSet();
--------------------------------------------------------
am i doing any mistake here?
And i can't use 2nd way(retrieving the data set using method), because the file may contains minimum of 500k records .This raises performance issue again to convert all values to date time.