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
1.6k views
in Technique[技术] by (71.8m points)

jasper reports - Subreport overflowed on a band that does not support overflow

I recently had an issue with a subreport of my JasperReports's report in which I was getting the following error:

Subreport overflowed on a band that does not support overflow.

What is happening?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

I fixed the problem, so I thought I'd post my solution here in case someone found it useful.

Things to check:

  1. If you're in a Detail band, check your report's Print Order. It has to be Vertical. Horizontal Print Order reports are not allowed to overflow on Detail bands.
  2. Check your subreport's dimensions. The subreport's width must be smaller than the report's width, and, for non-growing bands (see point #3 below), the height must be smaller than the band's height.
  3. Some bands grow, some bands don't. Keep this in mind with your subreports. If you have a subreport in a header or footer, make sure they do not grow, meaning that your datasource to that subreport can't send in too many elements, or send in repeating elements where your subreport is expecting one or few elements.

In my case, I had made a subreport and passed it a datasource that I wasn't actually using (it was an informational subreport not using any data from the datasource).

(the example is an XML datasource but the same concept applies to SQL datasources.)

e.g.

(net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}
    ).subDataSource("/Order/Note")

Later, the "Note" was turned into an array instead of a single note. Which meant my footer-subreport was trying to repeat twice, thus the footer report was printing twice, making it too high. Thus the error.


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

...