Tuesday, February 28, 2012

Jasper Reports Performance

When a report returns large number of rows, the 'ignore pagination' property of the report should be set to false. If it is set true, the performance of the report is slow to render all the rows in a single page.

For cross tab reports, when the 'ignore pagination' is set false, the cross tab header will repeat every page when the report is export in to excel. To solve this issue, 'Repeat Column Headers' property of the cross tab should be set to false.

Monday, February 6, 2012

Returning value from Sub Report

When we return value from sub report to main report, we need to create a variable in the sub report to assign the field value, which we want to return.

For example if we want to return Sum, which we calculated using query in the subreport, we need to create a variable called sum, then assign variable expression as $F{sum}. Calculation, Reset type and Increment type should be set to None. Class variable should be of the type of Field.

Then we need to create a variable in the main report to pass the subreport value. Select the same variable as 'Variable Expression'. Calculation, Reset type and Increment type should be set to None. Class variable should be of the type of Field.

Select subreport in the main report, click on 'Return Values' in the properties. Click on Add. Type the Subreport Variable sum, Select the variable created in the main report as value of 'Local destination variable', Select 'Nothing' as 'Calculation type' and click on OK.

Saturday, January 28, 2012

Boolean column in where condition (SQL)

When we check a boolean value in condition, we can use this form.

select
* from SomeTable where true
.

Here true is a column with boolean data type. The above query will give all records which have true as the value for true column.

select * from SomeTable where not(true).

The above query will give all records in SomeTable where value for true column is false.

Most databases will accept this format.

Tuesday, January 17, 2012

Jasper schedule issue

When we schedule a report, which is using union in input control 'single select query' to show multiple values (past 3, 5, 7, etc), the value we selected while we schedule the report will be changed to first value on the next day of report scheduled.

So we have to use 'Single Select list of values' type input control and hard code the values and using dynamic query we can pass them to the report.