Reputation: 863
I started working with subreports in JapserReports. At the beginning I would like to do something very simple. This is xml code of my subreport:
<?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="Rb50dane" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="0" bottomMargin="0">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="column01" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band splitType="Stretch"/>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="22" splitType="Stretch">
<textField>
<reportElement x="208" y="0" width="257" height="22"/>
<box>
<pen lineWidth="3.25"/>
<topPen lineWidth="3.25"/>
<leftPen lineWidth="3.25"/>
<bottomPen lineWidth="3.25"/>
<rightPen lineWidth="3.25"/>
</box>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{column01}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
And this is part of my main report code:
<detail>
<band height="22" splitType="Stretch">
<subreport>
<reportElement x="208" y="0" width="257" height="22"/>
<dataSourceExpression><![CDATA[]]></dataSourceExpression>
<subreportExpression class="java.lang.String"><![CDATA["C:\\Users\\mg\\Jasper\\Rb50data.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
As you can see I do not use any parameter in my subreport. Unfortunately, in iReport after compiling my main report, subreport is not displayed, but when I try to run my subreport separately it works.
In my test I use empty data source. I just want to see the column with null value to find out whether the subreport works fine.
Upvotes: 0
Views: 736
Reputation: 26
I'd try adding something in the dataSourceExpression of the parent report. Maybe send the whole data source by using *
Upvotes: 1