0

我有主报告,其中包含摘要部分的子报告。我想要的是我在数据库中有名为bill no 的列,我想显示与bill no 匹配的行。(即在查询的where 子句中它应该在哪里billno='something')。

目前我正在将参数从主报告传递到子报告。但它仍然无法正常工作。

主要报告:

<?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="SwastikReport" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.5"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="411"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["E:\\reports\\"]]></defaultValueExpression>
    </parameter>
<subreport>
                <reportElement x="438" y="56" width="109" height="100"/>
                <subreportParameter name="billoflading">
                    <subreportParameterExpression><![CDATA[$F{billofladingno}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SwastikReport_subreport.jasper"]]></subreportExpression>
            </subreport>
</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="SwastikReport_subreport" language="groovy" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Error">
    <property name="ireport.zoom" value="1.5"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
<parameter name="billoflading" class="java.lang.String">
    <defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
    <queryString>
        <![CDATA[select * from declaredvaluedetails d where d.billofladingno='$P{billoflading}']]>
    </queryString>
    <field name="billofladingno" class="java.lang.String"/>
    <field name="bookingno" class="java.lang.String"/>
    <field name="freightcharges" class="java.math.BigDecimal"/>
    <field name="ratedas" class="java.lang.String"/>
    <field name="per" class="java.math.BigDecimal"/>
    <field name="rate" class="java.math.BigDecimal"/>
    <field name="prepaid" class="java.math.BigDecimal"/>
    <field name="collect" class="java.math.BigDecimal"/>
    <field name="currencyrateofexchange" class="java.math.BigDecimal"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="37" splitType="Stretch">
            <textField>
                <reportElement x="33" y="14" width="82" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{freightcharges}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="120" y="14" width="72" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{ratedas}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="196" y="14" width="32" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{per}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="230" y="14" width="68" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{rate}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="299" y="14" width="82" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{prepaid}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="383" y="14" width="82" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{collect}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="468" y="14" width="81" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{currencyrateofexchange}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

它在主报告上显示空值。

4

1 回答 1

0

我得到了解决方案...解决方案是我必须将子报告参数映射到从主报告传递的参数。

子报告

**

<parameter name="billoflading" class="java.lang.String">
        <defaultValueExpression><![CDATA[$P{billoflading}]]></defaultValueExpression>
    </parameter>

**

于 2013-03-02T12:41:37.457 回答