4

我在尝试使用 Excel.ExcelReaderFactory ( http://exceldatareader.codeplex.com/ )打开一些 xls 文件时遇到此错误

IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);

excelReader.IsFirstRowAsColumnNames = false;
DataSet spreadsheetDocument = excelReader.AsDataSet();

错误:文件中未找到流“工作簿”和“书”

调用 CreateBinaryReader 时发生错误

一些文件 100% 工作,但其他文件给出了这个例外。有没有人有任何想法?

他们网站上的类似问题(http://exceldatareader.codeplex.com/discussions/461766

4

1 回答 1

2

这是来自http://exceldatareader.codeplex.com/discussions/461766#post1113133以为我会在这里发布:

同样的问题,与水晶报告 xls 文件相同的异常。这是因为“Excel 数据阅读器”将块字符串定义为“Workbook”和“Book”,而不是将 Crystal Report 定义为“WORKBOOK”:您必须进行不区分大小写的比较!

打开“Excel\Core\BinaryFormat\XlsRootDirectory.cs”并替换第 75 行

if (e.EntryName == EntryName)

if (string.Equals(e.EntryName, EntryName, StringComparison.CurrentCultureIgnoreCase))

对我来说它解决了。

祝你有美好的一天,马可

于 2013-10-29T04:35:15.953 回答