views:

755

answers:

1

Hi everyone,

I want to use iReport with my J2EE project (JSP/Servlet) in order to generate automatically any report that I want.

I don't Know how to integrate ireport with my project and with eclipse and how to genarate reports.

Thanks for Help.

+1  A: 

Hi,

We can integrate ireports with j2ee project using jasperreports-3.5.0.jar, commons-digester-1.7.jar, commons-beanutils-1.8.0.jar, commons-collections-3.2.1.jar etc...

There might be some other jar files also.

I can give you very brief code base to generate a PDF report.

Suppose your jasper file name is : "PopulationReport.jasper" and located in "E:\" directory

then the code base looks like:

Assume that jrxmlParams is the Map object which has the Parameters that to be passed to the jrxml and connection is the Database Connection object.

    String strFileName = "E:\PopulationReport.jasper";

    JasperReport objJReport = JasperCompileManager.compileReport(strFileName);

    JasperPrint objJPrint = JasperFillManager.fillReport(objJReport, jrxmlParams, connection);

    ByteArrayOutputStream objBAOutputStream = new ByteArrayOutputStream();

    JasperExportManager.exportReportToPdfStream(objJPrint, objBAOutputStream);

And we can write this objBAOutputStream object to the User Interface(JSP or Html) in the form of byte array.

Multiplexer