Home:ALL Converter>How can I build a report with large summary in JasperReports

How can I build a report with large summary in JasperReports

Ask Time:2017-09-05T07:20:44         Author:Alvaro Pedraza

Json Formatter

I'm trying to accomplish some requirements with a report I'm designing for a desktop app. I'll try to explain myself as clearly as it's possible to me. The situation is as follows:

I have a report with a simple table in the <detail> band and then a very big section of some static text and 2 or 3 expressions, which should correspond to the <summary> band. In a first moment, I tried to put all that information in the <summary> but then I found out the 656px height limitation for JasperReports bands.

My second attempt to solve that problem was to put that static summary information in a subreport. That way I was able to use <title> and <summary> bands to put the fields in both bands and don't have to worry about band height limitation. The problem with that solution is that I wasn't able to show page numbers (from the first report) in the subreport section (which has 2 or 3 pages). I found the option of page footer and header in summary (a checkbox in Jaspersoft Studio which is isSummaryWithPageHeaderAndFooter="true" property in <jasperReport> element) but then my report gave me a compilation error on preview; don't know if it's a bug in Jaspersoft Studio: I tried in the 2 latest versions and the error was the same.

Finally, I tried to add a second <detail> band with a different query which returns only a single value. The problem now is that I wasn't able to put the second detail band "below" the first: in the preview I see one row from each band alternately, and not as I need. After searching a lot I found out that this is not possible.

Summary requirements causing problems

The summary has the following requirements:

  1. Has severals static text fields and some other expressions with calculated fields and parameters (formatted dates and things like that).
  2. Those pages must be paginated (page [current] of [total] in the footer).
  3. The datasource and the query is the same for the main report and the summary.

The first requirement makes the summary band to need a height bigger than 656px, which is the max allowed for that band. So I tried the solutions described briefly above. I'll describe now the problems for the subreport approach.

Subreport with isSummaryWithPageHeaderAndFooter="true"

When I try to preview the report from Jaspersoft Studio with this approach, first I get the following state (before the IDE ask for the parameter):

First report state

When I enter the parameter, I get the following state:

Second report state

and after that the times and the pages keep growing until the program crashes. The same behavior happens in different installations: I tried versions 6.3.1 and 6.4.0 in both Windows 7 and Mac OS. HOWEVER, compiling the report from the IDE is successful (I mean it generates the .jasper file) with the compile report option.

compile report option

But when I export the report to PDF (or display it with JasperViewer) it doesn't render with page footer in summary band.

Note: Compiling the report from a simple Java app doesn't gives me any error.

Any help is welcomed. Thanks in advance.

Author:Alvaro Pedraza,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46045053/how-can-i-build-a-report-with-large-summary-in-jasperreports
localghost :

You could add a dummy group that won't generate any ruptures and place the second detail's content inside the group footer band.",
2017-10-26T13:11:15
yy