Knife test ireport

Source: Internet
Author: User

Create a report:Menu BarFile --- new document -- reprot name: Set report name -- OK
Compile the report:Menu BarBuild -- compile
Run the report:Menu BarBuild -- execute

Iport port Internationalization
After ireport is started, sometimes its window menu bar displays traditional Chinese characters
This is because it is not well internationalized. We can modify ireport to display it in English or simplified Chinese.
Options -- option -- General -- language --SelectEnglishYou can.
If you want to display Chinese characters, select 3rdChinese (China)You can.

Add static text
ClickStatic text button,Drag a rectangle in the report.
Vertex in the report tableStatci text box,Right-click PropertiesYou can edit static text in detail.

Technology Used to preview the bottom layer of a report
After selecting the preview mode, the corresponding components are used to help us complete the preview.
For exampleConvert PDF Format, It usesItext component,This is a famous tool that uses Java to manipulate PDF files.
For exampleConvert office format, It is usedApache -- poi componentTo convert

Preview a report
Ireport supports multiple previewing methods, that is, it can be converted to multiple formats.
What we can see during the preview is to view the final report.
The default value is jrviewer preview.You can also select another preview method.
After editing a report, you must compile the report and execute the report first.
In additionJava 2D preview is very dazzlingYou can flip the book during preview.

Create a report in The Report Wizard
File -- Report Wizard --Next we will explain them one by one
Query:InConnections/Data sourcesSelect the defined data source
InSQL query input SQL statementFor example, select * From person
Fields Selection: The table fields are automatically displayed in the Left box, and the right box is used to specify the fields displayed in the report.
Group ...:Specify which field to group
Layout:Specify a report template. For example, selectClassicc. xmlClassic Template
Finish:This will pop upCompatibility warning compatibility warning boxClick OK.

Associate with programs by previewing
When running the reportOutput Console. If the following information is displayed:
No external viewer is specified for this type of print. Set it in the options pane.
Indicates that the current preview method is not associated with a specific open program. You need to set it in the options panel.
ClickOptions -- settings... -- external programs -- configure the Open Mode

Create a data source
Data -- connections/data sources -- New -- database JDBC connection
In// IReport-2.0.5 // lib //The jar package is automatically provided for us to connect to the database.
To connect to other databases, and happen to be // iReport-2.0.5 // lib does not provide the corresponding database driver
We can copy the database driver to // iReport-2.0.5 // Lib, and then restart ireport.
At this time, ireport automatically loads the database driver, that is, the jar package used to connect to the database.
Name:Custom Data Source Name, such as mysql_connection
Jdbc url:After entering the database, clickWizard button, Automatically added by item
Server address: Address of the database server, such as localhost
Database:Name of the connected database
User name:Database connection username
Password:Database connection password,Click the test button below to test the connection.

Expressions on the report
Click on Report$ F {age}Right-click Properties -- text field expression
InOpen the expression editor buttonYou can open the expression editor.
InText Field expressionShown inGreen $ f {age}
HereFIt refers to the fields in the database,{}Is the field name, without quotation marks
The expression isGreenIndicates that the information isCorrect, If yesBlueIndicatesThis information is incorrect.

PDF preview Chinese problems
If the report contains Chinese characters, garbled characters or blank spaces may occur during preview in PDF preview.
This is because ireport uses itext to generate PDF files,By default, itext does not support Chinese characters.
So to download itext's itextasian plug-in that supports Asian text from the http://itextpdf.sourceforge.net
Then downloadItextasian. JarCopy to // iReport-2.0.5 // lib and restart ireport
In this case, do not rush to preview and modify some parameters,Static text box with Chinese characters in the report
Right-click Properties -- font -- change the PDF Font Name To The stsong-light font.
ThenChange the bottom PDF encoding to the UniGB-UCS2-H (Chinese Simplified ).
In addition, the pop-up Properties dialog box does not have a confirmation button, and the modification takes effect immediately after the parameter is modified.
In addition:You don't have to buy books to learn about itext. You can simply search for some materials online.
In addition:Published by manning PressItext in actionIs also the only itext book

Customize the display of $ f {field}
By default, $ f {field} displays the values of all fields.You can also decide whether to display a field value.
Right-click $ f {field} and choose Properties -- common -- print when expression.
You can enter a Boolean expression in the box, that is, when true is returned, the field value is printed.
For example, we want the report to print the username value that is not the name of all people in zhangsan.
You can enterNew java. Lang. boolean (! "Zhangsan". Equals ($ f {username }))

How to create a report during real development
When creating a report in real development, the Report Wizard does not use many
This is because the report wizard has some limitations. We can only customize reports according to some of its templates.
In fact, the reports are customized according to the customer's requirements, and the templates usually do not meet the requirements.
Therefore, we usually start from creating a common report:Select File -- New Document

Band interpretation of the main form of a common report
Title band:Only display on the top of the first page of the entire report. Similar to the title of a book
Content in title band is not displayed on all pages except the first page.
Pageheader band:Display on the top of all pages of the entire report. Header similar to word
However, on the first page of the report, its content is displayed below the title band.
Pagefooter band:Display at the bottom of the page. Similar to the word footer
Lastpagefooter band:That is, the footer of the last page. It is only displayed at the last footer.
The last page will no longer display pagefooter band
Detail band:That is, the Report Content segment. The content that needs to be repeated in the detail Band Design Report
The content in the detail band is displayed on each page. Text similar to word
Columnheader band:The header segment of the detail band. Generally, the report header is drawn in this section.
Columnfooter band:Table tail segment for detail band
Summary band:The total segment of the table. The detail band appears after the last page of the entire report.
Used to count the total values of one or more fields in a report.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.