JasperReport Road

xiaoxiao2021-03-06  96

1 Let's take a look

Three articles on http://plateau.sicool.com/main.html

Ireport and JasperReport integrated development reports (1) (2) (3)

After reading the understanding, run, ok, you have started

2 Go to find a title.1.0.pdf

After reading it, you will learn about the basic processes and principles generated by JasperReport, and there are many answers.

Just exposed to this report tool

3 Experience on the forum

There are a lot of experience and problems of JasperReport and Ireport in Java Research Forum.

Everyone may wish to overwhelmed the post on the forum, many questions you have to ask can find the answer.

There are still a lot of valuable experience

Of course, the most authenticity of the forum is still

Https://sourceforge.net/projects/ireport/

Https://sourceforge.net/projects/jasperreports/

Everyone can go to SourceForge.net to see, provide search on the forum, and you can turn it into a lot of things.

Practice your English

4 Learning JasperReport's Samples

Decompression JasperReports-0.5.0-Project.zip Directory JasperReports / Demo / Samples

Examples, see these examples is your best in the best way to improve this report tool.

I will put a brief description of each example below.

To run the example under SAMPLE, first you have to install Ant and set a good environment variable.

If the ANT_HOME value is D: / Install / Ant161

Then go to the DOS mode, to a directory of a sample, such as

JasperReports / DEMO / SAMPLES / ALTERDESIGN directory

Run Ant, compile report files

Running Ant View will show reports

5 What is better than the above information?

Just JasperReport's source code, read the source code, JasperReport

It's in your mind, you want to do anything, optimize your code, overwrite, inherit his class, achieve personality

The function of the chemical, even you can refer to his thoughts, sublimate, do your own report

-------------------------------------------------- -------------------------------------------------- ------------

ALTERDESIGN

This example demonstrates how to dynamically control the elements when the report is compiled.

For example, let a certain rectangular discoloration or other

2. ANTCompile

Demonstrate how to make Ant to compile

3. Chart

Demonstrate how to add an image in the report, JasperReport is the way with Scriptlet

Add images to the report, and scriptlet is called also an open source JFreeChart API

Generate graphics, go to JFreeChart, the tool's graphic generation capability is also very strong

4. DataSource

Demonstrate how to use a variety of data sources in the report, you can use BeanArray

Beancollection, you can also use custom data sources, as long as JRDataSource

Two interfaces, this can provide users with very flexibility, the data of the report is not limited to one

The SQL statement, or the stored procedure, the data in the generated report can also be sorted, two

Secondary search, etc. 5. Fonts

Demonstration of various fonts

6. Horizontal

Demonstrate the report of the horizontal column, the demonstration report is divided into three columns, which also used

TextFieldExpression, just like the effect of the IF statement to select the output content

7. HyperLink

Demonstrate links in various styles

8. Images

Demonstrate how to add images and images of images in the report

9. Jasper

Demonstrate the report of the packet column, in the demo, 2 times Group

10. JCHARTS

Demonstrate an API JCHARTS called another open source to add analysis graphics to the report, the principle is the same

On Chart, if JFreeChart can't meet your analysis of graphics, then JCHARTS

Learn to find it, maybe there is

11. Landscape

Demo the landscape report

12. Nopagebreak

Demonstrate, for example, print out the contents of the report, through this demonstration

Understand how to configure parameters

13. NOREPORT

Demonstrate how to generate JASPERPRINT objects directly through the Java program

14. Noxmldesign

Demonstrate how to generate a JAVA program to generate a JaspeSign object to dynamically

Table, according to this example, the user can make a self-defined report, of course, more troublesome.

And it is sure you have to add his API library.

(JasperReport is really powerful, huh, huh)

15. PDFENCRYPT

Demonstrate the PDF output method, you can add code to the PDF file, in fact, the PDF output method

Parameter configuration, there are species that are configurable, go to see the API.

16. PRINTSERVICE

Demonstrate how to print the report

17. Query

Demonstrate how to make the SQL dynamics of the query, such as you can pass through a JSP page

Report SQL WHERE Condition, Order Condition, and Even the entire SQL statement

18. Rotation

Demonstrate the reported report

19. Scriptlet

Demonstrate how to inherit JRDEFAULTScriptlet, and join your own processing statement, this feature

But very powerful, look at these interfaces

BeforeReportinit () insterreportinit () beforepageinit ()

AfterPageinit () BeforeColumninit () aftercolumninit ()

Beforegroupinit (String Groupname)

Aftergroupinit (String Groupname)

Look at these names, you can do those features, such as displaying a quarter, right

The analysis graphic of the column data, of course, you can also add your own method and call in the report.

20. Shapes

Demonstrate the graphics in JasperReport, and configured parameters

Of course, you can also inherit or override the API in JasperReport to generate the graphics you want,

21. Stretch

Demonstrate how to deal with data stretching in the report and bring stretching from the surrounding lines and boxes.

You can learn that although the black-frame form is not a default way ofouting in JasperReport,

But it is not difficult to implement in JasperReport

22. Subreport

Demonstrate the sub-report, tell you that there can be n sub-reports in a report, you can also

Nested sub-report

23. TableofContents

Demonstrate how to generate a directory, complex report

24. Unicode

Demonstrate various character encoders

25. WebApp

Demonstrate how to put the report in a JavaWeb project, you can use JSP servlet

Applet, the author makes a parameter page that can choose the report of the HTML PDF Applet output, interested, I can put the code behind it.

