bharathiraja_rp Posted February 12, 2009 Share Posted February 12, 2009 Hi All,We are using jasper report in our web application. When we export the report through code to PDF and if we print the report from the exported PDF document it is fine.But when we export the report to Excel and then print from the exported Excel document the report gets spanned to several pages and printing is incorrect.I am attaching the Excel file and the code am using for exporting.Please help!! Code:public void exportToExcel ( FacesContext facesContext, JasperPrint jasperPrint ) { try { HttpServletResponse response = ( HttpServletResponse ) FacesContext .getCurrentInstance().getExternalContext().getResponse(); response.setHeader( "Content-type", "application/xls" ); response.setHeader( "Content-disposition", "attachment; filename=Report.xls" ); JRXlsExporter xlsExporter = new JRXlsExporter(); xlsExporter.setParameter( JRXlsExporterParameter.JASPER_PRINT, jasperPrint ); xlsExporter.setParameter( JRXlsExporterParameter.OUTPUT_STREAM, response .getOutputStream() ); xlsExporter.exportReport(); } catch ( JRException exception ) { LOGGER.error( "JasperException Found::" + exception.getMessage() ); throwException( facesContext, "error.exporting.report" ); } catch ( IOException exception ) { LOGGER.error( "IOException Found::" + exception.getMessage() ); throwException( facesContext, "error.exporting.report" ); } } 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