JavaFX netbeans 12.4. Added Poi to library but cannot use the import in the project
Asked Answered
D

1

1

I have downloaded the most recent Apache poi from https://poi.apache.org/download.html and installed the jars into NetBeans by right-clicking libraries and selecting all the jars, and those in lib.

I'm then presented with these errors when trying to import and use poi in my project.

Error for imports

I have had a long look around and cannot find where I am going wrong here. Please could anyone point me in the right direction?

Dimitris answered 1/7, 2022 at 21:4 Comment(4)
Please post text, not pictures of text. See also How to use .jar files in NetBeans?Preempt
Are you using Maven, Gradle, or ANT? Did you create your project using one of the flows from here?Goldfish
@skomisa: I take your point; s/not/as well as/. It looks like poi-ooxml-5.2.2.jar is missing.Preempt
Re "...installed the jars into NetBeans by right-clicking libraries and selecting all the jars...", I know nothing about POI at all, but adding both poi-ooxml-lite-5.2.2.jar and poi-ooxml-full-5.2.2.jar doesn't seem appropriate, and may be problematic. You might need none or one of them, but I'm pretty sure you don't want both. Please list the jar files you added to NetBeans.Hemialgia
P
2

The error message indicates that the package org/apache/poi/xssf/usermodel is missing. The package is in poi-ooxml-5.2.2.jar, which should be added your library, as shown in How to use .jar files in NetBeans?. You can find other missing packages using the jar command, for example:

jar tf poi-bin-5.2.2/poi-ooxml-5.2.2.jar

Because not all of the JARs are needed for every document file format, see also Apache POI—Component Overview: Component Map and Apache POI: FAQ, item 3.

For reference, here's typical set of dependencies:

$ ls -1 dist/lib/
commons-codec-1.15.jar
commons-collections4-4.4.jar
commons-compress-1.21.jar
commons-io-2.11.0.jar
commons-logging-1.2.jar
commons-math3-3.6.1.jar
log4j-api-2.17.2.jar
poi-5.2.2.jar
poi-ooxml-5.2.2.jar
poi-ooxml-lite-5.2.2.jar
xmlbeans-5.0.3.jar
Preempt answered 2/7, 2022 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.