pbm in xls format export

0
Dear All,
I have a small problem in xls format report generation.
When i'm exporting the report into File System it's working fine, But when i'm displaying directly in the browser it's not working.

My Code is

File reportFile = new File(session.getAttribute("reportPath"«»)+repfname+".jasper"«»);
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
Map parameters = (Map)session.getAttribute("param"«»);

JasperPrint jasperPrint = (JasperPrint) JasperFillManager.fillReport(jasperReport,parameters, new reportData(Sql,QryType));
JRXlsExporter jasperXlsExportMgr = new JRXlsExporter();

byte[] bytes = null;

ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();

jasperXlsExportMgr.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
jasperXlsExportMgr.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
jasperXlsExportMgr.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE, java.lang.Boolean.FALSE);
jasperXlsExportMgr.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, java.lang.Boolean.TRUE);
jasperXlsExportMgr.setParameter(JRExporterParameter.OUTPUT_STREAM, xlsReport);
jasperXlsExportMgr.exportReport();
bytes = xlsReport.toByteArray();
response.setHeader("Content-Disposition", "attachment; filename=printExcel.XLS"«»);
response.setContentType("application/x-msexcel"«»);
response.setHeader("Pragma", "public"«»);
response.setHeader("Cache-Control", "max-age=0"«»);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();

Post edited by: kumarasamymk, at: 2006/12/28 13:33
Post edited by: kumarasamymk, at: 2006/12/28 13:34
kumarasamymk's picture
Joined: Aug 22 2006 - 8:59pm
Last seen: 12 years 10 months ago

3 Answers:

0
hi

i also faced the problem before.
we have to be take care while giving x,y,height and width for the elements.

go through the below link.
i hope it will be helpful.

http://jasperforge.org/sf/wiki/do/viewPage/projects.jasperreports/wiki/FAQ

all the best
sumankumar_alla's picture
Joined: Dec 11 2006 - 6:07pm
Last seen: 12 years 6 months ago
0
I also having same problem....Any solution / advise to overcome this kind of problem
anandharaj's picture
Joined: Oct 18 2006 - 5:02pm
Last seen: 5 years 8 months ago
0
Shortcut will be ,,export to file system and use iframe and in src u call the excel sheet.
kumarasamymk's picture
Joined: Aug 22 2006 - 8:59pm
Last seen: 12 years 10 months ago
Feedback
randomness