kumarasamymk Posted December 28, 2006 Share Posted December 28, 2006 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:33Post edited by: kumarasamymk, at: 2006/12/28 13:34 Link to comment Share on other sites More sharing options...
sumankumar_alla Posted December 28, 2006 Share Posted December 28, 2006 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 Link to comment Share on other sites More sharing options...
anandharaj Posted January 4, 2007 Share Posted January 4, 2007 I also having same problem....Any solution / advise to overcome this kind of problem Link to comment Share on other sites More sharing options...
kumarasamymk Posted January 5, 2007 Author Share Posted January 5, 2007 Shortcut will be ,,export to file system and use iframe and in src u call the excel sheet. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now