org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Offic

org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. 
You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)

缘由是:
HSSFWorkbook:是操做Excel2003之前(包括2003)的版本,扩展名是.xls 
XSSFWorkbook:是操做Excel2007的版本,扩展名是.xlsxapache

 <!--处理2003 excel-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.16</version>
        </dependency>
        <!--处理2007 excel-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.16</version>
        </dependency>
相关文章
相关标签/搜索