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 in开发者_如何学编程tegrate ireport with my project and with eclipse and how to genarate reports.
Thanks for Help.
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.
精彩评论