Jump to content
We've recently updated our Privacy Statement, available here ×

JasperReport subReport inside Subreport is not printing the data


manojvemuru

Recommended Posts

 

Hello,
 
My situation is 3 level of report.
Main report is a paper with some details of report , second level is a list of questions, the third level is a four options or a single options image and one question image if the question contains image.
 
The data is printing well for the two or three pages after that the 3rd level sub report which is options or option image is missing at the starting of a new page.
 
Main Report is
<?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="NRWorksheet" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e08b3cc9-2f81-49a0-a077-cb298e0a59bf">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <parameter name="WORKSHEET_HEADER_TEXT" class="java.lang.String" isForPrompting="false"/>
    <parameter name="WORKSHEET_HEADER_CLASS_NAME_TEXT" class="java.lang.String" isForPrompting="false"/>
    <parameter name="QUESTIONS_NUMBER_TEXT" class="java.lang.String" isForPrompting="false"/>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["C:\kaleido\reports\"]]></defaultValueExpression>
    </parameter>
    <parameter name="QUESTION_SUBREPORT" class="net.sf.jasperreports.engine.JasperReport"/>
    <parameter name="QUESTION_SUBREPORT_DS" class="java.lang.Object"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <field name="classText" class="java.lang.String">
        <fieldDescription><![CDATA[classText]]></fieldDescription>
    </field>
    <field name="headerText" class="java.lang.String">
        <fieldDescription><![CDATA[headerText]]></fieldDescription>
    </field>
    <field name="numberofQuestionText" class="java.lang.String">
        <fieldDescription><![CDATA[numberofQuestionText]]></fieldDescription>
    </field>
    <background>
        <band height="802" splitType="Stretch">
            <rectangle>
                <reportElement uuid="ab9ba2b4-6dee-45f8-afa8-862c75aaf44d" x="-4" y="-8" width="564" height="810"/>
                <graphicElement>
                    <pen lineWidth="1.0" lineStyle="Solid"/>
                </graphicElement>
            </rectangle>
        </band>
    </background>
    <title>
        <band height="73" splitType="Stretch">
            <rectangle>
                <reportElement uuid="04cbadc2-287a-4c27-9b17-7611332363a4" mode="Transparent" x="6" y="7" width="543" height="61"/>
            </rectangle>
            <textField>
                <reportElement uuid="c63dfd3f-0e8a-47ea-ac7d-90d0f3512ab9" x="0" y="13" width="555" height="20"/>
                <textElement textAlignment="Center">
                    <font fontName="Calibri" size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{headerText}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement uuid="54a78051-f43d-4954-9829-5ab703e314d7" x="0" y="40" width="555" height="20"/>
                <textElement textAlignment="Center">
                    <font fontName="Calibri" size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{classText}]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <detail>
        <band height="110">
            <staticText>
                <reportElement uuid="895ad664-2164-446d-ab25-365436a4fab1" x="8" y="41" width="126" height="20"/>
                <textElement>
                    <font fontName="Calibri" size="11" isItalic="true"/>
                </textElement>
                <text><![CDATA[This worksheet contains ]]></text>
            </staticText>
            <textField>
                <reportElement uuid="caa97675-cac8-40ac-839a-e2cec1702c1d" x="133" y="41" width="24" height="20"/>
                <textElement>
                    <font fontName="Calibri" size="12" isItalic="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{numberofQuestionText}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement uuid="b4605e3e-9e21-45f1-bedb-ff8d84f12f71" x="157" y="41" width="381" height="20"/>
                <textElement>
                    <font fontName="Calibri" size="11" isItalic="true"/>
                </textElement>
                <text><![CDATA[questions. Write the correct answer in the space provided.]]></text>
            </staticText>
            <subreport>
                <reportElement uuid="4336711f-9c91-4dfa-8ccd-1c6391882bdf" stretchType="RelativeToTallestObject" x="0" y="78" width="538" height="28" isPrintWhenDetailOverflows="true"/>
                <dataSourceExpression><![CDATA[$P{QUESTION_SUBREPORT_DS}]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{QUESTION_SUBREPORT}]]></subreportExpression>
            </subreport>
            <staticText>
                <reportElement uuid="9caea2c1-99b8-4cf1-a232-595d2f47eebc" x="14" y="5" width="100" height="20"/>
                <textElement>
                    <font fontName="Calibri" size="11"/>
                </textElement>
                <text><![CDATA[Name :]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="3ca8c5c5-6e0b-43cd-b72c-991f36623949" x="204" y="5" width="100" height="20"/>
                <textElement>
                    <font fontName="Calibri" size="11"/>
                </textElement>
                <text><![CDATA[Roll number :]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="ce82dd91-be53-4710-a625-c73f6836ddc5" x="397" y="5" width="72" height="20"/>
                <textElement>
                    <font fontName="Calibri" size="11"/>
                </textElement>
                <text><![CDATA[Date : ]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="59230f1b-188d-493c-8419-15fab90253d9" x="473" y="57" width="72" height="20"/>
                <textElement>
                    <font fontName="Calibri" size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[Answers]]></text>
            </staticText>
        </band>
    </detail>
    <pageFooter>
        <band height="54" splitType="Stretch">
            <image>
                <reportElement uuid="9f2b3fe0-aa35-4541-9cc8-7a6c0dce7c93" x="3" y="4" width="127" height="47"/>
                <imageExpression><![CDATA["C:\kaleido\reports\Images\keleido_final_logo.png"]]></imageExpression>
            </image>
            <textField>
                <reportElement uuid="15d87380-9147-407a-a5c6-25206c73f0ca" x="428" y="18" width="80" height="20"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement uuid="0cebb482-d9cc-464b-a25a-5f976c430909" x="508" y="18" width="40" height="20"/>
                <textElement/>
                <textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
</jasperReport>
 
And  First 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="NRWorksheet_QuestionSubReport" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="d403873d-7c02-475b-908a-9e079949b4ed">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#FFBFBF">
        <box>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 1">
        <box>
            <pen lineWidth="1.0" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 1_TH" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 1_CH" mode="Opaque" backcolor="#FFBFBF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 2">
        <box>
            <pen lineWidth="1.0" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 2_TH" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 2_CH" mode="Opaque" backcolor="#FFBFBF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <subDataset name="Table Dataset 1" uuid="431badd4-ba6e-4e50-b1bb-5ee1561a9ede">
        <field name="question_Text" class="java.lang.String"/>
        <field name="Option_A" class="java.lang.String"/>
        <field name="Option_B" class="java.lang.String"/>
        <field name="Option_C" class="java.lang.String"/>
        <field name="Option_D" class="java.lang.String"/>
        <field name="Question_Image" class="net.sf.jasperreports.engine.JasperReport"/>
        <field name="Option_Image" class="net.sf.jasperreports.engine.JasperReport"/>
        <field name="qno" class="java.lang.String"/>
        <field name="Option_Image_DS" class="java.lang.Object"/>
        <field name="Question_Image_DS" class="java.lang.Object"/>
    </subDataset>
    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
        <defaultValueExpression><![CDATA["C:\kaleido\reports\"]]></defaultValueExpression>
    </parameter>
    <group name="questionGroup" minHeightToStartNewPage="500">
        <groupHeader>
            <band height="1"/>
        </groupHeader>
        <groupFooter>
            <band/>
        </groupFooter>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="34">
            <componentElement>
                <reportElement uuid="dba40d4d-4645-4535-8e00-410b0a908427" key="table" style="table" stretchType="RelativeToTallestObject" x="13" y="1" width="406" height="30" isPrintWhenDetailOverflows="true"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="Table Dataset 1" uuid="ac0aea8f-e76b-4e8a-9809-76001090b698">
                        <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
                    </datasetRun>
                    <jr:column uuid="14afe5bf-61c1-4060-b192-c5792c0d4b81" width="447">
                        <jr:detailCell style="table_TD" height="64" rowSpan="1">
                            <textField isBlankWhenNull="true">
                                <reportElement uuid="0ec65756-086b-40f3-88f9-2ee9852b7811" stretchType="RelativeToTallestObject" x="20" y="0" width="427" height="39" isPrintWhenDetailOverflows="true"/>
                                <box bottomPadding="1"/>
                                <textElement markup="html">
                                    <font fontName="Calibri"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{question_Text}]]></textFieldExpression>
                            </textField>
                            <textField>
                                <reportElement uuid="a59d8b1f-b6b0-41de-b199-ce5d9ede41a8" x="0" y="0" width="20" height="39"/>
                                <textElement>
                                    <font fontName="Calibri"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$F{qno}]]></textFieldExpression>
                            </textField>
                            <subreport>
                                <reportElement uuid="ac3f47f7-a4ed-4146-b829-4ffb63662545" stretchType="RelativeToBandHeight" x="0" y="39" width="447" height="21" isPrintWhenDetailOverflows="true"/>
                                <dataSourceExpression><![CDATA[$F{Question_Image_DS}]]></dataSourceExpression>
                                <subreportExpression><![CDATA[$F{Question_Image}]]></subreportExpression>
                            </subreport>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column uuid="d423ed3e-c382-4acf-9013-3943a1de6d7b" width="79">
                        <jr:detailCell style="table_TD" height="64" rowSpan="1">
                            <rectangle>
                                <reportElement uuid="1e724ee4-697b-4a2a-bb3e-9fccc07c4d6a" x="6" y="10" width="45" height="40"/>
                            </rectangle>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
