Basic introduction to Jasperreport
Introduction to Jasperreport and Ireport
Jasperreport is a report printing tool that supports report printing in multiple formats such as PDF and CSS.
JasperReport is an open source toolkit. Adding the JasperReport package to the project's classpath can start using the JasperReport package. From a Java program, you can operate on the jrxml file by calling the class in the package, and you can complete the compilation, display and output of the report. Wait for work;
The report generation process of Jasperreport is as shown in the figure below.
As shown in the picture above. There are two ways to make report templates:
1) Use the ireport graphic editing tool, iReport is a report editing graphic tool. After editing, output the jrxml file (XML format) and generate a jasper file (ends with .jasper);
2) Directly use java code to compile and generate jasper files (end with .jasper).
The end we need to use the compiled *.jasper file.
Jasperreport supports a variety of data sources, including xml, database, JavaBean and other data sources.
Jasperreport basic class
l net.sf.jasperreports.engine.JasperCompileManager class.
Use several static methods of this class to complete the compilation of the report (see the API documentation for details)
After compilation is completed, there are two ways to handle JasperCompileManager:
1>Return a JasperReport object
2> Generate a .jasper file in the directory where the .jrxml file is located
These two methods are chosen by the programmer themselves. However, I prefer to use .jasper files. After all, the structure of the report is not changed every day, so it is not very cost-effective to recompile the report every time.
l net.sf.jasperreports.engine.JasperFillManager class
The purpose of this class is to fill the report with data. It can be used with the JasperReport object or it can be used. The jasper file is used as a report template.
It also has 2 ways to handle it: