Using iReport with eclipse to generate reports approperly

天涯浪子 提交于 2019-12-08 11:35:16

问题


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:


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.



来源:https://stackoverflow.com/questions/2812614/using-ireport-with-eclipse-to-generate-reports-approperly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!