How to set fields on pages

Asked

Viewed 44 times

1

Please inform if I need to improve the explanation.

I am trying to create a report in Jaspersoft Studio composed of three sections: customer information (a Javabean containing name, email, date of birth, etc.), customer’s addresses (a list of Javabeans each containing the name of the street, number, neighborhood, etc.) and customer requests (also a list of Javabeans, containing order number, date, simple address, total, etc.).

I understand that each of these sections would be a sub-report, powered by a separate Javabeans datasource.

I’m not sure how to distribute them in pages. For example, the first section (customer information) is small and could fit on a page along with the second section (customer’s addresses). But addresses can eventually take up more than one page, so maybe they should be placed on a separate page. I don’t have enough practice with Jasperreports to decide, and I also don’t know how to add two datasources to a single report/page, just an individual report. So I’m considering one sub-report per section.

Also not sure in which bands should I put the sections. I managed to put the first section in the band Title and the second in the band Summary, but I’m not sure where to put the third section. Put two sections in the same band (for example, in the Title) apparently makes one overlap with the other.

Any hint?

Layout proposto para o relatório

1 answer

1

A good reading of this documentation at this link, I’ll copy the report structure from there:

inserir a descrição da imagem aqui

When I structure Ports, I follow the following rule:

  • I have the master, which will include some of the following: Title, Header, Page Footer
  • I usually have several other sections, like this one address you mentioned. For each section of this I add a Subreport in uma Detail
  • Subreports can then use if necessary Column Header and Footer, Detail and Summary, with this you can add headers and footers if your subreport has tables, and if you still have subreports these will follow the same rule of master, a Detail for each subreport.

In short:

  • Title: Used only for the report title (I almost never use)
  • Page header: Report header (I always use, for company logo, addresses...)
  • Column header: Header of a table (the table is included in Detail)
  • Detail: Relevant report data (same report information)
  • Column footer: Table footer (previously included in Detail)
  • Page footer: Page footer (I usually include page footer information)
  • Summary: Area used for sum of values (particularly not use much, usually I present customized details with sum by formula)
  • Hello, your text implies that it is possible to include more than one Detail band in the same master report, this is possible?

  • Hello @Piovezan, yes it is perfectly possible, I even recommend using a band of Detail by subreport, it is more organized.

  • There is a detail related to Details, they are rendered depending on the amount of records passed in the datasource, if you treat multiple subreports as my suggestion, the master should understand that you should render only once, otherwise you will get thousands of equal Details :)

  • How the master is told to render once or multiple times?

  • Sorry I didn’t have an example, I generated Ports in the past company, but I think we passed the content of subreports as parameters to the Jasperfillmanager, and the JRDatasource using Jrbeancollectiondatasource with an empty collection.

  • In our case we didn’t pass the connection directly to the report due to Tomcat pool depletion problems, so we searched all the information before and passed the parameters to the report.

  • I hope it helps you :)

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.