First ireport the case:
1, parameter if lowercase, reference also lowercase
2, $F {}, generally uppercase
3. When referring to the values queried in the parent report in the subreport, only lowercase is required, that is, only lowercase is required in the parameter of the subreport.
First, iReport the current time of the system
1, select TextField type is Java.util.Date, select TextField expression Class (type) is Java.util.Date
2. Select the time format in the pattern
3. Write Java.util.Calendar.getInstance () in TextField expression. GetTime ()
Second, avoid the empty
Method One, locate blank when null in the property options
Method Two, $F {ABB614}? $F {ABB614}: ""
Three, set the time format
Method One, you can use the inline function to intercept the string to display
1, using substring to intercept (for string type)
$F {AAE036}? (($F {aae036}.tostring ()). substring (0,4) + "year" + ($F {aae036}.tostring ()). substring (4,6) + "month" + ($F {aae036}.tostring ()) . substring (6,8) + "Day"): ""
2. Use the built-in function to fetch (for date type)
"Date" + ($F {ABB017}? String.valueof ($F {abb017}.getyear () +1900) + "year" +string.valueof ($F {abb017}.getmonth () +1) + "month" + $F {abb017}.getdate () : "") + "Day
Method Two, set Exception class is the date type, and then set the time format in the pattern, you can write yourself, such as xxxx year XX month xx days, but note that if the empty $f{abb614}? $F {ABB614}: "", You can only use blank when null this method
Iv. using tags in HTML in ireport
such as:<br>
1. Locate the markup selection in the Properties panel as HTML
2. Join <br> in the place where needed
V. Make the data in a field print out under certain conditions
By setting the field's printwhenexpression, we can limit the value of the field to be printed only under certain conditions, and a Boolean expression in the printwhenexpression, such as: New Java.lang.Boolean ($F {Type}.trim (). Equals ("Mod_cook"))
Vi. nested subreports
1, find the subreport in the panel properties, and then drag into the place you want to put, release the mouse, there will be a new report. After the report is created, there will be a parameter,string type named Subreport_dir, which will have a default path that refers to the path of the subreport. Because subreports tend to have multiple data, it is best to put them in a single detail (for example, if there are multiple data in the query, it will be displayed in detail).
2, if the sub-report needs to pass in the data, then first point the Neutron report, and then in the property bar (not the parameters) to find "parameters", create a new one, for example:
Name is abz050, expression is $f{abz050}, because the value here is the value after the parent report query, so it is not used with parameter, but field.
3, reference the value in the subreport, first define a variable parameter in the subreport, then reference it.
Then why would you find it?
Because: When you create a subreport, you also automatically create a parameter, the name defaults to Subreport_dir, which has a default path (the new incoming path overrides the default path).
At the same time, you can point the neutron report to see his properties, there is a subreport exception value of $p{subreport_dir} + "subreport name. Jasper", so that the system can be found. Of course, the system will automatically configure some other sub-report properties, specifically create a new one to see it.
Seven, automatic line-wrapping
If you do not handle it, some fields are too long to be displayed. Select the field, right-click the property, and on the text field, put the stretch with overflow on the hook.
At the same time, select all the fields in the row, right-click Properties, and choose relative to tallest object in common's stretch type.
Eight, the use of embedded functions
Example: ($F {ABB617}). ToString ()). substring (0,4) + "Year" converts the ABB617 (date type) to a string and then intercepts the year
Using inline functions in ireport just look at the fields and use them directly.
Nine, height according to content automatically become high
1. Select the primary key, find Stretch with overflow in the attribute and select. And put him alone in a detial or something.
2, there is also a property called Stretch type, the default value is no Stretch, can be changed to the relative to Band Height.
The second step I personally think can be done is not done.
Of course, the function of the second step is useful when making the table, for example: The table is 2 columns, then the data on both sides must be different, or the left is static, then if you do not select this property, you will find that the right side of the data will be expanded, but not on the left, this time, we can set the property, And put them in a separate detial or other container so that the left and right sides will be high.
Ten, set a total of several pages, the first few pages
$V {Page_number} indicates the current page, the Text field option evaluation The time selected report is a total of several pages, the now table is the current page. The page number can be set directly in the ireport. "A few pages in the first page"
I wrote it in page footer.
Eleven
ireportWorking with values
§
§1. The result is shown as null:
Processing method:
1). Handle the data before filling it in the list
2). Using conditional expressions to process iReport fields
$F {name}==null? "---": $F {Name}
§2. Working with date formats
Processing method:
1). Handle the data before filling it in the list
2). Set the iReport field
New Java.text.SimpleDateFormat ("Yyyy-mm-dd"). Format ($F {date})//month must be in uppercase M, lowercase for minutes
§3. Data that requires precision
Processing method:
1). Handle the data before filling it in the list
2). Set the iReport field:
New BigDecimal ($F {num}). Setscale (2,BIGDECIMAL.ROUND_HALF_UP)
§4. Using the scientific notation E
Processing method:
1). Handle the data before filling it in the list
DecimalFormat dfs = new DecimalFormat (". 00");//#
Dfs.format (num);
2). Set the iReport field: New BigDecimal (2.2343434E7). Setscale (2,BIGDECIMAL.ROUND_HALF_UP) or:
New DecimalFormat (". xx"). Format (234342232)
Tips for making ireport <Reproduce>