Excel.ExcelReaderFactory无法打开某些文件

我得到这个错误试图打开一些xls文件使用Excel.ExcelReaderFactory( http://exceldatareader.codeplex.com/ )

IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream); excelReader.IsFirstRowAsColumnNames = false; DataSet spreadsheetDocument = excelReader.AsDataSet(); 

错误:文件中找不到“工作簿”和“书籍”stream

当您调用CreateBinaryReader时发生错误

有些文件可以100%的工作,但是其他的文件却有这个例外 有没有人有任何想法?

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

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

同样的问题,与水晶报告xls文件相同的例外。 这是因为“Excel数据读取器”将块string定义为“工作簿”和“书”,而将Crystal Report定义为“工作簿”:您必须进行不区分大小写的比较!

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

 if (e.EntryName == EntryName) 

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

对我来说,它解决了。

祝你有美好的一天,马可