Jasper reports 背景交替的子报告

Jasper reports 背景交替的子报告,jasper-reports,subreport,Jasper Reports,Subreport,我正在使用iReport 3.7.6。(不可能使用更新的版本) 我有一份主报告和一份分报告。子报表重复多次,我需要为子报表设置交替背景,但我需要在每个子报表下面显示一个子报表,以便它们在新页面开始时拆分,而不是仅在合适时才在页面上显示 这就是我想要的: 我尝试了多种方法,但似乎都无法奏效 我尝试使用框架并设置备用行样式,并将所有元素放在该框架中: <style name="AlternateRowStyle" mode="Opaque"> <conditionalSt

我正在使用iReport 3.7.6。(不可能使用更新的版本)

我有一份主报告和一份分报告。子报表重复多次,我需要为子报表设置交替背景,但我需要在每个子报表下面显示一个子报表,以便它们在新页面开始时拆分,而不是仅在合适时才在页面上显示

这就是我想要的:

我尝试了多种方法,但似乎都无法奏效

我尝试使用框架并设置备用行样式,并将所有元素放在该框架中:

<style name="AlternateRowStyle" mode="Opaque">
    <conditionalStyle>
        <conditionExpression><![CDATA[$V{REPORT_COUNT} % 2 == 0]]></conditionExpression>
        <style backcolor="#E5E7E9"/>
    </conditionalStyle>
</style>

但我在这篇文章中得到的结果如下:

然后我尝试使用背景带(为了简单起见,我只添加了一种颜色的框架,所以没有交替),但在这种方法中我也遇到了困难

我的子报表只有细节和背景栏,我已将其设置为等高和立即拆分类型

主报告只有详细栏(我简化了它)

子报告片段:

<background>
    <band height="250" splitType="Immediate">
        <frame>
            <reportElement mode="Opaque" x="0" y="0" width="600" height="250" backcolor="#E5E7E9"/>
        </frame>
    </band>
</background>
<detail>
    <band height="250" splitType="Immediate">
        //content not important
    </band>
</detail>
<detail>
    <band height="660" splitType="Immediate">
        <subreport>
            <reportElement positionType="Float" x="0" y="0" width="600" height="250"/>
            <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{objects})]]></dataSourceExpression>
            <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "subreport1.jasper"]]></subreportExpression>
        </subreport>
    </band>
</detail>

//内容不重要
主报告片段:

<background>
    <band height="250" splitType="Immediate">
        <frame>
            <reportElement mode="Opaque" x="0" y="0" width="600" height="250" backcolor="#E5E7E9"/>
        </frame>
    </band>
</background>
<detail>
    <band height="250" splitType="Immediate">
        //content not important
    </band>
</detail>
<detail>
    <band height="660" splitType="Immediate">
        <subreport>
            <reportElement positionType="Float" x="0" y="0" width="600" height="250"/>
            <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{objects})]]></dataSourceExpression>
            <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "subreport1.jasper"]]></subreportExpression>
        </subreport>
    </band>
</detail>

但这种方法会导致wierd行为:子报表的背景只在主报表的每一页上显示一次,并且只显示在页面的开头,而不管主报表的一页上实际有多少个子报表,就像背景设置为主报表一样(如图所示)。我希望每个报告都有背景


如果有任何帮助,我将不胜感激。

请尝试为背景带中的帧元素设置stretchType=“RelativeToBandHeight”。这没有帮助:(