IReport FAQ Finishing

Source: Internet
Author: User
Tags print format

1. question:ireport How to implement a Variable field $f{PropertyName} assignment to a null object does not display "null" and appears blank?

Workaround: Select the dynamic cell, right-select the property, and in the pop-up Dialog TextField tab select Blank when null.

think: in the past, we assign values to ireport in the program or report TextField expression with a three-mesh sign to empty, with ireport this function can improve accuracy, but also reduce workload.

2. Questions: ireport if the characters in the dynamic cell $f{propertyname} appear too long, how do I wrap them?

Workaround: Select the dynamic cell, right-select the property, and the stretch with Overflow will be selected in the Pop-up dialog box on the TextField tab.

think: There are a lot of bugs caused by the incomplete display of dynamic text ($F {propertyname}), and the way these bugs are modified is not a fundamental solution, because even if the elongated cell is too large for a dynamic word, the same problem occurs. And the same problem will occur on the spot. This problem is resolved with the feature "Dynamic length exceeds text box length wrap".

3, problem:ireport in a cell because the content is too much to wrap, and the other is not wrapped so its display height certainly inconsistent, how to solve the cell alignment caused by the problem?

Workaround: stretch type= "Relativetobbandhheight" to the properties of all cells in the peer. Select all cells in the same row, right-click to select Properties, and in the pop-up dialog Common tab, set the Stretch type property to "Relativetobbandhheight".

thinking: with this feature, we make the print format appear more neatly, just like a table box for each cell.

4, question:ireport when the text in the cell in the case of a newline spread, how to ensure that the line wrapping can be displayed correctly, and to ensure that the height of the peer after line consistency?

Workaround: Select all the cells of your peers, right-click to select Properties, and in the pop-up Dialog Common tab select Print when detail over.

thinking: Previous page-flipping printing often occurs when the print content is missing, the printing format is not aligned with the bug. This feature resolves appeal issues.

5. question:How does a subreport in ireport make a print position based on whether it has print data in its upper part?

Workaround: Select the neutron report, right-click the property, set the position Type property to float in the Common tab, and place the stretch type property at Relativetotallestobject.

think: when the first page to print the basic information in the upper, sub-report in the lower part, subreport data many need to page, and page after page to print the content of the subreport, this is the most appropriate to take advantage of this feature. If a dynamic text box appears overlapping text because of a newline, you can also select FLOAT to resolve the issue.

6, problem: printing often encounter page turn printing, and each page printed content is inconsistent, ireport how to implement this feature?

Solution: Create multiple frames, each of which can have a different print layout, and control the display of different displays after the page is controlled by controlling the number of pages displayed on a frame. Action: Select frame, right-select Properties, enter control code in the Print when Excepression text box in the Common tab, such as "New Boolean ($V {page_number}.intvalue () >1)" Indicates that the content on this frame is displayed on more than one page.

thinking: This feature gives you more flexibility to meet the needs of different content for page flipping

7, the problem: Some of the previous formatting needs to print variables in the program implementation, in fact, it is best to format in the template (code reuse, removal of coupling), then ireport to provide which formatting rules, how can we use them?

Workaround:each variable cell of ireport has many options for formatting rules (such as), and we can also add our own formatting rules: Select the cell, right-click the property, and in the text On the Field tab, click the Create button to add a formatting rule to the variable (the variable type corresponds to the formatting rule). Each of the formatting rules is not mentioned here.

thinking: The biggest change in printing requirements is the format, we tend to change the format to increase the repetition of code or print items, and the template is customized, formatting on the template to avoid the problem to the maximum extent, for example, the date can be formatted in various forms to display, the currency symbol with that, Whether or not the thousand bits are split can be achieved through this function.

8, problem:ireport in the case of the problem:

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.

IReport FAQ Finishing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.