Generate/Read an Excel file in Java using Apache POI


In this tutorial, we will find how to generate and read excel files in java using apache poi.

Apache POI is a library which is created to work with Microsoft office formats.

You'd use HSSF if you needed to read or write an Excel file using Java (XLS). You'd use XSSF if you need to read or write an OOXML Excel file using Java (XLSX). The combined SS interface allows you to easily read and write all kinds of Excel files (XLS and XLSX) using Java.

Additionally, there is a specialized SXSSF implementation which allows writing very large Excel (XLSX) files in a memory-optimized way.

In maven we have two separate dependencies for each type. poi artifact id used for .xls files and poi-ooxml used for .xlsx files.

Find this project on Github

https://github.com/javacodenet/excelDemo

pom.xml


ExcelApplication.java


Employee.java


ExcelHelper.java


Output: Generated Excel file


Output: Data read from an Excel file



Comments

Post a Comment

Popular posts from this blog

Generate PDF From XML Or Java Object Using Apache FOP

Generate Random values in Spring boot