allart Posted July 7, 2010 Share Posted July 7, 2010 i've a problem to open report in xls, this is my code what'is the error? Code: Post Edited by allart at 07/07/2010 10:03Post Edited by allart at 07/07/2010 10:04 Link to comment Share on other sites More sharing options...
allart Posted July 7, 2010 Author Share Posted July 7, 2010 i tryed this too but i wrong something "impossible to open the file"Post Edited by allart at 07/07/2010 09:40Code:ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();//ServletOutputStream servletOutputStream = resp.getOutputStream();JRXlsExporter exporterXLS = new JRXlsExporter();exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT,print);exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, xlsReport);//exporterXLS.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, request.getRealPath("/reports") + "/" +title+".xls");exporterXLS.exportReport();System.out.println("Sixe of byte array:"+xlsReport.size()); bytes = xlsReport.toByteArray(); System.err.println("size: "+bytes.length); resp.setContentType("application/vnd.ms-excel"); resp.setContentLength(bytes.length); resp.getOutputStream().write(bytes); resp.getOutputStream().flush();Post Edited by allart at 07/07/2010 09:43 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