Total Pageviews

2015/11/19

[iReport] How to Set Line Break in Text Field

Problem
Here is my existing report design template:

You can see the report column is dynamic.
The report, with PDF format, is generating as following:

But our customer ask to set line break between 一般政府 and (基金或法人名稱).


How-To
1. Click the textfield

2. Set Markup property to styled
3. Java code should amend as bellows:
1
2
3
4
5
6
7
    Dbm037rVo header = new Dbm037rVo();
    header.setFundName("<style>公共公司<br />(基金或法人名稱)</style>");
    header.setRate1Year(Integer.toString(Integer.valueOf(accountYr) - 2).concat(" 年度(比率)"));
    header.setRate1Year(Integer.toString(Integer.valueOf(accountYr) - 1).concat(" 年度(比率)"));
    header.setRate1Year(accountYr.concat(" 年度(比率)"));
    
    result.add(header);


Reference
[1] http://www.tutorialspoint.com/jasper_reports/jasper_report_styles.htm

No comments: