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?

skomisa
  • 16,436
  • 7
  • 61
  • 102
crraeb
  • 15
  • 3
  • 4
    Please post _text_, not _pictures_ of text. See also [_How to use .jar files in NetBeans?_](https://stackoverflow.com/q/1975973/230513) – trashgod Jul 01 '22 at 21:45
  • 1
    Are you using `Maven`, `Gradle`, or `ANT`? Did you create your project using one of the flows from [here](https://openjfx.io/openjfx-docs/)? – SedJ601 Jul 02 '22 at 05:37
  • @skomisa: I take your point; `s/not/as well as/`. It looks like `poi-ooxml-5.2.2.jar` is missing. – trashgod Jul 02 '22 at 12:50
  • 1
    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. – skomisa Jul 02 '22 at 13:04

1 Answers1

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
trashgod
  • 203,806
  • 29
  • 246
  • 1,045