Read XLSX using Apache POI – Maven Project




Apache POI (Poor Obfuscation Implementation File System) is the Java API for Microsoft Documents such as XLS,XLSX,DOC and PPT as well.
HSSF (Horrible Spreadsheet Format)
Read or write an Excel file format – XLS
XSSF (XML Spreadhsheet Format)
Read or write an Excel file format – XLSX
To download the Apache POI Library access the below link -> https://poi.apache.org/download.html
Download the Binary Distribution

  • Linux : poi-bin-xx.tar.gz
  • Windows : poi-bin-xx.zip

Apache POI
Reading the XLSX in JAVA project
1. Create JAVA Project
2. Add the dependencies of the Apache POI to the Build Path of the project.

Apache POI Referenced Libraries

Java Project – Build Path


3. Create a XLSX file with rows and columns
Apache POI-Xlsx File

Xlsx File


4. Write the logic to read the data from XLSX.


Reading the XLSX in maven project
1. Create MAVEN Project
2. Add the following dependencies in the MAVEN pom.xml
https://mvnrepository.com/artifact/org.apache.poi/poi
https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
Maven Dependency- Apache POI

Maven Dependency- Apache POI


3. Write the logic to read the data from XLSX.

Conclusion:
Reading the XLSX is easy using the Apache POI and Java API.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

Output
Output of the Program

Output of the Program




Leave a Reply

Your email address will not be published. Required fields are marked *