为什么部分不适合页面高度?

Why does sections do not fit the page height?

我正在处理一份需要附加到另一份报告才能生成更大报告的报告,因此它只有标题、页脚和摘要部分。问题是我遇到编译错误,我不知道原因。这是我的 jrxml 文件(为简洁起见省略了 ... 的部分):

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ... pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="469" leftMargin="70" rightMargin="56" topMargin="130" bottomMargin="56" isSummaryWithPageHeaderAndFooter="true" ...>
    <property ...some properties.../>
    <parameter .../>
    <queryString language="SQL">...</queryString>
    <field .../>
    <variable>...</variable>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="650" splitType="Stretch">...</band>
    </title>
    <pageFooter>
        <band height="50">...</band>
    </pageFooter>
    <summary>
        <band height="451">...</band>
    </summary>
</jasperReport>

尝试使用 Jaspersoft Studio 我遇到了一个错误,但看不到跟踪,所以我在 Netbeans 中做了一些例程,我得到的堆栈跟踪是:

Exception in thread "main" net.sf.jasperreports.engine.design.JRValidationException: Report design not valid : 
 1. The title section, the page and column headers and footers and the margins do not fit the page height.
at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:280)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:152)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:357)
at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:273)
at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:232)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:542)
at ar.edu.unt.jasper.ReportCompilerAndExporter.main(ReportCompilerAndExporter.java:25)

我的代码行(堆栈跟踪中的最后一行)是这样的:

String myReport = JasperCompileManager.compileReportToFile("myReport.jrxml");

(文件存在且路径正确)

我的第一个想法是 pageHeight - (topMargin + bottomMargin) < 650px 但事实并非如此,实际上是 656px 所以我不知道我错过了什么。欢迎任何帮助或指导。

我尝试删除 <pageFooter> 只是为了测试(我不能在最终报告中这样做,它包含一些信息)并且报告可以顺利编译和呈现。此外,我可以说没有元素在带外,因为它是用 Jaspersoft Studio 制作的,并且在设计视图中显示了这种错误。

有关报告源代码的任何其他信息,请在评论中告诉我。

它正试图将 pageFootertitle 带(650+50>656)放在同一页面上。

如果您喜欢在没有 pageFooter 的单独页面上显示标题栏,您需要设置属性

isTitleNewPage="true"

来自 JReport API

Specifies if the title section will be printed on a separate initial page.

在 JasperSoft Studio 中