Export data to Excel Sheet in STRUTS 1.3
hi.
how can i export content present on the jsp to excel sheet on button click.....
and challenging part is i have to merge few rows and columns for a particular field(Value)......
Can any one please provide me with an example......
i have gone through POI API but could not get much help.....
View Answers
April 20, 2011 at 4:49 PM
1)form.jsp:
<html>
<form method="post" action="excelFile.jsp">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contact"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
2)excelFile.jsp:
<%@page import=" java.io.*"%>
<%@page import=" org.apache.poi.hssf.usermodel.*"%>
<%
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
String filename="c:/data.xls" ;
HSSFWorkbook hwb=new HSSFWorkbook();
HSSFSheet sheet = hwb.createSheet("new sheet");
HSSFRow rowhead= sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("Name");
rowhead.createCell((short) 1).setCellValue("Address");
rowhead.createCell((short) 2).setCellValue("Contact No");
rowhead.createCell((short) 3).setCellValue("E-mail");
HSSFRow row= sheet.createRow((short)1);
row.createCell((short) 0).setCellValue(name);
row.createCell((short) 1).setCellValue(address);
row.createCell((short) 2).setCellValue(Integer.toString(contact));
row.createCell((short) 3).setCellValue(email);
FileOutputStream fileOut = new FileOutputStream(filename);
hwb.write(fileOut);
fileOut.close();
out.println("Your excel file has been generated!");
} catch( Exception ex ) {
System.out.println(ex);
}
%>
</form>
</html>
For more information, visit the following link:
http://www.roseindia.net/jsp/poi/
April 20, 2011 at 5:59 PM
Thanks for you help........
Can you please tell me how to increase the size of a row in the excel sheet.... and place the data in that row...
June 28, 2012 at 2:30 PM
addMergedRegion() function will do this for you explore this function more
Ads
Related Tutorials/Questions & Answers:
Export data to Excel Sheet in STRUTS 1.3
Export data to
Excel Sheet in
STRUTS 1.3 hi.
how can i
export content present on the jsp to
excel sheet on button click.....
and challenging part is i have to merge few rows and columns for a particular field(Value
Advertisements
export data from database to excel sheet - JDBC
export data from database to
excel sheet I am facing a problem about exporting required
data from database table to ms-
excel sheet.i mean whenever I execute a query then result will be display in MS-
EXCEL sheet.
please give me
Export html data to excel
Export html
data to excel I am trying to
export data from an html page to an
excel sheet.Any advise
Java swing: Export excel sheet data to JTable
Java swing:
Export excel sheet data to JTable
In this tutorial, you will learn how to read
data from
excel file and
export
it to JTable.
In swing... and POI-HSSF api. Here we are using JExcel api to fetch the
data from
excel sheet
how to display data in excel sheet?
how to display
data in
excel sheet? According to the user Id,some... the button and to display the
data in
excel sheet... there will be a button called
excel download,and if we click the button
data
excel sheet reading and using that data - JSP-Servlet
excel sheet reading and using that data i have to do a read a
excel sheet file of a employee record and then i have to use a employee details to send mail to those employees how to do in jsp sir please help me sir..
Thanks
Store data in HTML forms from Excel sheet
Store
data in HTML forms from
Excel sheet I have a
excel file having multiple coloums, and having one Html page having forms corrospoding to
excel coloums.
I want to auto fill up the
excel data into html forms,
Any one please
struts 1.3
struts 1.3 my requirement is i have two drop downs.second drop down... all the
data related to that item in database will come in next drop down menu using
struts 1.3 but without using ajax
struts 1.3
struts 1.3 please provide me a login application using struts1.3 hibernate and mysql
thanks
struts 1.3
struts 1.3 After entering wrong password more than three times,the popup msg display on the screen or the username blocked .please provide its code in
struts jsp
struts 1.3
struts 1.3 After entering wrong password more than three times,the popup msg display on the screen or the username blocked .please provide its code in
struts jsp
update excel sheet using jsp::
update
excel sheet using jsp:: Hi Sir,...
I have a
excel... given
excel sheet and display it into
another
excel sheet using jsp... page to delete the
data in
excel
but it not working..
it shows null point
reading excel sheet in java
reading
excel sheet in java can anyone tell me a proper java code to read
excel sheet using poi
Here is a java code that reads an
excel file using POI api and display the
data on the console.
import java.io.