Alpha
Alpha

Reputation: 14036

The import org.apache.poi.xssf can not be resolved

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:

    <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.

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

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

Upvotes: 16

Views: 63100

Answers (3)

Pooja
Pooja

Reputation: 21

When using maven, for Apache POI, make sure to add all the latest dependencies related to Apache POI as follows:

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

<dependency>
    <groupId>org.apache.xmlbeans</groupId>
    <artifactId>xmlbeans</artifactId>
    <version>3.1.0</version>
</dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-scratchpad</artifactId>
    <version>4.1.0</version>
</dependency>

Save and run. Errors should be resolved.

Upvotes: 2

yTze
yTze

Reputation: 93

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

  1. Download from "https://poi.apache.org/download.html".
  2. Click the one Binary Distribution -> poi-bin-3.17-20170915.tar.gz
  3. Unzip the file download and look for this "poi-3.17.jar".

Problem solved and errors disappeared.

Hope this could help.

Upvotes: 4

geert3
geert3

Reputation: 7321

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

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

Upvotes: 36

Related Questions