Jump to content
We've recently updated our Privacy Statement, available here ×

export to XLS in Jasper Reports


dnambiar

Recommended Posts

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

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...