Summary of Jaspersoft iReport 5.6 report design problems

    Take the time to write something today. Regarding the Jaspersoft iReport report, some problems encountered in the design are summarized and classified, which are mainly divided into the following contents:

  • add driver
  • Control handling
  • dataset creation
  • parameter transfer problem

    Most of the problems are often encountered in report design, but not the vast majority. I hope it can help everyone. Let's talk about how to deal with these problems in detail below.

    (1) Add driver

    After the report is designed, it is often necessary to associate the database for testing. Here, take the oracle database as an example, and describe the method of adding the oracle driver. If it already exists, skip it. The oracle driver jar package I use is oracle10g. Of course, if you install oracle, Just copy a copy directly from the installation directory, here is the download link of the ojdbc14.jar package:

    https://pan.baidu.com/s/118i38WJepOdNfw8GKiqGsw , password: 3kk2, after downloading, copy the jar package to the iReport installation or decompression directory: \iReport-5.6.0\ireport\modules\ext.

    (1) Open the Tools-Options in the navigation bar and click on the Classpath configuration item, as follows:

    (2) Click the Add JAR option, add the oracle driver jar package to the Classpath, and confirm, as follows:

    (3) Verify that the oracle driver is installed successfully, click the icon, as follows:

    New - Select Database JDBC connection, as follows:

    Check whether there is an Oracle driver in the JDBC Driver, as follows:

    

    As for adding a connected database, you can configure it yourself.

    (2) Control processing

    (1) In order to ensure the correctness of the content of the report format when previewing or printing PDF, it is best to change the following configuration of the control to this:

    (2) When the Text Field control displays the amount value format, you can adjust this item, as follows:

    (3) The Text Field control uses ternary expressions, as follows:

   (3) Dataset creation

    (1) When using iReport to design a report, there will be a main dataset, let's call it maindataset, as follows, right-click the report name and select Edit Query, you can edit the main query statement of the report:

    If you add a table control, you need to create a sub-dataset, called subdataset. Since the content to be displayed in the table cannot be directly obtained from the main dataset, the data of the table table is dynamically generated and obtained through its corresponding dataset query. How to set Woolen cloth? As follows, right-click the report name and select Add Dataset to add a subdataset:

    Then, name the dataset, click Next, select the connected database (same as the main dataset), and add the query statement required by the table table:

    Then, click Next, the queried fields will be displayed, and they will be added to the right side according to the table needs:

    Finally, click Next, select the sort field, choose by yourself, and complete the creation of the subdataset:

   (4) The problem of passing parameters

    (1) In (3), we have created a subdataset, so how to pass parameters to the dataset? As follows, click on the subdataset, right-click the Parameters option, and select Add Parameter:

    Right-click on the added table component, select Edit table datasource, in the pop-up Dataset Run window, select the Parameter tab, click Add, and add the parameters to be passed:

    Well, the summary is basically based on what you have used and some more pitted problems to prevent yourself from falling into the pit again. If you have encountered other problems and solved them, you can raise them and share them together.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325114677&siteId=291194637