Ireport and JasperReport Integrated Development Web Report Wizard (2)

xiaoxiao2021-03-06  108

This article is written by JPLATEAU. Copyright belongs to JPLATEAU Author Home http://plateau.sicool.com

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 the "New" button to create a new empty report, considering the introduction of XML file editing, you can display Chinese, please GB2312 on the XML Encoding option (no option yourself manually), as shown below:

When you set the necessary options Click Finish, 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 workspace (such as Title, Pageheader, Detail, PageFooter Summary, etc.), if you enter "Today's weather!". 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, huh

Below I will use the question and answer method to gradually explain the usage of IREPORT. 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 words in the previous document: "A Datasource a Jasper = a print" There is therefore necessary first to introduce how to connect the database, is actually very simple. Enter the DataSource / Connections / DataSources menu or click the shortcut button, the following property page appears:

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 District (such as Title Detail, etc.) Report Groups Setup Group Element Properties Element Properties page Element Browser Displaying the list settings for all elements of the report, but in the report, these variables, the parameters, and fields are written, huh, 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 font, you need to under additional JA R ITextasian.jar, if this JAR package is included in the Ireport download package, this step can be exempted.

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 to automatically inherit, huh, convenient! Ok, let's talk about how to use Chinese fonts other than 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)

Mode = "opaque"

X = "13"

Y = "42"

Width = "239"

HEIGHT = "53"

Forecolor = "# 000000"

Backcolor = "# fffff"

PositionType = "fixrelativeTotoP"

IsprinTrepeatedValues ​​= "true" isremovelinewhenblank = "false"

IsprintInfirstWholeBand = "false"

IsprintwhendetailoverFlows = "false" />

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!

Author: Jplateau Source: http: //plateau.sicool.com total of 4410 readers read this article

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

New Post(0)