Click here to Skip to main content
15,905,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Exception "Cannot find table 0" is throwing while uploading excel sheet using IExcelDataReader.
Here is the sample code

FileStream stream = File.Open(opFile.FileName, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader;
if (FileExtension == "xlsx")
    excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
else
    excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
excelReader.IsFirstRowAsColumnNames = true;
DataSet dsresult = excelReader.AsDataSet();
Posted
Updated 7-Jan-14 19:58pm
v2

the error is very much clear my friend. this is an empty data set which don't have any table. it may possible that the excel sheet is blank and there is no rows.so it can not read it.
 
Share this answer
 
I replaced Excel.dll Version 2.0.1.0 with Version 2.1.0.0.Now it is working fine.Thanks for your support.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900