Jasper reports 当打印时,框架上如何保持相同的行为当表达式为false时,就好像它不存在一样?

Jasper reports 当打印时,框架上如何保持相同的行为当表达式为false时,就好像它不存在一样?,jasper-reports,Jasper Reports,所以我有一个有两个框架的细节栏,第一个框架有几个元素,包括一个子报表,第二个框架只有一个文本字段 我遇到的问题是,如果我从带中删除第二帧,所有内容都会保留在同一页中。如果我添加第二个框架并使用printonly表达式不显示它,它会将整个内容更改为下一页。 如果第二个框架为空,有没有办法强制执行该操作,以保持该行为好像根本不存在 <band height="160" splitType="Prevent"> <property name="local_mesure

所以我有一个有两个框架的细节栏,第一个框架有几个元素,包括一个子报表,第二个框架只有一个文本字段

我遇到的问题是,如果我从带中删除第二帧,所有内容都会保留在同一页中。如果我添加第二个框架并使用printonly表达式不显示它,它会将整个内容更改为下一页。 如果第二个框架为空,有没有办法强制执行该操作,以保持该行为好像根本不存在

<band height="160" splitType="Prevent">
        <property name="local_mesure_unitheight" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
        <frame>
            <reportElement isPrintRepeatedValues="false" x="0" y="1" width="556" height="116" isRemoveLineWhenBlank="true" uuid="3aca49ee-4b55-452c-a8c6-5cc252c4175c">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <subreport>
                <reportElement positionType="Float" x="2" y="65" width="160" height="51" uuid="438d3f08-7b8a-4b61-b17f-19993aa5abe4">
                    <property name="local_mesure_unitx" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                </reportElement>
                <subreportParameter name="DOC_ID">
                    <subreportParameterExpression><![CDATA[$P{DOC_ID}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="IS_RUNNING_LOCAL">
                    <subreportParameterExpression><![CDATA[$P{IS_RUNNING_LOCAL}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{IS_RUNNING_LOCAL} ? "/Reports/Common/xxxxxxxxxxxxxxSub.jasper" : "repo:/Reports/Common/xxxxxxxxxxxxxxSub"]]></subreportExpression>
            </subreport>
            <textField isStretchWithOverflow="true">
                <reportElement style="Default" positionType="Float" mode="Transparent" x="1" y="1" width="552" height="30" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="837c85bf-7a2a-4eb5-919d-bd16d4bc64f2">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="local_mesure_unity" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                </reportElement>
                <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
                <textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
                </textElement>
                <textFieldExpression><![CDATA["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="Default" positionType="Float" mode="Transparent" x="2" y="43" width="511" height="17" forecolor="#000000" backcolor="#FFFFFF" uuid="3e1c3952-6578-4d5f-85a3-d706fc5a5fbb">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitx" value="cm"/>
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                </reportElement>
                <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
                <textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
                    <font fontName="Arial" size="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
                </textElement>
                <textFieldExpression><![CDATA["testetestestestestestes"]]></textFieldExpression>
            </textField>
        </frame>
        <frame>
            <reportElement positionType="Float" x="1" y="120" width="555" height="40" isRemoveLineWhenBlank="true" uuid="c3bf96ce-dd19-41f1-bf13-fe1dd46d8d4e">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
                <property name="local_mesure_unitwidth" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                <printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
            </reportElement>
            <textField isBlankWhenNull="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" mode="Transparent" x="1" y="0" width="551" height="39" isRemoveLineWhenBlank="true" uuid="c1ab35b8-31a6-41e9-a260-71bbcab8692e">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
                </reportElement>
                <textElement textAlignment="Justified">
                    <font size="10"/>
                </textElement>
                <textFieldExpression><![CDATA["PS: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
            </textField>
        </frame>
    </band>

如果第二个框架为空,有没有办法强制执行该操作,以保持该行为好像根本不存在

<band height="160" splitType="Prevent">
        <property name="local_mesure_unitheight" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
        <frame>
            <reportElement isPrintRepeatedValues="false" x="0" y="1" width="556" height="116" isRemoveLineWhenBlank="true" uuid="3aca49ee-4b55-452c-a8c6-5cc252c4175c">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <subreport>
                <reportElement positionType="Float" x="2" y="65" width="160" height="51" uuid="438d3f08-7b8a-4b61-b17f-19993aa5abe4">
                    <property name="local_mesure_unitx" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                </reportElement>
                <subreportParameter name="DOC_ID">
                    <subreportParameterExpression><![CDATA[$P{DOC_ID}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="IS_RUNNING_LOCAL">
                    <subreportParameterExpression><![CDATA[$P{IS_RUNNING_LOCAL}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{IS_RUNNING_LOCAL} ? "/Reports/Common/xxxxxxxxxxxxxxSub.jasper" : "repo:/Reports/Common/xxxxxxxxxxxxxxSub"]]></subreportExpression>
            </subreport>
            <textField isStretchWithOverflow="true">
                <reportElement style="Default" positionType="Float" mode="Transparent" x="1" y="1" width="552" height="30" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="837c85bf-7a2a-4eb5-919d-bd16d4bc64f2">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="local_mesure_unity" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                </reportElement>
                <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
                <textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
                    <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
                </textElement>
                <textFieldExpression><![CDATA["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="Default" positionType="Float" mode="Transparent" x="2" y="43" width="511" height="17" forecolor="#000000" backcolor="#FFFFFF" uuid="3e1c3952-6578-4d5f-85a3-d706fc5a5fbb">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="local_mesure_unitx" value="cm"/>
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                    <property name="local_mesure_unitheight" value="pixel"/>
                </reportElement>
                <box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
                <textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
                    <font fontName="Arial" size="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
                </textElement>
                <textFieldExpression><![CDATA["testetestestestestestes"]]></textFieldExpression>
            </textField>
        </frame>
        <frame>
            <reportElement positionType="Float" x="1" y="120" width="555" height="40" isRemoveLineWhenBlank="true" uuid="c3bf96ce-dd19-41f1-bf13-fe1dd46d8d4e">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
                <property name="local_mesure_unitwidth" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                <printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
            </reportElement>
            <textField isBlankWhenNull="true">
                <reportElement positionType="Float" isPrintRepeatedValues="false" mode="Transparent" x="1" y="0" width="551" height="39" isRemoveLineWhenBlank="true" uuid="c1ab35b8-31a6-41e9-a260-71bbcab8692e">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
                </reportElement>
                <textElement textAlignment="Justified">
                    <font size="10"/>
                </textElement>
                <textFieldExpression><![CDATA["PS: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
            </textField>
        </frame>
    </band>
解决方法是使用多个细节栏,并将
printweenexpression
设置为细节栏

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TestParams" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f85bc6aa-5060-4485-bd99-bd5de1734ef1">
<queryString>
        <![CDATA[]]>
    </queryString>
    <detail>
        <band height="116">
           <break>
            <reportElement x="0" y="5" width="100" height="1" uuid="fb9c89cd-1b6a-44f5-82a9-99e9996229e3">
                <printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
            </reportElement>
           </break>
            <frame>
                <reportElement x="0" y="10" width="200" height="116" uuid="e6890adf-6ff1-49f6-9c47-ba6f171a2c60"/>
            </frame>
        </band>
        <band height="40">
            <printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
            <frame>
                <reportElement x="0" y="0" width="200" height="40" uuid="d9f8ba4a-e435-49ff-9ff7-d23e55aecc52"/>
            </frame>
        </band>
    </detail>
</jasperReport>


这样,如果第二个组件未显示/打印,则整个标注栏(高度)将被删除,其行为将与仅存在第一个标注栏一样。

请发布XML文件问题是,如果要显示第二个标注栏,如何强制这两个标注栏更改页面?这就是我想要的行为。@我编辑的Maxrunner在显示另一个坏页面时也添加了一个分页符,但是通常情况下(如果您不确定它是否总是应该分页符,固定内容),您可以使用组处理动态分页符,组有一个参数
minHeightToStartNewPage
,可以帮助您决定何时分页符。不过,根据您目前的问题以及您的评论,我想分页符就足够了。谢谢,解决方案是将分页符放在新的细节/波段中。