获取“无法找到表格0”。使用IExcelDataReader上传excel文档时出现异常 [英] Getting "Cannot find table 0." Exception while uploading excel document using IExcelDataReader

查看:869
本文介绍了获取“无法找到表格0”。使用IExcelDataReader上传excel文档时出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用IExcelDataReader上传excel表时,无法找到表0正在抛出。

以下是示例代码



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();

推荐答案

我的朋友错误很清楚。这是一个没有任何表的空数据集。有可能excel表是空白的,没有行。所以它无法读取。
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.


我用版本2.1.0.0替换了Excel.dll版本2.0.1.0。现在它工作正常。感谢您的支持。
I replaced Excel.dll Version 2.0.1.0 with Version 2.1.0.0.Now it is working fine.Thanks for your support.


这篇关于获取“无法找到表格0”。使用IExcelDataReader上传excel文档时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