In this section, we have developed a application to insert data in excel file from database in JSP. We created file SearchUser.jsp, excelData.jsp.
Brief description of the flow of the application:
- Download the POI.jar from Apache Jakarta Project .
- Extract it and then copy poi-2.5.1-final-20040804.jar, poi-contrib-2.5.1-final-20040804.jar and poi-scratchpad-2.5.1-final-20040804.jar into C:\apache-tomcat-5.5.23\common\lib directory .
- Then download source code and paste into C:\apache-tomcat-5.5.23\webapps\excel.
- Start the web server.
- Create folder into C drive with the name 'excel' .
- The excel file will generate into directory C:\excel.
Step 1: Create a web page ("SearchUser.jsp") to SearchForm.
| <html> <head> </head> <body> <br><br><br><br> <form name="searchForm" method="post" action="excelData.jsp"> <table align="center" bgcolor="LIGHTBLUE"> <tr> <td colspan=3 align="center"><b> <span style="font-size:20px;">Create a Excel file with Search Table</span></b></td> </tr> <tr> <td colspan=3> </td> </tr> <tr> <td><b>Search</b></td> <td><input type="text" name="searchtxt" value=""></td> <td><input type="submit" name="Submit" value="Search"></td> </tr> <tr> <td colspan=3> </td> </tr> </table> </form> </body> </html> |
Step 3:Create a webpage "excelData.jsp" to retrieve the data from database and create excel file and insert the data into excel file.
<%@ page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
|
Successful Output of the program:

To click on "Search" Button to Search data
and insert this data into excel file.

The Output is Display on the Browser :
![]()
Download the full web application shows here.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Insert data in Excel File from Database using JSP View All Comments
Post your Comment