Detailed explanation of ireport and jasperreport development 1. Introduction: jasperreport is a report production tool. Users must write an XML according to the rules it writes, and then obtain the report file that the user wants. The jasperreport library is a flexible and powerful report generation tool. It can generate reports in various forms such as PDF, html or xml, and supports reports in csv, xls, and other formats. This engine is written by Java and supports various forms of applications to generate dynamic reports. The printed report document, jasperreport organizes the report data according to a predefined XML document. These data sources are diverse, including relational databases and java container objects. We will introduce later that users implement data sources and report engines through simple interfaces. Use of First of all, the ireport version we use is: ireport 0.4.1; the jasperreport version is: jasperreports 0.6.5. Currently, ireport supports versions between asperreports 0.6.0 and 0.6.4, including versions 0.6.0 and 0.6.4. itself. 1. The minimum version of the running environment jdk requires 1.2.2 or higher. 2. How jasperreport works (Image source: http://ireport.sourceforge.net/cap3.html#3.1) After the user uses ireport to design the report, he gets an XML file (ends in .jrxml), which is generated after compilation. The jasper file (ends with .jasper), the compiled *.jasper file 3.ireport3.1.1 After decompressing ireport0.4.1, there will be a batch file named: ireport.bat in the directory, double-click Run it (as shown in the figure:). 3.1.2 The main interface after ireport is run is as shown in the figure: 3.1.3 Make a report based on the SQL server database (there are many static report production on the Internet, so I will not explain it here). First, select the file menu (as shown in the figure), (Figure 1) Select the new document to create a new report (you can also select the report wizard report wizard to generate the report, but I won’t talk about it for now), or click the icon to create a new report. 3.1.4 The real-write report attribute is true to the report name. Select the paper and size you want to use in the page size area. We select the default parameters here. In many online information introductions, you need to modify the xml encoding in the i18n tab. , changed to gb2312, the default parameter is utf-8, and ireport does not provide this option. We did not modify this option and it is still utf-8. If you think it is necessary, you can manually enter gb2312. Then click OK. Main interface Change to: 3.1.5 Set the data source, click the menu datasource, select connections/datasources and the following picture frame appears. Click new to set the data source. After clicking new, the picture frame pops up and set the connection properties (as shown in the figure:), Select your data source (type of connection/ddatasource), There are javabean, xml, jdbc and other data sources. We choose jdbc data source, the data source name name, and you can enter your favorite name at will. Select the database connection driver in the jdbc driver drop-down list box. We choose to connect to the SQL server class as shown in the figure. Connect to the jdbc URL, and it will automatically fill in for you. Enter the server address in the server address input box. Fill in the database name you want to use in the database input box. Fill in the username and password of the username of the database you log in to, and then click save password on the edge of the password input box to save the password, and then click wizard to update your login information. In the jdbc url, we should now do a connection test for the database to see if the settings are correct. Click the test in the lower right corner. If the test is successful, it will pop up, otherwise the connection error dialog box will pop up (as shown in the picture). At this time, you want to Check whether your settings parameters are correct to have a safe login method with a database. To be continued faq1. Chinese garbled code is generated when generating a report? The Chinese processing of jasperreport requires an Asian language package itextasian.jar, and then go to the lib directory under ireport; then modify the report's pdf font name to change it to stsong-light, and then modify the pdf embedded pdf encoding to change it to unigb-ucs2-h(chinese simplified) , this can solve the Chinese problem of jasperreport (for PDF settings, it may be less for excel, but this setting can also be displayed in Chinese, and it is not a good idea to echo). 2. Noclassdeffoundexception exception was generated when the report was compiled? The exception occurred when the code handled jasperreport because some jar files referencing jasperreport are incomplete. Because I was busy with work, my way of handling is to demo ample/webapp/web- in the jasperreport directory All jar files inf/lib/ are referenced in case of accidents, and there is no time to go into too much delve into them. There will definitely be some unnecessary packages being cited. If you have time, you can take a look and then remove the unnecessary jar. 3. When saving as pdf, unisupportencodingexception occurs? There are inevitably minor errors in the process of report design. This is because the pdf font name should be changed to stsong-light. Download related: ireport download address: http://ireport. sourceforge.netjasperreport download address: http://jasperreports.sourceforge.netitext Asian language pack download address: http://www.lowagie.com/itext
Collect the most practical web page special effects code!