Write Excel File in Java using Apache POI

In our previous posts we have seen on How to Create an Excel File and Read an Excel File.

Now lets see how to Write Excel File in Java using Apache POI

Writing a excel file in java using Apache POI is very easy and can be divided into below steps:

1. Create a workbook
2. Create a sheet in workbook
3. Create a row in sheet to write the headers
4. Get Data and then create Row’s and Cell’s to write data.

To make the example readable, I created separate methods like getRowHeaders , getEmployeeDetails and writeIntoCell

Note that we are using a Employee Object to write data into excel. You can modify to use any of your objects.

Employee.java

Output -
Write Excel File in Java using Apache POI

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn