Three Java reporting tools
A report is a very complex program. It is very difficult to develop a report manually, and it is almost impossible.
There are many report tools. Here we only list three
① CRYSTAL REPORT.. It was one of the most famous reporting tools for Windows systems at the earliest, and now it has corresponding JAVA Implementation
② Birt.. Business Intelligence and reporting tools: business intelligence and reporting toolsHttp://www.eclipse.org/birt
③ Jasperreport.. A very powerful report tool, struts2 provides an integrated strategy with this report tool
Previously, the jasperreport project relied on SourceForge, And now it actually relied on SourceForge.
It does not have its own independent site before, and now it has, that isHttp://www.jasperforge.org
WhereJasperreport is the earliest,While Birt appears at the latestHowever, Birt has developed rapidly based on the Eclipse open-source organization.
About jasperreport and ireport
JasperreportItself isComplex XML filesAnd the real demand for the project is ever-changing, and it is impossible to fully write Java code to develop it.
In fact, you cannot develop a visualization tool without it. Therefore, jasperreport provides us withVisualized auxiliary tool, that is, ireport
The two are two products under the same open-source project and are always used together. Therefore, when developing a report, you must use its visual designer ireport.
Ireport and jasperreport are independent,Therefore, make sure that the two versions match during download.. In the past, the two versions were named independently, and the version numbers are now consistent.
First start// IReport-2.0.5 // ireport.exeInC: // Documents and Settings // system Logon Name //Create. IreportDirectory
. IreportDirectory will generateConfig. xmlFile. The changes and configurations of ireport are saved in config. xml. You can edit the file directly.
Fields in iReport-2.0.5
Three main force
Fields, variables, ParametersThree important things in ireport
FieldsIt refers to the expression on the report.$ F {field}To obtain the field value of the data table.
Variables and parametersThe same as in Java, it refers to variables and parameters respectively.
Because reports cannot be purely static, they must be dynamically queried based on user input data, so they must receive parameters.
And sometimes you need to define a variable so that it can be referenced elsewhere.
Manually set the fields displayed in detail
Build -- set active connection --Select the configured database connection -- OK
Now the database connection is set to the current report, and then the table field is set to detail.
Data -- REPORT query --The report query window is displayed, which supports multiple languages by default.
Then, enter an SQL statement, such as select * From person. The query result is automatically displayed below.
ThenREPORT queryIf you click OK in the window, all fields in the person table can be used in the current report.
InDetail bandPutText Field buttonIn this case, the report will display$ F {field}Words
You can modify $ f {field} to display the specific field value,For example, the value of the age field in the $ f {age} table is displayed.
Variables in iReport-2.0.5
Define Variables
View -- variables --Click the variables tab.
In variables, the variables with five uppercase letters are displayed. This is the built-in variable of ireport, that is, built-in.
Click againNewCreate your own variables and specify the variable name and type in the pop-up window.
BottomInitial Value expressionThe expression used to set the initial value,The default value is null.
ThenVariable expressionUsed to set the expression of the variable. We can click the small button on the right of the variable.
Then it will pop upExpression editor... windowFor example, we enter new java. util. Date ()
If the input expression is incorrect, a red font is displayed in the middle.. This editing method is similar to a stored procedure.
After the variables are created, expandIreportLeftDocument structure perspectiveMediumVariables Options
Drag the variable you just defined to the report.$ V {variablename}
Built-in Variables
Expand the variables option in document structure,Drag page_number to the report.
When you preview a report, you will find that the page number is displayed on each page. This is the charm of five built-in variables.
In addition, the right side of ireportLibrary perspectiveInPage X of Y variableCan be displayedPage 2 of 7Words
Parameters in iReport-2.0.5
Define parameters
View -- parameters --Click the parameters tab.Also, some parameters are built in ireport.
We canDefault Value expressionFor example, "This is a parameter"
Note thatWhen the default value of the parameter is specified, the string must be enclosed in double quotation marks.
BottomEdit parameter properties...This is used to edit attributes, so we do not need to care about it for the moment.
Note:Use as a prompt single commit,That is, set parameter as a prompt to use, Select it now
After the parameters are defined, expandParameters options in the document structure perspective
Drag the defined parameters to the report and you will see a similar$ P {paramname}
Parameter prompt
After the parameter is defined as prompt,The parameter prompt dialog box appears when you execute a report.
Assume thatJadyer, The preview effect is in$ P {myparam}Is outputJadyer
If no parameter is input in parameter prompt, the position of $ P {myparam} is blank during preview.
When using a report, you need to dynamically decide what to do next based on the information transmitted by the program.
Here, parameter is the parameter passed from outside, and this parameter can be displayed.
It can be roughly considered that parameter prompt is similar to passing parameters in actual development.