当阅读excel表格时,BiffException

时间:2021-07-21 21:49:55

I have a code to read from an excel sheet which is in old format(97-2003). I made some changes to data and ended up a 2007 format excel sheet. When I used this xlsx sheet instead of xls sheet, I am getting this:

我有一个从旧格式(97-2003)的excel表中读取的代码。我对数据做了一些修改,最终得到了2007格式的excel表格。当我使用xlsx表格而不是xls表格时,我得到的是:

jxl.read.biff.BiffException: Unable to recognize OLE stream
    at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
    at jxl.read.biff.File.<init>(File.java:127)
    at jxl.Workbook.getWorkbook(Workbook.java:268)
    at readexcel.ReadExcel.readContent(ReadExcel.java:50)
    at readexcel.ReadExcel.init(ReadExcel.java:25)
    at readexcel.ReadExcel.main(ReadExcel.java:183)

4 个解决方案

#1


17  

The xls format (< Excel 2007) is comprised of binary BIFF data in an OLE container. The xlsx format (>= Excel 2007) is comprised of XML files in a zip container.

xls格式(< Excel 2007)由OLE容器中的二进制BIFF数据组成。xlsx格式(>= Excel 2007)由zip容器中的XML文件组成。

The Java Excel API only deals with the first format so it throws an exception when it doesn't encounter an OLE container.

Java Excel API只处理第一种格式,因此在不遇到OLE容器时抛出异常。

You will need to restrict your input to xls files only or find another tool that handles both formats.

您将需要仅将输入限制为xls文件,或者找到另一个处理这两种格式的工具。

#2


4  

"save as" your workbook as "Excel 97-2003 workbook" (option comes in Microsoft Excel 2007) it saves your file in OLE container.

“保存为”您的工作簿作为“Excel 97-2003工作簿”(选项在Microsoft Excel 2007中)它将您的文件保存在OLE容器中。

#3


3  

I just have had the same trouble. Project was Maven based and side effect of following directive was to filter XLS file.

我只是遇到了同样的麻烦。项目是基于Maven的,后续指令的副作用是过滤XLS文件。

<resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
</resources>

Clean workaround solution was to define sub folder "config" and allow filtering on this specific folder, while including but not filtering on other sub-folders.

干净的解决方案是定义子文件夹“config”并允许对该特定文件夹进行过滤,同时包括但不过滤其他子文件夹。

#4


0  

I was facing same issue in Eclipse/Selenium and tried to "Save As" 97-2000 (.xls) and it solved my problem.

我在Eclipse/Selenium中遇到了相同的问题,我尝试“保存为”97-2000 (.xls),它解决了我的问题。

#1


17  

The xls format (< Excel 2007) is comprised of binary BIFF data in an OLE container. The xlsx format (>= Excel 2007) is comprised of XML files in a zip container.

xls格式(< Excel 2007)由OLE容器中的二进制BIFF数据组成。xlsx格式(>= Excel 2007)由zip容器中的XML文件组成。

The Java Excel API only deals with the first format so it throws an exception when it doesn't encounter an OLE container.

Java Excel API只处理第一种格式,因此在不遇到OLE容器时抛出异常。

You will need to restrict your input to xls files only or find another tool that handles both formats.

您将需要仅将输入限制为xls文件,或者找到另一个处理这两种格式的工具。

#2


4  

"save as" your workbook as "Excel 97-2003 workbook" (option comes in Microsoft Excel 2007) it saves your file in OLE container.

“保存为”您的工作簿作为“Excel 97-2003工作簿”(选项在Microsoft Excel 2007中)它将您的文件保存在OLE容器中。

#3


3  

I just have had the same trouble. Project was Maven based and side effect of following directive was to filter XLS file.

我只是遇到了同样的麻烦。项目是基于Maven的,后续指令的副作用是过滤XLS文件。

<resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
</resources>

Clean workaround solution was to define sub folder "config" and allow filtering on this specific folder, while including but not filtering on other sub-folders.

干净的解决方案是定义子文件夹“config”并允许对该特定文件夹进行过滤,同时包括但不过滤其他子文件夹。

#4


0  

I was facing same issue in Eclipse/Selenium and tried to "Save As" 97-2000 (.xls) and it solved my problem.

我在Eclipse/Selenium中遇到了相同的问题,我尝试“保存为”97-2000 (.xls),它解决了我的问题。