2

我是JasperReportsiReport的新手。

我创建了一个主报表,其中包含自己的查询以及我将要包含的所有子报表。没有对任何子报告的查询。

我正在向主报告添加一个子报告并将其设置为使用数据源,该数据源是从主报告传递的参数。

我包含在主报告的详细信息部分中的子报告,因为它将显示数据。

当我运行主报表时,它会获取子报表,将数据传递并添加到子报表中,但由于某种原因,它会从子报表中的数据集中删除第一行。所以最后它开始显示子报告中第二行的数据。当我不包含子报表并将字段直接放入主报表的详细信息时,它会显示所有行。

我已经尝试增加两个报告详细信息部分的大小/高度和宽度,但它仍然删除了子报告中的第一行。我不知道接下来要尝试什么,看看可能是什么问题。

是否需要为子报告设置配置才能使其正常工作?

主要报告详细信息部分:

<detail>
        <band height="27" splitType="Stretch">
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="4171aece-1917-4338-8423-449eecf9dfff" key="textField-2" positionType="Float" mode="Opaque" x="180" y="0" width="88" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding90}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="34e23f8d-2664-47e9-be04-5c1494fbb38a" key="textField-7" positionType="Float" mode="Opaque" x="539" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{On time}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="3f707683-90e2-4c36-bb98-f1d6186687ae" key="textField-5" positionType="Float" mode="Opaque" x="449" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Total outstanding}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="4b54c6d3-f4e7-4f33-b84b-c4fd73ff4365" key="textField-8" positionType="Float" mode="Opaque" x="719" y="0" width="83" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="fb5afad4-e7c3-43a8-a3e6-e4d380bc5a51" key="textField-3" positionType="Float" mode="Opaque" x="269" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding60}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="b4809993-6a3c-42b3-bd14-6a62bac0f489" key="textField-4" positionType="Float" mode="Opaque" x="359" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding30}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="903f019a-f45e-4c6d-a580-5045eb8d4671" key="textField-6" positionType="Float" mode="Opaque" x="629" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Advance payment}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="780255b2-20d0-4e3e-8467-1afc5a234b52" key="textField-2" positionType="Float" mode="Opaque" x="90" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding120}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="true">
                <reportElement uuid="e8b6e711-881b-4fe6-be66-445930aa0655" key="textField-1" positionType="Float" mode="Opaque" x="0" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="1">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Status}]]></textFieldExpression>
            </textField>
        </band>
    </detail>

子报告:

<?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="OpsommendeKredietVerslagBedrae" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="eb062df7-cf59-4037-972e-a44f935a83cd">
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="Outstanding30" class="java.lang.Double"/>
    <field name="Outstanding60" class="java.lang.Double"/>
    <field name="Outstanding90" class="java.lang.Double"/>
    <field name="Outstanding120" class="java.lang.Double"/>
    <field name="On time" class="java.lang.Double"/>
    <field name="Advance payment" class="java.lang.Double"/>
    <field name="Total outstanding" class="java.lang.Double"/>
    <field name="Status" class="java.lang.String"/>
    <field name="Scheduled payment30" class="java.lang.Double">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Scheduled payment60" class="java.lang.Double">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Scheduled payment90" class="java.lang.Double">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Scheduled payment120" class="java.lang.Double">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="26" splitType="Stretch">
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="903f019a-f45e-4c6d-a580-5045eb8d4671" key="textField-6" positionType="Float" mode="Opaque" x="628" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Advance payment}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="fb5afad4-e7c3-43a8-a3e6-e4d380bc5a51" key="textField-3" positionType="Float" mode="Opaque" x="269" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding60}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="3f707683-90e2-4c36-bb98-f1d6186687ae" key="textField-5" positionType="Float" mode="Opaque" x="448" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Total outstanding}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="4171aece-1917-4338-8423-449eecf9dfff" key="textField-2" positionType="Float" mode="Opaque" x="180" y="0" width="88" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding90}]]></textFieldExpression>
            </textField>
            <textField pattern="" isBlankWhenNull="true">
                <reportElement uuid="e8b6e711-881b-4fe6-be66-445930aa0655" key="textField-1" positionType="Float" mode="Opaque" x="0" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="1">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Status}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="34e23f8d-2664-47e9-be04-5c1494fbb38a" key="textField-7" positionType="Float" mode="Opaque" x="538" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{On time}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="780255b2-20d0-4e3e-8467-1afc5a234b52" key="textField-2" positionType="Float" mode="Opaque" x="90" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding120}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="b4809993-6a3c-42b3-bd14-6a62bac0f489" key="textField-4" positionType="Float" mode="Opaque" x="359" y="0" width="89" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Outstanding30}]]></textFieldExpression>
            </textField>
            <textField pattern="R #,##0" isBlankWhenNull="true">
                <reportElement uuid="4b54c6d3-f4e7-4f33-b84b-c4fd73ff4365" key="textField-8" positionType="Float" mode="Opaque" x="717" y="0" width="90" height="26" forecolor="#000000" backcolor="#FFFFFF"/>
                <box leftPadding="5" rightPadding="5">
                    <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None">
                    <font fontName="Lucida Sans" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>
4

2 回答 2

1

我终于得到了答案。

我需要的是传递$P{REPORT_CONNECTION}给我的子报告,这意味着每个报告都可以有自己的查询。主报告和所有子报告

脚步:

  1. 自己查询我的主要报告
  2. 通过从调色板中拖动来创建子报表。
  3. 在子报表属性上。设置使用连接表达式
  4. 在子报表属性上。使用价值$P{REPORT_CONNECTION}_
  5. 通过主报表打开子报表,即右键单击主报表上的子报表标签,点击打开子报表。出于某种原因,当我这样做时,它打开了相同的子报告,但它显示了我在单独打开它时所做的更改。我认为这就是改变的地方,因为在我对我打开的那个做出改变之后,所有这些都 100% 有效。

感谢您的所有建议

于 2013-10-21T16:40:27.403 回答
1

为了详细说明这个话题,我对 JavaBeanCollectionDataSource 有同样的问题。我有一个包含许多子报表的主报表,我希望所有子报表都与主数据源一起提供。在所有子报表中使用$P{REPORT_DATA_SOURCE}作为数据源表达式会导致只查看第一个子报表(并且还缺少第一行,因为主报表使用了它)。

解决方案:每个子报表都需要一个新的数据源实例

如何:在填充期间为每个子报表添加数据集的克隆实例。例如:

Map parameters = new HashMap();
parameters.put("MasterDataSourceInstance_1", beanColDataSource.cloneDataSource());
parameters.put("MasterDataSourceInstance_2", beanColDataSource.cloneDataSource());

在报告文件中:

<parameter name="MasterDataSource_1" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="MasterDataSource_2" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>

现在,您可以使用(每次使用一次)数据源实例:

<dataSourceExpression><![CDATA[$P{MasterDataSource_1}]]></dataSourceExpression>
于 2016-08-03T11:31:16.950 回答