dnambiar Posted September 19, 2006 Share Posted September 19, 2006 hi, i am using the following code in the action-class to display a report in XLS : String src="/BusinessEvent.jrxml"; String src1=context.getRealPath(src); String des="/BusinessEvent.xls"; String des1=context.getRealPath(des); System.out.println("Step 4 "+des1); OutputStream outputfile= new FileOutputStream(new File(des1)); Map parameters = new HashMap(); String empNo=new String(session.getAttribute("loginempno").toString()); Long EmpNO=new Long(Long.parseLong(empNo)); String sdate=new String(request.getParameter("fromDate").toString()); parameters.put("empno", EmpNO); String edate=new String(request.getParameter("toDate").toString()); String Location=(String)request.getParameter("location").toString(); String businessname=(String)request.getParameter("businessname").toString(); String BusinessName=businessname.substring(0,businessname.indexOf("_")); OracleDAOLibrary objODAOLib = new OracleDAOLibrary(); objODAOLib.Reportby_BusinessEvent( sdate,edate,Location,BusinessName,EmpNO); JasperDesign jasperDesign = JRXmlLoader.load(src1); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,sds.getConnection()); JRXlsExporter exporterXLS = new JRXlsExporter(); response.setHeader("Content-Disposition", "inline;filename="+des1); response.setContentType("application/vnd.ms-excel;charset=windows-1252"); exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint); exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, outputfile); exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE); exporterXLS.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE, Boolean.TRUE); exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE); exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); exporterXLS.exportReport();--END OF CODE but i get a blank XLS page.Pls. somebody help me out. Link to comment Share on other sites More sharing options...
andysusanto Posted September 20, 2006 Share Posted September 20, 2006 hai, use OUTPUT_FILE_NAME rather than use OUTPUT_STREAM Regards, andy susanto Link to comment Share on other sites More sharing options...
ismail.saleh Posted April 29, 2008 Share Posted April 29, 2008 hello, you can use the JExcelApiExporter. 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