Thanks,<br />Mike
SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
Originally posted by vishalraju shah:
If you are populating collection from DB -> coming to servelt -> going to jsp than following can be one of the way you can achieve your requirement.
<%@ page contentType="text/csv"%>
<% response.setHeader("Content-Disposition","inline; attachment; filename=Data.csv");
response.setHeader( "Pragma", "public" );
response.setHeader("Cache-Control", "cache");
response.setHeader("Cache-Control", "must-revalidate");
String separator = System.getProperty("line.separator");
pageContext.setAttribute("separator",separator);
%>
// iterate over your collection and print values seperate by ,(comma).
// This will prompt user to open/save a csv file.
Originally posted by Abhinav Srivastava:
This is one way of Exporting to Excel:
"If users want to save the page as a PDF file or Excel file"
SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
POI and iText are the more elegent solution and I agree to that. However if user here wanted to just save file in excel/pdf format which can be done by above way as per me.
Originally posted by Glenn Graham:
The reason this does work is that the browser now interprets all the tag and data content as Excel info.
SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
|