-1

I have been trying to very simply manipulate cells in a spreadsheet using poi, however every time I try to build my project it gives the same error.

This is the error

This occurs every time at this line here XSSFWorkbook workbook = new XSSFWorkbook();

Here are the libraries downloaded: Libraries that are downloaded

Before the org/apache/logging/log4j/LogManager error was something else at first, I found out that by installing dependencies the error changed slightly but did never go away.

I should probably mention that I am a beginner at java and I do not use Maven. I have spent a lot of time finding solutions to this problem and none of them helped, many mentioned using Maven but that is not really an option for me as I have never used maven before and I think that is something to learn in the near future.

If there is any alternative to poi it would be great too as I really only want to enter numbers in cells without having to read spreadsheets or customize them.

Thanks.

EDIT

The problem is solved thanks to @PJFanning for helping me out. It was indeed a problem with the required dependencies and their required version for each of them.

  • I mentioned, I do not. – Jordy van Dongen Nov 11 '21 at 17:30
  • 2
    Did you try adding all the [listed dependencies of Apache POI?](http://poi.apache.org/components/index.html#components) If not, what happens when you try following the docs and doing that? (Though using a package manager to do that for you is a lot easier longer term...) – Gagravarr Nov 11 '21 at 17:35
  • 1
    The POI docs are a bit out of date. The recent POI 5.1.0 release introduced Log4J v2 as the logging framework - see https://poi.apache.org/components/logging.html - I will try to update the other POI pages (that still refer to older logging frameworks) – PJ Fanning Nov 11 '21 at 19:20
  • @PJFanning Thank you very very much, this helped me pass the line: ```XSSFWorkbook workbook = new XSSFWorkbook();``` However, unfortunately I am now stuck with this new error when I try: ```workbook.write()``` It now gives this error [link to picture](https://i.imgur.com/8TUgYJ5.png), which I do not understand. Also, these are all the dependencies installed right now: [link to picture](https://i.imgur.com/TnnStzo.png) – Jordy van Dongen Nov 11 '21 at 20:34
  • 1
    you need xmlbeans 5.0.2 - you would make everyone's life a lot easier if you learn how to use gradle or another build tool - POI 5.1.0 has an explicit dependency on xmlbeans 5.0.2. – PJ Fanning Nov 11 '21 at 21:00
  • https://github.com/pjfanning/poi-gradle-example is an example project that shows how to run POI code using gradle – PJ Fanning Nov 11 '21 at 21:05
  • 1
    Please [don't upload text as image](https://meta.stackoverflow.com/a/285557/13447). Edit your question to contain all the information in text form - consider to use the editor's formatting options. Also see [ask]. – Olaf Kock Nov 12 '21 at 09:04
  • Does this answer your question? [What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException?](https://stackoverflow.com/questions/1457863/what-causes-and-what-are-the-differences-between-noclassdeffounderror-and-classn) – Danubian Sailor May 27 '22 at 12:23

1 Answers1

0

I recomend to consider maven or gradle.

Last time I made some project where I read a few types of sheets

these are dependencies:

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>5.1.0</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>5.1.0 </version>
</dependency>
<dependency>
    <groupId>com.github.miachm.sods</groupId>
    <artifactId>SODS</artifactId>
    <version>1.4.0</version>
</dependency> 
Marek Borecki
  • 402
  • 1
  • 4
  • 20
  • 5
    Those are pretty old version of Apache POI - [POI 3.17 is over 4 years old now!](http://poi.apache.org/devel/history/changes-3x.html#3.17) - you probably want to use a recent stable version – Gagravarr Nov 11 '21 at 19:15