Development Use Steps (IReport 4.1.1)
(Personal summary, if there are questions please leave a message, also know the table control usage of the message to me or email thank you.) email:jiazx0107@163.com)
Directory
1. Development use Step (iReport4.1) ... 2
Introduction to 4.1 jasperreport and ireport ... 2
4.1.1. Jasperreport Introduction ... 3
4.1.2. IReport Introduction ... 3
4.1.2.1. IReport a few important concepts ... 3
4.1.2.2. ireport the establishment of a database connection DataSource. 5
4.2. Create a report (for example, in several different types of reports) ... 7
4.2.1. ireport Basic Report (example: Advance payment fee and deposit statement) ... 7
4.2.2. IReport subreport Subreport (example: Bulk Print Report) ... 13
4.2.3. iReport table Type form (example: Deposit statement) ... 21st
Configuration of ireport in 4.2.4. Dorado7 ... Introduction to 1.1.JasperReport and ireport
There is a detailed introduction to this software on the Internet. Can search the next, further understand. Here is a brief introduction. 4.1.1. jasperreport introduction
L A report is described by a source-code file, which is an XML tag defined by a DTD (JASPERREPORT.DTD, Version 0.6.3. Listed in appendix B). In version 0.5.3, its source file name extension becomes. jrxml; Replaces the generic. xml extension. The source code for the report is compiled into a jasper file (. jasper extension).
L Jasper file is a kind of forecast table, which is strictly like the object that the Java class is sealed. Jasper files are loaded through your application. It is added to the markup of a data source to create a report, and then it can be exported in the format you want (for example, PDF or XLS). 4.1.2. iReport Introduction
L ireport is also a free software in open source organization Sf.net, whose main role is to visually design the report format file used in Jasperreport, because Jasperreport itself does not provide a good visual report design tool, The appearance of IReport just made up for the flaw.
L The latest version of ireport is 4.1.3
L ireport need the Sun Java2 SDK version 1.5 and above in order to be able to compile our report files we need the full installation JDK. 4.1.2.1. ireport several important concepts
dynamic object variables, parameters, fields for a report
L field (Fields): The database content that is extracted from the database and wants to appear in the report. For example, all values for an ID. $F {Filedsname}
L parameter (Parameters): This is the entry that your application needs to provide to the report, for example, if you want to provide a condition value for the WHERE statement when the report is interpreted, you can use the parameter (Parameters). $P {parametername}
L variable (Variables): This is the representation of some logical operations in the report, such as statistical values. $V {Variablesname}
Report Structure
The report is divided vertically into several parts, each part of which we call "band". Each band has its own characteristics, some will print once when the report is generated, some will print many times. The structure of the report is roughly several parts: title, PageHeader, ColumnHeader, Detial, Columnfooter, PageFooter, Summary, GroupHeader, GroupFooter. The following figure:
Title : The title section is only shown in the top section of the first page of the entire report, except for the first page, no matter how many pages in the report will not appear in title band. is the title of the report.
L PageHeader: The contents of the PageHeader section will appear on every page in the entire report, appearing at the top of the page. If this is the first page of the report, the content in PageHeader will appear under Title Band, and in all but the first page, the content in PageHeader will appear at the top of the page, the header. Some common elements of a report, such as page numbers, creation time, creator, and so on, are better placed here.
L columnheader: Justifiably, here is the name of the place column, remember not to column data.
L detial: report content segment, in this band, the content that needs to be repeated in the design report, the content of Detail section appears every page. such as sales record data.
L columnfooter: The statistics computed value of the drop column level or the description of the column.
L pagefooter: Displayed at the bottom of the page, that is, the footer. Place page-level statistics or a description of the page. Establishment of 4.1.2.2 ireport database connection DataSource
L Open ireport software and click on the datasources
L Click New to create a new connection, select DataSource
L fill in the connection name and choose the correct driver and URL, click Test. You can save it after you succeed.
Note: If driver is red, it means there is no such drive. You need to add the appropriate jar package. For example, there is no Oracle driver. To add a jar package step
In the ireport menu bar, "Tools"-"Options"-"classpath"-"Addjar", add ojdbc.jar files.
1.1. Create a report (for example, in several different types of reports)
Use ireport tools for report development. The basic usage and tips of ireport are illustrated with examples.
1.1. 1.1.1. ireport Basic Report (example: Advance payment fee and deposit report)
1. Open ireport. File-à New-à Select Blanka4-àopen This template
2. Name the report and select Save location, click Next
3. Finish (new blank report complete)
4. Start the design.
Right click on the report name, select Editorquery Open the reports query interface to design their own SQL statements (the proposed first write a parameter fixed sql), the SQL design will appear as follows, the right side of the parameters without tube, click OK button to save
5. Back to the main interface, you can see all the fields in the SQL query in the left fields node
6. The design of the form.
Design reports According to requirements, the palette has a variety of different controls (the control does not describe the use method here) you can choose according to your needs, drag the field in the left side of the fields to the desired location, as shown in
L Total.
On the left variables right-click to add a field, set its properties in the property, Variable Class recommends using Java.math.BigDecimal (you can keep decimals), calculation a few different functions, select sum here as needed, select a field to sum in variable Expression, It's OK to drag the Sum field in the variables to the position you want in the form.
L Preview and design of parameters.
Click Preview Preview Effect, if there is no problem, start design parameters, that is, adjust the SQL statement.
Parameters: Add the required parameters to the parameters of the main interface and configure them in the properties. and then save
L ADJUST the SQL statement.
Reopen the ireport Query interface, where you can see your own design parameters on the right, and drag the parameters to replace the previously fixed parameters in the SQL statement. This way, when this report is invoked, it is passed to the report with the same parameter name parameters (how the foreground invokes the report and how the arguments are described in the configuration in ireport later Dorado7).
Click to save, view preview this time you will be prompted to enter parameters, enter the appropriate parameter, report design completed
(Note: This is a simple report making.) Mainly shows the basic functions of ireport, the steps are relatively detailed, the following report mainly shows some skills, repeat the steps no longer screenshots
1.1.1. ireport Subreport Subreport (example: Bulk print report)
1. First you design a subreport (the part that you need to display in the main table), and you have the same parameter settings, set
Count steps as above. Take the batch printing as an example, select a building, the different customer information detected in the building as parameters to the child table, bulk printing customer payment information. child table design as shown:
2. The design of the primary table.
Add a subreport by adding the subreport control to the detail section of the main table (as appropriate). Drag in, select the local already existing in the table (child tables. Jrxml original file).
3. Click Next to see the parameters of the child table, regardless of the click Next, click Finish, then you can see the following figure. The child table is already associated with the primary table.
Click Next to complete.
4. Parameter passing between the primary table and the child table.
For example, a parameter house2clientid is defined in the child table. Assign the value of the query in the main table to this parameter. Click the added subreport control in the main table to view the properties. Add a parameter house2clientid to the parameters and define which field in the primary table the specified is. Click the Edit icon on the right side of the valueexpression and select the value to determine. This allows the field selected by the primary table to be passed as a parameter to the child table.
Tip 1: How to pass totals from a child table to the primary table (the child table passes to the primary table)
1. Example: Add a parameter sum to the variables in the child table that asks for a field's totals, as shown in the property setting:
2. Add the same parameter sum with the same name in the primary table, and the property is configured as
3. In the main table, select the added subreport control to view the last return Values in the property, edit the calculation type with a different function, and choose nothing here (if the sum sum is selected to automatically calculate the totals in each child table table), That means the total of all the child tables will be added to the sum of all the children. Click OK so that the totals in the child table can be displayed in the primary table
Tip 2: Cleverly use a subreport to design a form
Like: The following form can be seen, there are several different combinations of forms, mainly the number of rows in each form is not fixed, which needs to be made into three forms or table combined. The form can take advantage of the relationship of the master table, for example, the first form is placed in the ColumnHeader position of the form two, and the form two detail put the form two to query the content, the same put form two as a child table in the form three column header position, Then put the table Tansan as a child table in the Main table column header position so step up, you can design such a form. Of course, the position of each report needs to be calculated well.
Parameters: This time, as long as in the subreport in the order of the main to the child table design parameters can be, the following figure is the table Tansan to the form setter.
The following is the design of each master table, the adjustment of their position should be noted.
1.1.1. iReport table type form (example: Deposit statement)
The table-type form written here in ireport is a control with a table, which uses ireport to make the style of the table without using the table control. Take the deposit statement as an example.
1. Design a report style layout, and then select all the columns that add borders, right-click to select padding and Borders to design your own format, such as line width Select 1 to select solid lines. You can, of course, you can design the style of the top and bottom lines of the border as needed. This allows you to design a report of type table.
2. Another design is to use the properties of the control in the Properties panel to set it. Shape as pictured.
3. You can strictly distinguish Table_ch, table_th, TABLE_TD, and table styles (display different colors). Select a different row and modify the property value in the property style (the default property is empty) as shown in Figure two or three below. However, there is a problem with this attribute, such as in the above deposit table in the use of this is the attribute is not prompt as shown in Figure four. What is the reason that is not resolved at the moment, so if the style attribute is not available, it is recommended that you design the table in the first way.
(Note: The above is the use of ireport to do report the use of the transfer of parameters between reports)
configuration of ireport in 1.1.1. Dorado7
2.4.1. How to print a report using ireport in Dorado7
U Install swftools-0.9.1.exe conversion tool on server side
Configure BDF.REPORT.PDFTOSWF variable values in the Bdf.properties of the war package, such as: Bdf.report.pdftoswf=d:/program Files/swftools/pdf2swf.exe
Note When reporting development, add a Parameter:custom_datasource value that is empty, so that the framework automatically uses the default data source.
U Jasper file through the report template maintenance interface to add, (for this project, due to the maintenance of the interface problem, add the save also through the Sqldeveloper directly in the database set bdf_reports its datasource_name=wy)
You open the report in the business interface with the following code:
The packages of the view is set to: Jasperreports,swfviewer
JS Report calling Code:
var BDF = new. JasperReports ();
Report.showreport ("Checkin", {p1: "value1", P2: "value2"});
The first parameter corresponds to the name of the report added to the report template.
The second parameter JSON object is a parameter definition that requires incoming reports;
2.4.2. ireport preview problem in Dorado7
Chinese characters cannot be displayed when previewing. Installing Xpdf-chinese-simplified Language Packs
Steps:
2.1. Configure BDF.REPORT.PDFTOSWF variable values in the Bdf.properties of the war package, such as:
Bdf.report.xpdfpath=d:/programfiles/xpdf-chinese-simplifie
2.2. Select the text box in which the Chinese character may appear, and set the following
FontName: Song Body
Pdffont Name:stsong-light;
Pdfencoding=unigb-ucs2-h
pdfembedded: Tick selection (optional)
2.4.3. Dorado7 in grid Export report
Export the DataGrid in the Dorado7 and the data from the AutoForm control into a report (which supports PDF and Excel two formats) while leveraging the SWF report browser of the BDF report module to browse through the generated report files online for users to browse and download.
U also first install Swftool tool
The packages of the U view is set to: Jasperreports,swfviewer
You are called on the business interface through the following code.
var BDF = new. A ();
Report.showgridreportdialog (This, "Gridfeebill", Null,true,
True,true);
· First parameter: Represents the current View object;
· Second parameter: The ID of the DataGrid that represents the report to export;
· Third parameter: Export the initialization parameters of the report;
· Fourth parameter: Whether the online preview button is displayed;
· The fifth parameter: whether to show the direct export PDF button;
· The sixth parameter: whether to show the direct export Excel button;
After you execute JS, you can design the style and title of the report according to your needs.
(For reports on grid and form in Dorado7, there are detailed descriptions in BSDN.)
http://wiki.bsdn.org/pages/viewpage.action?pageId=3964933)
email:jiazx0107@163.com