我正在使用iReport 4.5.1创建报告模板(jrxml文件)。
我有主报告和子报告。在主报告中,我有参数和变量:参数PGNUM和变量PAGE_NUMBER。在子报告中,我有两个框架(框架 A和框架 B)、变量TempPAGENUM和参数PGNUM。
我在所有报告中使用PAGE_NUMBER对页面进行编号,因此我在主报告的页面标题带中找到了该变量。
PGNUM是一个参数,用于传递由PAGE_NUMBER变量产生的页数的值。
我的目标是我想让子报表中的框架 A在表达式为时打印,
而对于框架 B是表达式为TempPAGENUM modulo 6 not equal 1
TempPAGENUMBER modulo 6 is equal 1
所以问题是当我使用参数PGNUM作为子报表的参数输入和由主报表计算的PAGE_NUMBER时,为什么子报表中的 TempPAEGNUM 变量即使是“初始值表达式”也永远不会增加我用PGNUM填充它作为参数输入。
变量TempPAGENUM永远不会增加并且我的目标失败了,它永远不会显示帧 B,因为TempPAGENUMBER永远不会算作 6 值。
你能帮我解决这个问题吗?
主要报告:
<?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="isat_new_form" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="502" leftMargin="56" rightMargin="37" topMargin="28" bottomMargin="42" whenResourceMissingType="Key">
<style name="Style 1" mode="Opaque">
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#999999">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Users\\skyeres\\Desktop\\kirim\\"]]></defaultValueExpression>
</parameter>
<parameter name="PGNUM" class="java.lang.Integer"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band>
<printWhenExpression><![CDATA[new Boolean($V{PAGE_NUMBER}.intValue() == 0)]]></printWhenExpression>
</band>
</title>
<pageHeader>
<band height="10" splitType="Stretch">
<textField>
<reportElement x="319" y="0" width="131" height="10"/>
<textElement textAlignment="Right">
<font fontName="Arial" size="7"/>
</textElement>
<textFieldExpression><![CDATA["Page : "+$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="458" y="0" width="38" height="10"/>
<textElement>
<font fontName="Arial" size="7"/>
</textElement>
<textFieldExpression><![CDATA["- "+$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="0" width="213" height="10"/>
<textElement>
<font fontName="Arial" size="7"/>
</textElement>
<text><![CDATA[Sample Invoice. For Testing Purpose Only]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="762">
<printWhenExpression><![CDATA[]]></printWhenExpression>
<subreport>
<reportElement x="0" y="0" width="502" height="762"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="PGNUM">
<subreportParameterExpression><![CDATA[$P{PGNUM}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<pageFooter>
<band>
<printWhenExpression><![CDATA[new Boolean($V{PAGE_NUMBER}.intValue() == 1)]]></printWhenExpression>
</band>
</pageFooter>
</jasperReport>
子报告:
<?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="deploy_details" language="groovy" pageWidth="502" pageHeight="842" columnWidth="502" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<style name="table_CH" mode="Opaque" backcolor="#999999">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\DEMO\\JasperFormat\\"]]></defaultValueExpression>
</parameter>
<parameter name="PGNUM" class="java.lang.Integer"/>
<variable name="tempPAGENUM" class="java.lang.Integer" incrementType="Page" calculation="Sum">
<variableExpression><![CDATA[$V{tempPAGENUM}+1]]></variableExpression>
<initialValueExpression><![CDATA[$V{PAGE_NUMBER}+$P{PGNUM}]]></initialValueExpression>
</variable>
<detail>
<band height="762" splitType="Stretch">
<frame>
<reportElement isPrintRepeatedValues="false" mode="Opaque" x="62" y="71" width="114" height="43" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" backcolor="#000000">
<printWhenExpression><![CDATA[$V{tempPAGENUM} % 6 != 1]]></printWhenExpression>
</reportElement>
<staticText>
<reportElement mode="Transparent" x="15" y="12" width="83" height="18" forecolor="#FFFFFF"/>
<textElement/>
<text><![CDATA[FrameA]]></text>
</staticText>
</frame>
<frame>
<reportElement isPrintRepeatedValues="false" mode="Opaque" x="191" y="71" width="114" height="43" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" backcolor="#000000">
<printWhenExpression><![CDATA[$V{tempPAGENUM} % 6 == 1]]></printWhenExpression>
</reportElement>
<staticText>
<reportElement mode="Transparent" x="15" y="12" width="83" height="18" forecolor="#FFFFFF"/>
<textElement/>
<text><![CDATA[FrameB]]></text>
</staticText>
</frame>
</band>
</detail>
</jasperReport>