how to load values of html form into an excel table using java servlet?

how to load values of html form into an excel table using java servlet?

i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should be loaded into an excel table automatically. i have created a dsn for excel table ,but my program is working till generation of receipt and the values are not loading into excel table. would you help me in solving this problem?

View Answers

March 13, 2012 at 4:55 PM

1)Create form.html

<form name="userform" method="post" action="http://localhost:8080/examples/excelFile.jsp">
<tr><td>Enter First Name:</td><td><input type="text" name="firstName"></td></tr>
<tr><td>Enter Last Name:</td><td><input type="text" name="lastName"></td></tr>
<tr><td>Enter User Name:</td><td><input type="text" name="userName"></td></tr>
<tr><td>Enter Address:</td><td><input type="text" name="address"></td></tr>
<tr><td>Enter Email ID:</td><td><input type="text" name="email"></td></tr>
<tr><td>Enter DOB:</td><td><input type="text" name="dob"></td></tr>
<tr><td><input type="submit" value="Export to excel"></td></tr>

2)Create excelFile.jsp

<%@page import="*"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFCell"%>
String value1=request.getParameter("firstName");
String value2=request.getParameter("lastName");
String value3=request.getParameter("userName");
String value4=request.getParameter("address");
String value5=request.getParameter("email");
String value6=request.getParameter("dob");
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("First Name");
rowhead.createCell((short) 1).setCellValue("Last Name");
rowhead.createCell((short) 2).setCellValue("User Name");
rowhead.createCell((short) 3).setCellValue("Address");
rowhead.createCell((short) 4).setCellValue("E-mail Id");
rowhead.createCell((short) 5).setCellValue("Date Of Birth");

HSSFRow row = sheet.createRow((short)1);
FileOutputStream fileOut = new FileOutputStream("c:\\File.xls");
out.println("Data is saved in excel file.");
}catch ( Exception ex ){

Related Tutorials/Questions & Answers:
how to load values of html form into an excel table using java servlet?
how to update values of a html form into an excel table using java servlets?
Hi how to transfer table data from html page to excel sheet by using javascript .
How to export web page to excel using java or jsp or servlets
How to export data from html to excel sheet by using java
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?
Html form using JavaScript to display the table content
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java
how to load pdf on html
How to retrieve array values from html form to jsp?
how to load a table of data from oracle, to a jsp page using hashmap.
dispalying arraylist values in table form
how to read values from excel sheet and compare with database using jsp
how to write a jsp form using html
how to display values from database into table using jsp
how to pass form values from javascript of html page to jsp page
convert html to excel using jsp
excel parsing and print data in the form of table
how to use Excel Templet to write excel file using java.
how to save html form data into .csv file using only jsp.
Printing Values of Resultset to Html Table
how to use Excel Template to write excel file using java
Hiding form values using ajax
how to create an excel file using java
inserting all the values in a html table column
How to design a form using java?
Html form validation using jquery
How to read a rows which have a values in a excel file using apache poi - JSP-Servlet
How to Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database(MySql)?
How to populate an HTML table using jstl code - Spring
HTML form validation using jquery
form based file upload using servlets
problem in linking the html page using servlets
form values in java script - Struts
How to values from xml using java?
example of 1700 bir form using html
How to export data from jsp to excel sheet by using java
How to create simple HTML Form?
how html tags are extracted using java?
how html tags are extracted using java?
How to set background of an excel sheet using POI - Java Magazine