Thursday, June 9, 2022

Read Excel file (xlsx) using Apache POI in Liferay 7/DXP

Share it Please

 

Today we will see how we can read excel file(.xlsx) using Apache POI .The main problem in this is POI dependencies .POI create problem with OSGI .So we add dependencies in gradle and include resources in bnd.Here i am using Liferay 7.3.

So lets start this step by step :-


Step 1:- Create a simple MVC Portlet

Create a simple Liferay module Project and create a simple form in jsp

view.jsp


Step 2:- Create Action Method in Portlet

Create a method uploadFile in your controller . So now your controller become :-

ReadExcelPortlet.java

Explanation:-

Here we are using apache poi classes so we need to add dependencies for the same.


Step 3:- Add Dependencies 

Open build.gradle and paste this:-

build.gradle


Now open bnd.bnd and paste this:-

bnd.bnd


Step 4:- Check Output 

Now deploy your project and check output:- 

The Excel file we used :-




Upload Excel file and click submit and check the console




Note :  You can download the source code from here


 Project Structure



Related Post:-


No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!