
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.....

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:

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...

addMergedRegion() function will do this for you explore this function more
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.