I have a JSP page where I have some data in some tables. I want all the tables in the JSP to be exported to a excel file on click of a link on that page. Im currently using the following code to achieve that:
<a href="Result.jsp?exportToExcel=YES">Export to Excel</a>
String exportToExcel = request.getParameter("exportToExcel");
if (exportToExcel != null
&& exportToExcel.toString().equalsIgnoreCase("YES")) {
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename="
+ "report.xls");
}
}
The problem im facing is, this code exports all the data on the JSP(including geaders, footers etc) to the .xls file. But I do not want that to happen. I am interested only to get the tables in the JSP into the .xls file. Any ideas on how can i achieve that?