Jasper SubReport不会在Master

时间:2016-09-02 19:53:49

标签: jasper-reports subreport

一年前我问了一个类似的问题,并没有找到解决方案。我现在正在处理的子报告是在主人的细节范围内,尽管为了以防万一我在其他人中尝试过。

    <detail>
    <band height="34" splitType="Stretch">
        <subreport>
            <reportElement stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" mode="Transparent" x="0" y="0" width="555" height="34" uuid="6318f4b9-c420-4294-a63f-1a83d338f755">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <subreportParameter name="item_id">
                <subreportParameterExpression><![CDATA[$F{item_id}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA["report.jasper"]]></subreportExpression>
        </subreport>
    </band>
</detail>

我检查了子报表的路径是否正确。在子报表中,parameter_name完全相同。 .jasper文件已成功编译。

主报告调用存储过程,我正在使用它返回的一个字段作为子报告参数。我在这里称它为“item_id”。我使用向导将其映射到具有相同名称的子报表参数。这个想法是子报告应该返回有关SP在主报告中返回的每个item_id的附加信息。

当我自己运行子报表时,它会返回特定item_id的数据。我在主服务器中创建了一个变量来跟踪SP自身返回的行数,当我运行主服务器时,它显示存在正确的行数但主数据库上没有数据显示。它还留下足够的空白空间,以表示正在返回某些内容但尚未显示。当我在主报表的属性中为子报表元素设置'删除行空白'时,我没有得到任何行 - 所以显然它返回空行44次 - 每行一行。或者是吗?

一个建议是删除connection_expression并将其替换为parameters_map_expression,但这也无济于事。

我最好的猜测是子报告数据由于某种原因没有进入主数据。如果有人有任何建议,我可以使用JasperSoftStudio 6.3做任何事情。

主报告:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports        Library version 5.6.1  -->
<!-- 2016-09-07T10:21:37 -->
<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="ITEMMRPT" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1aa96e89-cb24-464e-90bf-0d12bc48a516">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="staging"/>
<parameter name="billing_year" class="java.lang.Integer">
    <defaultValueExpression><![CDATA[2015]]></defaultValueExpression>
</parameter>
<parameter name="billing_month" class="java.lang.Integer">
    <defaultValueExpression><![CDATA[9]]></defaultValueExpression>
</parameter>
<parameter name="billing_day" class="java.lang.Integer">
    <defaultValueExpression><![CDATA[1]]></defaultValueExpression>
</parameter>
<parameter name="report_type" class="java.lang.String">
    <defaultValueExpression><![CDATA["DAILY"]]></defaultValueExpression>
</parameter>
<parameter name="area_cd" class="java.lang.String">
    <defaultValueExpression><![CDATA["TACM"]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
    <![CDATA[exec createitembillingReport;1 @billing_year = $P{billing_year}, @billing_month = $P{billing_month}, @billing_day = $P{billing_day},@report_type=$P{report_type},@area_cd = $P{area_cd}]]>
</queryString>
<field name="item_id" class="java.lang.String"/>
<field name="item_name" class="java.lang.String"/>
<variable name="total" class="java.lang.Integer" calculation="Count">
    <variableExpression><![CDATA[$F{item_id}]]></variableExpression>
</variable>
<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band height="67">
        <staticText>
            <reportElement x="60" y="33" width="242" height="17" uuid="06a14aaf-07b9-4894-bc60-0f5b3b254826">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="11"/>
            </textElement>
            <text><![CDATA[Item Listing]]></text>
        </staticText>
        <staticText>
            <reportElement x="60" y="50" width="78" height="17" uuid="365238e1-9e5f-471b-92aa-aadab4fcfc31">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="11" isBold="true"/>
            </textElement>
            <text><![CDATA[Billable as of :]]></text>
        </staticText>
        <textField>
            <reportElement x="138" y="50" width="180" height="17" uuid="c735ec59-4e96-4b22-bf70-08af130efed9"/>
            <textElement>
                <font size="11" isBold="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$P{billing_month}+"/"+$P{billing_day}+"/"+$P{billing_year}]]></textFieldExpression>
        </textField>
    </band>
</title>
<columnHeader>
    <band height="18">
        <staticText>
            <reportElement x="16" y="0" width="70" height="17" uuid="79476ab9-e5ea-40ec-b382-b22a0c5d355a">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="12" isBold="true"/>
            </textElement>
            <text><![CDATA[Item ID]]></text>
        </staticText>
        <staticText>
            <reportElement x="479" y="0" width="61" height="17" uuid="adb588f3-ed71-439a-acde-d812acee6a94">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="12" isBold="true"/>
            </textElement>
            <text><![CDATA[Location]]></text>
        </staticText>
        <staticText>
            <reportElement x="260" y="0" width="97" height="17" uuid="243ce68e-c532-4056-958e-08f7a0f83d2a">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="12" isBold="true"/>
            </textElement>
            <text><![CDATA[Pull Date]]></text>
        </staticText>
        <staticText>
            <reportElement x="89" y="0" width="87" height="17" uuid="ca299eb7-2aba-4529-ae76-3dfa4c6abe29">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="12" isBold="true"/>
            </textElement>
            <text><![CDATA[Order Date]]></text>
        </staticText>
        <staticText>
            <reportElement x="380" y="0" width="86" height="17" uuid="c220e72b-bd29-416a-95fc-c6c8a10ab081">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="12" isBold="true"/>
            </textElement>
            <text><![CDATA[Ship Date]]></text>
        </staticText>
        <staticText>
            <reportElement x="168" y="0" width="92" height="17" uuid="2ea414c5-4484-48dc-a6b5-52d4ab3ebd97">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textElement>
                <font size="12" isBold="true"/>
            </textElement>
            <text><![CDATA[Description]]></text>
        </staticText>
        <line>
            <reportElement x="0" y="17" width="555" height="1" uuid="ab7d193f-96d3-454a-8fdd-5e0027425d42">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
        </line>
    </band>
</columnHeader>
<detail>
    <band height="20" splitType="Stretch">
        <subreport>
            <reportElement isPrintRepeatedValues="false" mode="Transparent" x="0" y="4" width="555" height="16" uuid="6318f4b9-c420-4294-a63f-1a83d338f755">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <subreportParameter name="item_id">
                <subreportParameterExpression><![CDATA[$F{item_id}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA["report.jasper"]]></subreportExpression>
        </subreport>
        <textField>
            <reportElement x="10" y="-1" width="100" height="16" uuid="91285585-7366-46c3-b248-9dbaf0c80839"/>
            <textFieldExpression><![CDATA[$F{item_id}]]></textFieldExpression>
        </textField>
    </band>
</detail>
<pageFooter>
    <band height="15">
        <textField>
            <reportElement x="110" y="0" width="100" height="15" uuid="54e9321a-c062-49f4-8b32-02f4c41458c0"/>
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
        <textField evaluationTime="Report">
            <reportElement x="210" y="0" width="100" height="15" uuid="00b215e9-ba28-413b-ad44-4c4a3aac7fdd"/>
            <textElement textAlignment="Left"/>
            <textFieldExpression><![CDATA[" of " + $V{PAGE_NUMBER}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="400" y="-1" width="50" height="15" uuid="0dae2a30-28fe-4a71-9dc9-ec906ec05c78"/>
            <text><![CDATA[Run Date :]]></text>
        </staticText>
        <textField pattern="MMMMM dd, yyyy">
            <reportElement x="450" y="1" width="100" height="13" uuid="34cfa033-e43d-4668-852d-3019f322ea5a"/>
            <textFieldExpression><![CDATA[new SimpleDateFormat("MMM dd, yyyy").format(TODAY())]]></textFieldExpression>
        </textField>
    </band>
</pageFooter>
<summary>
    <band height="18">
        <textField>
            <reportElement x="120" y="2" width="50" height="16" uuid="4a336320-9341-42dd-98c4-1cec2c2d6a15"/>
            <textFieldExpression><![CDATA[$V{total}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="10" y="2" width="100" height="13" uuid="00887a5b-9421-402b-98b8-b041f08959f0">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <text><![CDATA[Total Items]]></text>
        </staticText>
    </band>
</summary>

子报表:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1  -->
<!-- 2016-09-07T10:37:50 -->
<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="report" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="9014add6-11f0-4647-97ec-9b9f3f78afce">
<parameter name="item_id" class="java.lang.String" isForPrompting="false"/>
<queryString language="SQL">
    <![CDATA[select b.item_id,
            b.order_dt,
            cpnv.item_desc,
            cpnv.pull_dt,
            b.ship_dt,
            location = (select bjc.location_cd
                          from warehouse_location bjc
                          where bjc.item = b.item_id
                           and bjc.location_start_dt = 
                              (select max(location_start_dt) 
                               from  warehouse_location 
                                where item_id = b.item_id))
from item_names cpnv
join items b
ON cpnv.sub_id = b.sub_id
where (ship_dt is null or ship_dt >= '1-24-16 22:00')
and b.item_id = $P{item_id}]]>
</queryString>
<field name="item_id" class="java.lang.String"/>
<field name="order_dt" class="java.sql.Timestamp"/>
<field name="item_desc" class="java.lang.String"/>
<field name="pull_dt" class="java.sql.Timestamp"/>
<field name="ship_dt" class="java.sql.Timestamp"/>
<field name="location" class="java.lang.String"/>
<background>
    <band splitType="Stretch"/>
</background>
<detail>
    <band height="41" splitType="Stretch">
        <textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
            <reportElement x="9" y="11" width="67" height="20" isPrintWhenDetailOverflows="true" uuid="12d147f8-532b-4ed5-a249-e03661099e4f">
                <property name="local_mesure_unitheight" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textFieldExpression><![CDATA[$F{item_id}]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
            <reportElement x="89" y="11" width="78" height="20" isPrintWhenDetailOverflows="true" uuid="76ea3e37-9b7a-44e3-a1ae-5850072b90ef">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yy hh:mm").format($F{order_dt})]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
            <reportElement x="168" y="11" width="156" height="20" isPrintWhenDetailOverflows="true" uuid="9ab7bd73-e633-4d51-8271-00c673750a38">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textFieldExpression><![CDATA[$F{item_desc}]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
            <reportElement x="326" y="11" width="48" height="20" isPrintWhenDetailOverflows="true" uuid="b0ac4ef7-e951-4fb2-ab80-3b6dc3103764">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yy").format($F{pull_dt})]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
            <reportElement x="380" y="11" width="69" height="20" isPrintWhenDetailOverflows="true" uuid="83cb0048-4b23-42a9-a48d-63501a9f242d">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yy hh:mm").format($F{ship_dt})]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
            <reportElement x="479" y="11" width="54" height="20" isPrintWhenDetailOverflows="true" uuid="67a5bd0d-cd6d-4910-83d0-396fc36781d3">
                <property name="com.jaspersoft.studio.unit.height" value="px"/>
            </reportElement>
            <textFieldExpression><![CDATA[$F{location}]]></textFieldExpression>
        </textField>
    </band>
</detail>

由于专有原因,我改变了一些名称。希望他们是一致的。如果某些东西没有jive,它可能会在翻译中丢失。

如上所述,查询在子报表中正常工作。当我从主报告中的过程中给它一个item_id时,它会正确显示该项目的所有字段。它只是不会通过主报告。

1 个答案:

答案 0 :(得分:0)

您可以尝试在子报表的标题区域中打印子报表参数$ P {item_id},以检查参数传递是否正常工作。

根据主要报告详细信息区域的高度,可能您必须删除子报告的顶部和底部边距。

相关问题