hi all,
I am posting this question again. Help me guys n girls...it's urgent.
I need to open the csv file in the browser.
all info is coming in one cell& all the info is comma separated.
my code for this is
JRCsvExporter exporter = new JRCsvExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
ByteArrayOutputStream csvReport = new
ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, csvReport);
exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER , ",");
exporter.exportReport();
System.out.println("Size of byte
array:"+csvReport.size());
bytes = csvReport.toByteArray();
response.setContentType("application/vnd.ms-excel");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream =
response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
If I write the code as follows i.e, generate a csv file on the disk & then
open it explicitly with Ms Excel then it shows it correctly:
File destFile = new File(reportFile.getParent(),
jasperPrint.getName() +
".csv");
JRCsvExporter exporter = new JRCsvExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,
destFile.toString());
exporter.exportReport();
I need to show the CSV in the browser window to the client. Plz tell me how
do I do it.
Regards,
Meenakshi.
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
jasperreports-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions