.xls文件时,我有一个的.xlsx文件,我已经改变文件扩展名来的.xls,我试图用Gembox图书馆阅读。问题是,当我试图读取使用GemboxExcel.LoadXls(fileName);
方法我收到以下错误的文件:Gembox错误读取从.xlsx文件
Exception message: Analysis failed: Reading error: file is not a valid OLE2 Compound File. Exception stack trace: System.Exception: Analysis failed: Reading error: file is not a valid OLE2 Compound File. ---> GemBox.CompoundFileException: Reading error: file is not a valid OLE2 Compound File. at GemBox.ReadData.ReadHeader(BinaryReader br, ArrayList& masterAllocationTable) at GemBox.ReadData..ctor(Ole2CompoundFile ole2File, Stream inputStream)
at GemBox.Ole2CompoundFile.Load(Stream stream, Boolean loadOnDemand)
at GemBox.Spreadsheet.ExcelFile.ReadStreamHelper(ExcelFile excelFile, Stream inputStream, Boolean readSummaryStreams, Byte[]& ss, Byte[]& dss, Boolean readMacros, Byte[]& ctls, Byte[]& compObj, Ole2Storage& mStorage, String fileName) at GemBox.Spreadsheet.ExcelFile.LoadXls(String fileName, XlsOptions xlsOptions
的问题是,如果,如果我救从Excel(Microsoft Excel中的文件 - >另存为 - > .xls文件)然后我打开我的程序中的文件并使用GemboxExcel.LoadXls(fileName);
方法,它工作正常。
我在我的机器上安装了Microsoft Office Compatibility Pack,但它不起作用。
有人遇到过这个问题吗?
是的,我发现最终的解决方案。有没有办法让BIFF5文件(旧的.xls文件)工作?当我用这种文件做同样的事情时会引发错误,但它与普通(BIFF8).xls文件一起工作。 –
嗨,不幸的没有。目前GemBox.Spreadsheet仅支持BIFF8二进制文件格式的XLS文件,该文件格式适用于Excel文件97-2003。 我推测您使用的是旧版本的GemBox.Spreadsheet,但请注意Excel 5.0/95二进制文件格式(BIFF5)是在当前最新版本(3.7)中也不受支持。 –
感谢您的领导! –