Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities.

A:

JasperReport is a powerful, flexible report generation tool that displays rich page content and converts it to PDF, HTML, or XML format. Written entirely in Java, the library can be used to generate dynamic content in a variety of Java applications, including J2EE, Web applications. JasperReport is open source and a good choice for developers. I don’t want to introduce JasperReport in detail, but if you are interested, you can go to the Internet for more information about JasperReport.

2: download

Website:Community.jaspersoft.com/community-d…

Download the Library Jar package and the template designer Jaspersoft Studio. And install Jaspersoft Studio

Three:

Start using the software once you’ve installed it. This software is very similar to eclipse, which we use on a regular basis.

1. Create a JasperReport project

Name it whatever you want

2. Create a new folder under the project. The name can be different from mine

3. Create a Jasper Report

4. Select a blank A4 and click Next

5. Name and click finsh

Once it’s created, it looks like this

4. Studio’s Outline shows the template structure

Parameters for a report can be filled with data that can be passed in from outside. Fields: A field or field generated by the database or entity class associated with it. Sort Fields: indicates the sorted and filtered Fields. You can create Variables to perform mathematical calculations. Scriptlets: Report templates are essentially a tagging language, so scripting languages can also be used. Title: Only displayed at the top of the first page of the entire report. Only displayed on the first page, other pages are not displayed.

Page Header: Each Page is displayed throughout the report. On the first page, the position appears below the Title Band. The Page Header content is displayed at the top of the Page except the first Page.

Page Footer: Each Page is displayed throughout the report. It is displayed at the bottom of the page. Usually used to display page numbers.

Detail 1: The report contents are displayed on each page.

Column Header: If the Detail prints a table, the Column Header is the Column Header of the Column in the table.

Column Footer: If the Detail is printed as a table, the Column Footer is the Column Footer of the table.

Summary: The Summary section of the table, which appears on the last page of the report, after the Detail 1 Band. It is mainly used to do the total display of statements.

Palete displays the structure

In the space below the top of the Summary, click -> In the Properties Report, there is an Edit Page format that adjusts the page size and other Properties

It can be adjusted to suit your needs

Five: Parameters and templates

1. Create Parameters

2. Parameter name, select the parameter type, create the parameter you need and the type.

3. Parameters are finished, next, get template in the Title area to get the table, remember to get in the Title, beyond the boundaries will have a warning ⚠ the first blue (or lavender, doesn’t matter, anyway, can distinguish out) line, and the second blue line inside, there is a Title English

4. We hold Static Text to the Title area

The following figure

5. You can change the name, font size, color, text box position and so on

6. Set parameter values and drag the Text Field to the Title area, as shown in the figure

7. Double-click Text Field. The dialog box is displayed

8. Select Parameters, then select the one you need, double-click it, and then, in the white area at the top, the words “PrefOrderNo” appear. Where P{refOrderNo}. The word PrefOrderNo. I guess the sign means the parameter, I guess. P is short for Parameters. RefOrderNo in curly braces is the argument.

9. After clicking finsh, the following appears.

10. Do what you want. Format, size and position slowly adjust. And when you’re done, it looks like this

11. The total area above, and the reason why the curly braces inside don’t show the parameters, is because the box is a little narrow, so it doesn’t show. I adjusted the Title, Column Header, Detail 1, Summary position and size according to my own needs.

12. To do this: Click on an area and modify the Height parameter in Properties.

13. Insert pictures

14. I select Custom expression because I need to insert an image from the path (D:\Develop\cupboarderp\postgres\qrcode, this is the path I need to insert the image, I will talk about it in background code later) and then click and select the parameter value. Select the parameter value as above, I select qrCodePic

When it’s done, see the picture

About the report form this piece, I am also small white, oneself grope come over, unavoidably will have the mistake, hope has the big god that knows, give advice.

This article was adapted from CSDN.