Monday, November 06, 2006

iReport Tips

The following are useful tips for non-Java people like me. Adding Groovy support to iReport should do the trick but it requires an additional library. The tricky part with iReport variables is getting the data types to match.

The highlighting feature of Eclipse BIRT is much better than how it is being done in iReport/Jasperreports. I usually use an arrow character than changing the background color as it looks cleaner in the report design.

Accessing variables, parameters and fields

$P{fieldName} - is for parameter
$F{fieldName} - is for fields
$V{variableName} - is for variables

To highlight a row when it reaches a certain condition:

1. Add a text field
2. In the properties under PrintWhenExpression:

new Boolean($F{owner}.equals("username"))

The key thing here is that if the field owner is true,
it will print the text field.

To set a default date:

new SimpleDateFormat("yyyyMMdd").parse("20050101")

To show overall statistics on the first page of the report: Usually these are variables that should be computed at the end of the report. The reset type on the variable does not affect the actual output. You will need to change the evaluation time property on the textfield object.

To make a computed variable (usually percentage):

new Double($V{VAR1}.doubleValue() / $V{REPORT_COUNT}.doubleValue())

Sunday, November 05, 2006

Eclipse BIRT 2.1.1 SQL Bug

If your Eclipse BIRT report suddenly runs with errors after upgrading to BIRT 2.1.1, check if your SQL statement contains any division expression (i.e. SELECT month, sales / 12 FROM table1). This is a bug in 2.1.1 which was corrected in 2.2. Unfortunately, 2.2 is still a milestone release (not stable).

As discussed in this newsgroup thread, the solution (until 2.2 is released), is to download rcp-report-designer-2.2.0 and copy the oda-jdbc.jar found in: birt-rcp-report-designer-2_2_0\plugins\

and replace the oda-jdbc.jar found at: eclipse\plugins\

You will need to replace the oda-jdbc.jar in the webviewer if you are using it. I would have upgraded to 2.2M1 if the webviewer was working right.