Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use Ireport

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to install and use Ireport", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to install and use Ireport" this article.

First, install ireport

1. Click the installation package, you can always click on the next step, the installation is complete.

two。 After the installation is complete, add ojdbc14.jar in the following installation directory.

3. Add and modify data sources

(1) enter ireport and click the following location to add a data source.

(2) choose the JDBC data connection method. Select the first one and click next.

(3) in the following interface, edit the database you want to connect to. When filling in password, check the save password on the right, so that you don't have to enter the database password every time you need to connect to the database in the future.

* * (Note) * * Select the JDBC connection driver of oracle: Oracle (oracle.jdbc.driver.OracleDriver). If this driver is not available in red, you also need to add a driver.

If you have added the ojdbc14.jar,oracle driver in the installation directory in the previous step or the red is not available, perform the following steps:

Click the tool → option → Classpath

As shown in the figure above, if there is no ojdbc14.jar as shown above, click the Add JAR button and select the ojdbc14.jar under the project libs.

In this way, the driver is not red when you choose Oracle (oracle.jdbc.driver.OracleDriver).

(4) after the database information is added, you can click the Test button to test whether the database is connected successfully. If it appears as shown in the figure below, the test passed. Click the Save button to save so that the data source is added.

(5) Click the location below to add, modify and delete data sources.

II. The use of ireport

Click the location in the figure below to create a new report.

You can choose the template for the report, and the first two are vertical and horizontal blank templates. Select a vertical blank template and click Open this Template. (you can also choose to click Launch Report Wizard, but Launch Report Wizard needs to write sql statements in advance, but Open this Template does not.)

Let's take Open this Template as an example. We select a vertical blank template and click Open this Template. In the figure below, write the name of the report and click next.

Click finish to create a report.

In the report, you need to write a query sql statement to provide variables. Click the location below.

In the figure below, write the query sql statement. You can click Preview data to view the results of the sql statement query. If there is no problem, you can click the OK button to save.

If querying the where condition of sql requires the project system to pass values, you need to right-click to add a new variable in the figure below.

Then in the sql statement writing interface, drag the variable to the where condition of the sql statement to generate a variable of $P {}.

Component panels and properties are often needed when editing blank reports.

(note) these two interfaces do not necessarily show. If it is not displayed, you can open it in the following location.

Static Text can provide a constant, and Text Field can provide a variable whose name must be the field of the query of the sql statement. To use them, just click and drag to where you need it.

Crosstab can provide a crosstab to generate a table with indefinite columns and rows. We put crosstab at the bottom of the report: summary.

In the first step, we need to select a dataset to populate the crosstab. We use the dataset provided in the main report here, and click next to continue.

In the second step, we need to define at least one row group.

As with defining row groups, we need to define at least one column group from here.

Define data data, and when we want to display the data we query and calculate the total of each column, function we choose sum.

As shown in the following figure, Add row group totals is the total of added rows, Add column group totals is the total of added columns, and show grid lines (adding cell border) is the grid line that displays the total.

Click finish, and the crosstab will be done. To see if the report we made is what we want it to look like, we can click the compile button (right), and then click the preview button (left) to view it.

After completing the report, we need to paste the generated .jasper file into the project.

To use reports in a project, you must first import the corresponding jar package.

Then in the jsp interface, write the following code, reference the .jasper file, and pass the required values for the .jasper file.

(note) the name of the file that IreportByDatabaseHelper needs to query database configuration is: jdbc.properties

If you don't have this file, you need to add one.

(note) when using report display in a project, Chinese characters may not be displayed. We need to set the properties where we need to display them. The settings are as follows:

First of all, click on the areas that need to be modified, as shown below:

In the properties on the right, set these three properties as shown in the figure below:

When setting the font of Chinese characters, we should pay attention to the difference between window system and Linux system. The Linux system does not support the "Song style" format.

The above is all the contents of the article "how to install and use Ireport". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report