vincenzo iafelice
vincenzo iafelice

Reputation: 270

JasperReport- best approach for multiple pages static reports

i need to create a static report of 3 pages and every page contains static text and fields retrieved with a database query.

My first approach, after reading similar questions, was to create 3 separated report files (page1.jrxml, page2.jrxml and page3.jrxml) and then merge the resulting reports into a single one. It works fine but sometimes happens that a field contains a very long string and a single file report generetes 2 pages, leading to an horrible printing because the first page is full but the second contains one or few lines.

Can you suggest me a better approach?

Thanks

Upvotes: 4

Views: 5359

Answers (2)

Alex Chevelev
Alex Chevelev

Reputation: 91

I've needed to split a report over several sheets primarily for Excel-export. It seems to be working while previewing on JasperServer also:

  • add report property net.sf.jasperreports.export.xls.one.page.per.sheet set to true
  • add property net.sf.jasperreports.export.xls.break.after.row set to true the the textfield you need a page break after (there's a similar one to break before)

Also you may name your sheets. Please see here: http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.export.xls.one.page.per.sheet

Upvotes: 0

Vasco Mars
Vasco Mars

Reputation: 86

We use jrxml templates and we have only one jrxml. You do not need to have multiple files just split the static text to many DETAILS (paragraphs) and if the first page will overlap with few lines it will be inmediatelly followed by next detail.

In our app we use jasper from java and we pass the params with JasperFillManager.

We create template:

compiledTemplate = JasperCompileManager.compileReport(...);

and then we fill the variables

jasperPrint = JasperFillManager.fillReport(compiledTemplate, map with params, dto implementing JRDataSource);

and then we export it to pdf:

ret = JasperExportManager.exportReportToPdf(jasperPrint);

and thats it.

Upvotes: 3

Related Questions