In this article, you will see how you can download Apache POI 5 and install Apache POI in Eclipse IDE. You will also see how to add Apache POI maven dependency into the pom.xml file to build a Maven application.
Apache POI (Poor Obfuscation Implementation) is an open-source Java API library for manipulating the various Microsoft files format such as Excel, PowerPoint, and Word in Java. This article shows you the complete environment set up for the Apache POI-5.1.0 to build an application for manipulating the Microsoft Excel file (XLS and XLSX) format.
Table of Contents
Supported Java Version for Apache POI
- Apache POI 4.0 and later require JDK version 1.8 or later.
- Apache POI 3.11 and later 3.x versions require JDK version 1.6 or later.
- Apache POI 3.5 to 3.10 required the JDK version 1.5 or later.
- Apache POI versions prior to 3.5 required JDK 1.4+.
In this article, we are going to use the Apache poi-5.1.0 version so it required JDK 1.8+
How to Install Apache POI in Eclipse?
There are two ways for installing Apache POI in Eclipse IDE, based on your project type:
- Maven Project
- Stand-alone Java Project
1. Apache poi Maven Project
If you are going to create a maven project for poi, then you have to add the following poi maven dependency in the pom.xml file of your project. Please note here, that poi-5.1.0 is the core module of the Apache poi that will work only for the XLS file. If you want to work with XLSX as well then you have to add both (poi-5.1.0 and poi-ooxml-5.1.0) modules.
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.1.0</version>
</dependency>
2. Apache poi standalone Java Project
If you are going to create a standalone Java project for poi then you have to add the following jar files into the java classpath/build path:
- poi-5.1.0.jar
- poi-ooxml-5.1.0.jar
- poi-ooxml-lite-5.1.0.jar
- xml-apis-1.4.01.jar
- xmlbeans-5.0.2.jar
- curvesapi-1.06.jar
- SparseBitSet-1.2.jar
- commons-io-2.11.0.jar
- commons-codec-1.15.jar
- commons-collections4-4.4.jar
- commons-compress-1.21.jar
- commons-math3-3.6.1.jar
- log4j-api-2.14.1.jar
How to download Apache POI jars?
You can easily download all the above jars for Apache poi 5.1.0 in one place: Download Apache POI Jars
Steps to add poi jar files into the java build path
In Eclipse, right-click on your Project > Properties > select Java Build Path > Libraries Tab > Add External JARs… then choose above mention jars after that click on Apply and Close button as you can see in the below image:
How to create an Apache POI maven application?
You are going to see, how to build or create a sample poi maven application in Eclipse IDE and add the poi maven dependency:
Steps to develop poi maven application
Step-1: Create a new maven project by clicking File Menu > New > Maven Project and simply clicking on the Next button as in below image:
Step-2: Select the maven archetype: maven-archetype-quickstart and click on Next as below image:
Step-3: Provide Group Id: com.javacodepoint and Artifact Id: DemoApplication and click on the Finish button as in below image:
Step-4: Now add the below maven dependency into the pom.xml file:
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.1.0</version>
</dependency>
Once you add the above Apache POI maven dependency, you would see the poi jars get added to your project as you can see in the below image:
That’s all, now you are ready with the Apache POI 5.1.0 environment setup in Eclipse IDE.
Conclusion
In this article, you have seen download and install Apache POI for manipulating the Microsoft Excel file(XLS and XLSX) format. Here you have noticed we have taken the Apache poi-5.1.0 version to demonstrate it.
If you want to read and write an Excel file, visit another article here: Apache POI – Read and Write Excel files in Java.
Related Articles:
- Apache POI Excel Cell Alignment in Java
- Apache POI Excel Cell Border in Java
- Apache POI – Read and Write Excel files in Java
- How to create password-protected Excel in Java?
- How to write data to an existing Excel file in Java?