I figured this would be something that would be fairly-well documented as its a central theme to JasperReports, however I can't find an answer for this anywhere.
What is the purpose/function/intention of a details band? Is it supposed to just be the central or core part of a report?
From another question it was pointed out to me that there is a 1:1 relationship between a details band and a record/bean provided by the JRDatasource. This revelation brings to light a few tangential questions:
JasperFillManager
a null
data source? Is it possible to still have detail bands?I don't like to ask multiple questions at a time, but these are so similarly-related I'd rather do it all at once than clutter SO with multiple nearly-identical questions. Thanks in advance.
A subreport is a report included inside another report. This allows the creation of very complex layouts with different portions of a single document filled using different data sources and reports.
You can create another detail band by right-clicking your detail band in the outline and choosing "create band". But to have another header and footer, I think you need to create a subreport for each table. Set up each table with its header and footer in their own report.
A group can even have more than one header\footer band in the designer, for example to add an header to a group it's sufficent right click on the header element in the outline view (it dosen't matter if it has black color or lightgray because at the moment there aren't other headers) and select the option "Create Band" ...
The details band is indeed the band where each element of the data source is reported. The report engine automatically iterates over the data source and inserts data into the template of the detail band with respective element of the data source.
You may of course have several elements on a single page. According to the properties of the band (split allowed, height, etc.), the paging will be handled by Jasper Reports automatically, and it's the engine that will thus decide how many elements are printed on each page, when to go to the following page, etc.
The details band is not printed if you have nothing in the data source. The printing of the other bands depend on the parameters of the report.
The purpose of the detail band
is to provide you with a model where you place and configure report elements. I don't think the relationship between a bean and detail band is one to one, since you can place many bean property elements in one bean. So, i would say the detail band is tightly tied to a collection of report bean elements.
One difference though, is the fact that detail band's functionality is irrelevant to how many beans/records you provide through a JRDataSource
. The detail band will iterate through all of them until the data source is "consumed".
Furthermore, i personally find it very useful that the detail band allow you to iterate through a collection of bean properties. So, placing several properties in a detail band will iterate through all of them, before proceeding forward.
If you pass a null
as DataSource
you wont get any data on the report, and only static
text will show up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With