导入org.apache.poi.xssf无法解析

时间:2022-10-17 20:24:12

I've created Maven project and in pom.xml, I've mentioned following POI dependency in order to read from and write to excel file:

我已经创建了Maven项目,在pom.xml中,我提到了以下POI依赖项,以便读取和写入excel文件:

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.9</version>
    </dependency>

In test, when I add import org.apache.poi.hssf.usermodel.HSSFWorkbook;, I don't see any error.

在测试中,当我添加import org.apache.poi.hssf.usermodel.HSSFWorkbook;时,我没有看到任何错误。

However when I add import org.apache.poi.xssf.usermodel.XSSFWorkbook;, it shows an error: The import org.apache.poi.xssf can not be resolved

但是当我添加import org.apache.poi.xssf.usermodel.XSSFWorkbook;时,它显示错误:无法解析导入org.apache.poi.xssf

It's throwing error for XSSF but not for HSSF. Can you guide me how to resolve this issue?

它为XSSF抛出了错误,但对HSSF却没有。你能指导我如何解决这个问题吗?

2 个解决方案

#1


9  

for Poi/XSSF you need also dependency to poi-ooxml, like so

对于Poi / XSSF,您还需要依赖poi-ooxml,就像这样

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.9</version>
</dependency>

#2


1  

Look for "poi-3.17.jar"!!!

寻找“poi-3.17.jar”!!!

  1. Download from "https://poi.apache.org/download.html".
  2. 从“https://poi.apache.org/download.html”下载。
  3. Click the one Binary Distribution -> poi-bin-3.17-20170915.tar.gz
  4. 单击一个Binary Distribution - > poi-bin-3.17-20170915.tar.gz
  5. Unzip the file download and look for this "poi-3.17.jar".
  6. 解压缩文件下载并查找“poi-3.17.jar”。

Problem solved and errors disappeared.

问题解决了,错误消失了。

Hope this could help.

希望这可以帮助。

#1


9  

for Poi/XSSF you need also dependency to poi-ooxml, like so

对于Poi / XSSF,您还需要依赖poi-ooxml,就像这样

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.9</version>
</dependency>

#2


1  

Look for "poi-3.17.jar"!!!

寻找“poi-3.17.jar”!!!

  1. Download from "https://poi.apache.org/download.html".
  2. 从“https://poi.apache.org/download.html”下载。
  3. Click the one Binary Distribution -> poi-bin-3.17-20170915.tar.gz
  4. 单击一个Binary Distribution - > poi-bin-3.17-20170915.tar.gz
  5. Unzip the file download and look for this "poi-3.17.jar".
  6. 解压缩文件下载并查找“poi-3.17.jar”。

Problem solved and errors disappeared.

问题解决了,错误消失了。

Hope this could help.

希望这可以帮助。