Total Pageviews

Showing posts with label iReport. Show all posts
Showing posts with label iReport. Show all posts

2013/12/04

How to display column footer immediately without any spaces after details band

Problem
This is my report design in iReport:

Here is the Detail property and Column Footer property setting:

But...as I generate pdf, there has unnecessary spaces between Detail band and Column Footer band.

Solution
Step1. Right click --> property

Step2. Check the "Float column footer" property

Then this problem will be solved. There will not have any spaces between Detail band and Column Footer band.








2013/11/22

Why iReport eat my spaces

Requirement
We had a report requirement as bellows:
You can see some items' amount need to do indent. Others don't.

Problem
Here we add 7 single-byte spaces for some items' amount to do indent based on specific conditions.
1:   DecimalFormat df = new DecimalFormat();  
2:      df.setMaximumFractionDigits(2);  
3:      df.setMinimumFractionDigits(2);  
4:      for (Cta612pDto vo : dataList) {  
5:        if (StringUtils.startsWith(vo.getSeqnm(), "(*)") || "9800".equals(vo.getAcc())  
6:            || "9900".equals(vo.getAcc())) {  
7:          vo.setFormattedAmt(df.format(vo.getAmt()));  
8:        } else {  
9:          vo.setFormattedAmt(df.format(vo.getAmt()) + "       ");  
10:        }  
11:        formattedList.add(vo);  
12:      }  

But it does not work:

Root cause
 The iReport seem trim your spaces automatically. Therefore, it does not work for this circumstance.

Solution
We need to use double-byte spaces(全形空白) instead of single-byte spaces(半形空白).
1:   DecimalFormat df = new DecimalFormat();  
2:      df.setMaximumFractionDigits(2);  
3:      df.setMinimumFractionDigits(2);  
4:      for (Cta612pDto vo : dataList) {  
5:        if (StringUtils.startsWith(vo.getSeqnm(), "(*)") || "9800".equals(vo.getAcc())  
6:            || "9900".equals(vo.getAcc())) {  
7:          vo.setFormattedAmt(df.format(vo.getAmt()));  
8:        } else {  
9:          vo.setFormattedAmt(df.format(vo.getAmt()) + "   ");  
10:        }  
11:        formattedList.add(vo);  
12:      }  


2012/09/20

Failed to Apply Thousand Seperator / Text Pattern

Problem
I had set the text pattern to "#,##0", but it is not working.

Here is the setting in iReport


But it does not work as expected.

Solution
The root cause result from the expression class of this text field is java.lang.String. As I change to java.math.BigDecimal. It works now.



2012/04/12

Stop Redeploying in iReport Development

Context
以下是本案的project structure:


所有的jrxml放在jasperreports folder中,當jrxml有異動,處理程序如下:
1. 執行maven build
2.  將jrxml compile成jasper file會搬到nig-web\src\main\webapp\WEB-INF\classes\META-INF\jasperreport
3. 包成ear file
4. deploy到application server

Problem
在用iReport開發的時候,最浪費時間的部份,就是在我們無論做任何的細微的修改,如果要看到修改後的結果,都要將jrxml compile成jasper,然後redeploy到application server,此過程曠日廢時,浪費許多寶貴的開發時間。

Solution
Step1. 打開iReport工具-->工具--選項

Step2. iReport--> Compilation and execution--> unchecked "Use Report Directory to compile"-->將「nig-web\src\main\webapp\WEB-INF\classes\META-INF\jasperreports」貼進 "Compilation directory"-->click 「確定」按鈕

設定完成後,當我們在iReport Designer做任何異動,click "Compile Report" button,iReport會自動將jasper file搬移到指定目錄,application server會自動抓到最新的jasper file,不用再rebuild and redeploy了。





iReport print when expression 應用

Requirement
在報表呈現的內容,每筆資料之間,需要有間隔的虛線如下

Problem
原本iReport designer中的作法,是將line放在detail band中的fields下方,screenshot如下:

但是此舉,在最後一筆資料,也會出現分隔線,此結果不合理。

Solution
step1. 將分隔線放到detail band的fields上方,如此一來,列印順序是line-->data-->line-->date-->line-->data,以此類推

 step2. 由於列印順序是line-->data-->line-->data-->line-->data,為了滿足需求,只要讓第一次出現line的時候,不要讓顯示出來就好。此時,click line,並在attribute視窗中的print when expression輸入條件,當是第一筆的時候,不要印出line,從第二筆資料開始即可。


2012/03/21

iReport : Reprint header


Problem


When I export my report to pdf format, the data split into multiple pages.

The report header should print for each page, but it only print once.

Root Cause


Here has one group options to do reprint

  • Reprint header : If you want to reprint the group header on each page, check this option.

Step by step


1. click group header




2. check Reprint header
 


















3. click save

2012/03/08

iReport : text alignment

Requirement
Utilize JasperReports to print name and adrress on envelope. Name and addess should print from top to down.



Concerning text alignment, iReport has three attributes:

  • textAlignment - Values allowed for the horizontal alignment are: Left, Center, Right and Justified. By default, horizontal alignment is set to Left. 
  • verticalAlignment - Values allowed for the vertical alignment are: Top, Middle and Bottom. By default, vertical alignment is set to Top. 
  • rotation - Values allowed for the text rotation are: None, Left, Right and UpsideDown. By default, text rotation is set to None. 



Examples of combining horizontal alignment, vertical alignment and rotation in a element. 
The resulting paragraph will be horizontally aligned left, vertically aligned top, and the text will flow from top to bottom. 


Running this sample




2012/01/12

iReport 直式/橫式報表

需求
根據User所選擇要輸出橫式或直式的格式,分別輸出符合指定格式的報表

若user選擇列印格式為橫式

就輸出橫式報表

若user選擇列印格式為直式

就輸出直式報表

作法 - 橫式報表
由於iReport建立template後,default式Portrait,此時要手動去修改其page format
1. right click --> Page Format

2. Choose "Landscape" -- > OK

3. Change sucessfully

4. Drag and drop data field to template

作法 - 直式報表
1. Drag and drop data fields into template

2. Click each data field and go to change its property

3. Change "Rotation" property to "Right"

4. Check the result



2012/01/08

How to create barcode in iReport

Here is a simple example to create barcode in iReport

Scenario
1. As user click "Preview" in iReport, it will show dialog to input
2. iReport will generate barcode in "Preview" mode

Process
1. File-->New

 2. Choose "Blank A4"-->Open this Template

 3. Give it a name, barcodeReport, and click Next

4. Click Finish

5. Right click --> Add Parameter

6. Assign "barcodeParam" as its parameter name

7. Show palette: Window-->Palette

8. Click Barcode, Drag and Drop to template

9. Choose "Code128A" as our barcode type, and click "Use Barbecue"

10. A barcode has displayed in our template

11. Click "..." button in "Code Expression"

12. Assign "barcodeParam" in "Code Expression"

13. Click "Preview" to switch into Preview Mode

14. Input random value in this popup window and click OK

15. iReport will generate barcode based on the value you inputed

16. Download barcode reader in your smart phone, iPhone, and scan it to do validation