Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
687 views
in Technique[技术] by (71.8m points)

jasper reports - How to control the number of rows in a JasperReports

How do I set the number of rows to be displayed per page in a report using iReports. Ex: if i have 100 records, I wasnt to display 10 per page and then break. The default behavior is to cram all the records possible in the page.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ok! Found a way to accomplish this!

  1. The rows are usually printed in the Details band.
  2. At the end of the details band, where you need a page break, add a pagebreak.
  3. In the pageBreak's properties, edit the printWhen Expression from the properties pane.
  4. The expression will be

new java.lang.Boolean((int)($V{REPORT_COUNT}.intValue())%10==0)

where 10 is the number of records per page.

This is how it is done in iReports. The jrxml equivalent for people directly editing the file is as below.

<break>
    <reportElement x="0" y="23" width="100" height="1">
        <printWhenExpression><![CDATA[new java.lang.Boolean((int)($V{REPORT_COUNT}.intValue())%10==0)]]></printWhenExpression>
    </reportElement>
</break>

Put this just after the <band> tag under <details> tag.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...