Ireport and JasperReport Integrated Development Web Report Wizard (2)

zhaozj2021-02-12  169

Ireport and JasperReport Integrated Development Web Report Wizard (2)

In the previous document, we initially introduced Ireport and JasperReport, basically we have an initial understanding of them. In today's document, I will explain in depth to IREPORT tools.

Then the end of the previous document, if we successfully run Ireport, you can see the following main interface:

Click "New"

The button can create a new empty report, considering the introduction of the generated XML file editing, you can display Chinese, please GB2312 on the XML Encoding option (without the option yourself), as shown below:

When setting the option to play the necessary options, you can get a blank report, as shown below:

Ok, enter a piece of text, very simple, click to create a "static text" button

, Then enter any work area (such as Title, Pageheader, Detail, PageFooter Summary, etc.), if you enter "Today's weather is good!"

In the Properties box page, you can control the input content, such as font, color, size, and other properties, any element (static text, line, box, etc.) have its own property page, generally double-click any Elements can pop up the properties page of this element, the property page is shown below:

Finished, a simplest statement is generated, Ireport is equipped with an operational environment, as shown in the following shortcut:

The button on the left is running a static report (no database environment), the right is to run dynamic reports (if you need to set up a database connection, the database is connected to the connection below)

Then, after the efforts, it is clear that we will run a static report, then click the button on the left, you can see the following PDF, as shown:

Of course, the example is the simplest, huh, hure.

Below I will use the question and answer method to gradually explain the usage of IREPORT

1. How to connect to the database?

2. How to define variables, parameters, and fields?

3. How to define fonts and how to use custom fonts (such as black body, body or comparative artized sub)?

4. How do I perform SQL scripts to query?

5. How to introduce a good statement into the app?

Ok, for the above problem, I give a solution in the following paramount and intersect other function menus in Ireport.

1. How to connect to the database?

The static report is actually very small, I have mentioned a classic word in the previous document:

"A DataSource a jasper = a print" is therefore necessary to first introduce how to connect the database, it is very simple

Go to the DataSource / Connections / DataSources menu or click

The shortcut button appears the following property page:

Perform the necessary database connection properties configuration, then click the Test button to test, if the prompt is successful, save the database connection, you can.

2. How to define variables, parameters, and fields?

The definitions of variables, parameters, and fields are more convenient in Ireport, and some control points can be seen under menu view, as shown below:

Report Properties Settings Report Properties Report Query Settings Query statements, this is described below with the Report Fields Settings Field (Database) Report Variables Settings Variable Report Parameters Settings Parameters Report Fonts Setting Font By the way, the following you also explain the BANDS, pop-up report work The property page (such as Title Detail et al.) Report Groups Settings Group Element Properties Element Properties page Element Browser Displays a list of all elements of the report

The setting is easy, but these variables are quoted in the report, the parameters and fields are written, huh, huh J, let's take a step step by step.

The ways referenced in IREPORT, as follows

Element Name Reference Variable VariablesName $ V {VariableSname} Parameters P {ParameterName} FileDsName $ f {fileDsname}

In fact, these don't indicate that I don't know how to do it, one is described, and they are also very easy to use. Use more

3. How to define fonts and how to use custom fonts (such as black body, body or comparative artized sub)?

Because taken into account the use of Asian fonts, you need to under additional jar package ITextasian.jar, if this JAR package is included in the Ireport download package, this step can be avoided.

Currently in Ireport uses Chinese fonts, it seems to have only one of the Song, if you want to use other fonts (such as black body, body, etc.) need additional methods, here, here, here, how to use common Chinese font "Song" settings Method, in question 2 we see the introduction of the font, click "Report Fonts" to see the following property page:

Ok, if the settings on the upper side have set up the Song body, it will be referenced anywhere in the report. If we have to put our elements in the examples "Today's weather!" Changed to the Song, as follows:

This way as we choose Songti in the Report Font option, then the following properties are automatically inherited, huh, convenient.

Ok, let's talk about how to use Chinese fonts outside the Song, such as: black body, body or other artistic font.

It is also very simple, but it seems that Ireport is not perfect, but also manually modify the XML file to meet the requirements, as shown below, we define the black body:

First, the External TTF Font ... is selected in the PDF Font Name option, according to the common sense, at this time, select the black body TTF file Simhei.ttf, but I don't know why TrueType font is empty, (at the time When I am studying, this step will make me better than enough.), God, what should I do? !

Later I got the corresponding XML file, as follows: (Due to the big file, only we care about us)

Everyone can see the black body pdffontname = "" is empty, so I tried to write the TTF file path of the system black body (c: /winnt/fonts/simhei.tf) to this place, haha, actually succeeded. So I got such a conclusion, so I now use other fonts in the report, first do the property settings you made in the above figure, then manually write the TTF file of the font to pdffontname = "", although it is trouble, but This tricks, huh, huh J

I wrote here today, I haven't mentioned the question, you first see if I can solve it, see you tomorrow, if you have other questions I have not mentioned, I can leave a message to me, huh, huh J J

Welcome to my site http://plateau.sicool.com

JPLATEAU, Friday, December 26, 2003, written in Jingbo

转载请注明原文地址:https://www.9cbs.com/read-6109.html

New Post(0)