</jasperReport>
 
 
And  Second 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="NRWorksheet_QuestionImageSub" language="groovy" pageWidth="440" pageHeight="802" columnWidth="440" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Empty" uuid="f5e6d870-ccce-4e68-a34c-90b1c7ddd047">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#FFBFBF">
        <box>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <subDataset name="Table Dataset 1" uuid="1a9a15c5-af52-4e59-bc4a-0fb03a254c08">
        <field name="image" class="java.awt.image.BufferedImage"/>
    </subDataset>
    <field name="F_QN_IMAGE" class="java.awt.image.BufferedImage"/>
    <field name="F_OPTION_IMAGE" class="java.awt.image.BufferedImage"/>
    <field name="F_OPTION_A" class="java.lang.String"/>
    <field name="F_OPTION_B" class="java.lang.String"/>
    <field name="F_OPTION_C" class="java.lang.String"/>
    <field name="F_OPTION_D" class="java.lang.String"/>
    <group name="Header" minHeightToStartNewPage="5" keepTogether="true">
        <groupHeader>
            <band height="5"/>
        </groupHeader>
        <groupFooter>
            <band height="5"/>
        </groupFooter>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="61">
            <printWhenExpression><![CDATA[$F{F_QN_IMAGE}!=null]]></printWhenExpression>
            <image scaleImage="RealHeight">
                <reportElement uuid="d7f53135-8174-41ef-9545-4f25a107fc18" positionType="Float" stretchType="RelativeToTallestObject" x="23" y="7" width="408" height="50" isPrintWhenDetailOverflows="true"/>
                <imageExpression><![CDATA[$F{F_QN_IMAGE}]]></imageExpression>
            </image>
        </band>
        <band height="58">
            <printWhenExpression><![CDATA[$F{F_OPTION_IMAGE}==null]]></printWhenExpression>
            <textField isStretchWithOverflow="true">
                <reportElement uuid="c3069f44-b9f6-48ce-9334-45ca5ef362f4" positionType="Float" stretchType="RelativeToTallestObject" x="23" y="3" width="200" height="26" isPrintWhenDetailOverflows="true"/>
                <textElement>
                    <font fontName="Calibri"/>
                </textElement>
                <textFieldExpression><![CDATA["A. "+ $F{F_OPTION_A}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement uuid="de3388c9-2852-43f1-987e-206f622e4efd" positionType="Float" stretchType="RelativeToTallestObject" x="234" y="3" width="200" height="26" isPrintWhenDetailOverflows="true"/>
                <textElement>
                    <font fontName="Calibri"/>
                </textElement>
                <textFieldExpression><![CDATA["B. "+$F{F_OPTION_B}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement uuid="1eabff07-a2a3-4fa1-8e05-82ae77c0bfef" positionType="Float" stretchType="RelativeToTallestObject" x="234" y="32" width="200" height="26" isPrintWhenDetailOverflows="true"/>
                <textElement>
                    <font fontName="Calibri"/>
                </textElement>
                <textFieldExpression><![CDATA["D. "+$F{F_OPTION_D}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement uuid="31756620-5834-4fe7-b55a-c7ed963867a9" positionType="Float" stretchType="RelativeToTallestObject" x="23" y="32" width="200" height="26" isPrintWhenDetailOverflows="true"/>
                <textElement>
                    <font fontName="Calibri"/>
                </textElement>
                <textFieldExpression><![CDATA["C. "+$F{F_OPTION_C}]]></textFieldExpression>
            </textField>
        </band>
        <band height="53">
            <printWhenExpression><![CDATA[$F{F_OPTION_IMAGE}!=null]]></printWhenExpression>
            <image scaleImage="RealHeight">
                <reportElement uuid="ab15cf47-0a5f-4b7c-9b51-b8ace77931eb" stretchType="RelativeToTallestObject" x="23" y="3" width="408" height="50" isPrintWhenDetailOverflows="true"/>
                <imageExpression><![CDATA[$F{F_OPTION_IMAGE}]]></imageExpression>
            </image>
        </band>
    </detail>
</jasperReport>
 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...