Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print When (last element reached) Expression in JasperReports

Is it possible to generated a "Print When Expression" that detects the last element in an XML datasource file?

Basically I have a report with a column break inserted after a sub-report in a detail band so I can clearly define new pages for the beginning of a new record. But it always leaves me with a blank last page. So I am hoping that I can prevent this if I have a print when condition that prevents the column break if it is the last record element in the XML datasource.

Is this even possible?

like image 358
travega Avatar asked Nov 14 '22 11:11

travega


1 Answers

The problem is that you don't know it's the last element until after you look for the next element. I don't think there is a simple way.

In principle it should be fine to do something like this:
Create a super-report around the entire report. Run the same query in the super-report. Count the rows. Then pass the number of rows to the original report (which is now a subreport) and re-run the query again. Clearly, running the query twice is another drawback.

If the data source were SQL, then I would suggest modifying the SQL to return the number of rows as part of the result set. But for non-SQL data sources, you need some way of knowing the number of rows (well... some way of identifying the last row) before you reach the last row.

like image 63
mdahlman Avatar answered Jan 03 '23 10:01

mdahlman