-------------------------------------------------- -------------------------------------------------- ----------------

Here are some supplementary content:

Overview

JasperReport is http://www.sourceforge.net's excellent open source report tool, its powerful features and free features have been accepted and praised, and the latest version is JasperReport0.6.1. The download address is

Https://sourceforge.net/projects/jasperreports/.

Ireport is an IDE development tool for JasperReport, making JasperReport more easily, its latest version is Ireport0.3.2 support to JasperReport0.5.3, and JasperReport is also constantly updated. The download address is https://sourceforge.net/projects/ireport/.

There are a few good materials on the use of these two tools to develop web reports.

 JasperReport and IREPORT configuration and use .pdf (this document can be used to get started with these two tools)

 ThejasperReportsultimateGuide.1.0.pdf (this is a fee-based document, telling the principles of JasperReport generated, if you intend to use JasperReport report tools, you need to see this English information)

 http://www.javaresearch.org/forum/thread.jsp?column=316&thread=14374

(This is a introduction guide on the forum)

First run

The first time is always more painful, using this report tool, the following is the problem that I have summed up in some operations.

My summary is based on Ireport0.3.2 JasperReport0.5.3 (no way, Ireport0.4.0 has not yet come out, 0.3.2 only supports JasperReport0.5.3). As for the combination of the two, I still feel relatively smooth.

After downloading Ireport-0.3.2.zip, you should pay attention to it, pay attention to your JDK Tools.jar to the lib directory of the Ireport after you decompressed, the Chinese PDF report also needs to copy itextasian.jar Under LIB, if you use Oracle's database, then you need to copy class12.jar is also the Oracle's JDBC package to lib, other databases.

It's ready to do it, run Ireport.bat. If it is better, you should see the following screen, explanation

Ireport successfully run.

If the DOS interface passes, there is no above interface, there is no success. Follow the steps below to solve this problem:

Determine the system installation with JDK, and the system environment settings, there is a bin directory in the path, and there is a java_home parameter. The following is the configuration of several parameters for reference:

1 java_home d: /jbuilder9/jdk1.4

2 PATH D: /JBUILDER9/JDK1.4/bin; d: / install / ant161 / bin3 classpath d: / ingotport032 / fonts; E: / project / ESSV6 / WebAPPS / Web-INF / CLASSES

4 Ant_Home D: / Install / Ant161

(About the description of the above parameter settings:

 Report0.3.2 and JasperReport0.5.3 require JDK1.4 or above, so it is important to note that Oracle9 will automatically set the Java environment to Oracle's own JDK1.3.1, which will not be able to run IREPORT.

 Ant_Home and PATH settings are to learn JasperReport in an ANT, these examples under the DEMO / SAMPLES directory after JasperReport, such as entering the DEMO / Samples / Jasper directory in the DOS environment, enter the command ANT VIEW You can see the example report.

 The setting of the D: / Ireport032 / FONTS in ClassPath is to make sure that some external fonts can be selected when font settings in Ireport. For example, let PDF display the black body, then copy the simhei.ttf under Windows to D: / Ireport032 / Fonts In Ireport, the following: pdffontname is the external font, TrueTypefont is simhei.ttf, encoded as Unicode with Horizontal Writing, so you can use the black body.

 E: / project / ESSV6 / WebApps / Web-INF / CLASSES, this is setting in ClassPath, is to let some data in the report should be specially processed, and can be used in the project.

After these settings are completed, in the IREPORT directory in the DOS environment, the benefits of running IREPORT.BATs and DOS environments are if Ireport runs fails to see the cause of failure, and then targeted.

If Ireport is running, it is a discipline, slowly understands the familiar process until you can make a decent statement. This process can refer to the above mentioned

http://www.javaresearch.org/forum/thread.jsp?column=316&thread=14374

Frequently asked questions

When you do a statement, you will encounter a lot of questions. The key is that we need to analyze an error prompt. Based on finding a solution, if you put the report to your work, such as run the results prompt java.io.filenotFoundException, then you need Determine your report compiled file in the corresponding directory; for example, NoclassDefounderror, then you have to see which package is not placed under your work. Here are some common problems:

 The intersection of the Jasper report cannot be displayed in HTML and XLS?

A: If you want to display in HTML, between the line and the line, the line and the box cannot have any weight.

So what you said, if you are directly cross-painted by two lines, you can only be displayed, and you need to draw three line segments.

......

The key point is to see the wrong tips, find out the problem solving, depending on the ability of the user's Java programming.

My report FAQ

1.java.io.filenotfoundexception

JasperReport comes with the webapp example, the method for positioning the .jasper report template file is:

FILE ReportFile = New file ("/ report / webappreport.jasper"); this time, if your web server is Tomcat, the file in the WAbApp is placed in the root directory.

Then the actual location of this report is: d: /tomcat41/webapps/root/reports/webappreport.jasper

However, when you use a sub-report, the situation is different, first there is no Application object in the sub-report.

So you can't use the new file (Application.getRealPath ("/ Reports / WebAppreport.jasper") method to locate the sub-report.

JasperReport supports three ways positioning files, see JasperReportutiMateGuide.pdf

Here, if you are using String types to associate sub-reports, and string's value is Subreport.jasper

Then JasperReport will find the file in the D: / Tomcat41 / WebApps / root / web-inf / class content directory.

I know this point can take various ways.

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

New Post(0)