ktrinad Posted August 31, 2006 Share Posted August 31, 2006 By: Darren - darren2003 Sub-Report Example 2003-02-28 04:45 Did anyone can post sub-report example to here? becoz I still do not understand the detail setting in sub-report, thank you! By: Giulio Toffoli - gt78 RE: Sub-Report Example 2003-02-28 06:16 This post is material that I have sended more than two weeks ago to Shailesh Kadam to write a subreport tutorial... This is not a tutorial, but a stating point that can help you... Giulio __________________________________________- Instructions: What I send to you: 1. master_example.xml (the master report) 2. subreport_example.xml (the subreport) Note the parameter named SUBREPORT_FILE_NAME in master_example.xml: the expression is the name of the subreport file. This is the trick that use iReport to find your self the subreport. (the name SUBREPORT_FILE_NAME is only evocative bat you can change it...) Also the step that you must fallow to create a subreport.... In the master document: 1. Create a parameter in wich store the file name (fully qualified by path, i.e. c:mypathtosubreport.jasper) called i.e. SUBREPORT_FILE_NAME. 2. Add a subreport element. 3. Set in the tab named subreport1 in the element properties dialog for the subreport element added to the document this values: a) set Connection/Datasource Expression to "Use connectiopn Expression" b) set as expression the built in barameter: $P{REPORT_CONNECTION} 4. Set in the tab named subreport2 in the element properties dialog for the subreport element added to the document this values: a) set Subreport Expression Class to class java.lang.String b) set Subreport Expression to $P{SUBREPORT_FILE_NAME} c) add a new subreport parameter (right click on the subreport parameters list to open the contextual menu) - Set ADDRESSID as subreport parameters name - Set a field of the local document as value for this parameter (in your case, we are linking addresses [master_example] with documents totals è´¡ble documents] where addressid in documents is equal to the id of the address record.) We have finished with the master. Go to setting subreport_example. 1. Create a parameter (that will recive the ID value of the parent) named ADDRESSID (the type must be Integer due to the ID value in the parent is a integer). 2. Adjust report query writing something like SELECT * FROM DOCUMENT WHERE ADDRESSID = $P{ADDRESSID} 3. Compile only the file due to create a file jasper, that will used by the master report. Now, return to the master report, compile it and create the pdf. Remember to leave blank the query field in the compiler form. I'm missing database connection config: they are the parameters to use creating a connection to the HSQL database shipped with jasperreports...(you must use iR 0.0.8) DATABASE= DRIVER=org.hsqldb.jdbcDriver NAME=JR_SampleDB PASSWORD= SAVE=false URL=jdbc:hsqldb:C:\Documenti\progetti\iReport\jasperreports-0.4.5-project\JasperReports\demo\hsqldb/test USERNAME=sa You have to replace C:\Documenti\progetti\iReport\jasperreports-0.4.5-project\JasperReports\demo\ with your path to the hsqldb directory... We have finished. In the zip you will find the pdf generated. In this mail I have underlined to you only the most relevant steps, I have not speak about reading fields form db, etc.. that are argoments that I assume already clear... Good Look Giulio _____ MASTER_EXAMPLE.XML <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="Untitled_report_1" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <parameter name="SUBREPORT_FILE_NAME" isForPrompting="true" class="java.lang.String"> <defaultValueExpression><![CDATA["C:\Documenti\progetti\iReport\tmp\subreport_example.jasper"]]></defaultValueExpression> </parameter> <queryString><![CDATA[ select * from address ]]></queryString> <field name="ID" class="java.lang.Integer"/> <field name="FIRSTNAME" class="java.lang.String"/> <field name="LASTNAME" class="java.lang.String"/> <field name="STREET" class="java.lang.String"/> <field name="CITY" class="java.lang.String"/> <variable name="test" class="java.lang.String" resetType="None" calculation="Nothing"> <variableExpression><![CDATA["test"]]></variableExpression> <initialValueExpression><![CDATA["test" ]]></initialValueExpression> </variable> <title> <band height="34"> <staticText> <reportElement mode="Transparent" x="61" y="5" width="412" height="29" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Center" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="24" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[Master report]]></text> </staticText> <line direction="TopDown"> <reportElement mode="Opaque" x="0" y="34" width="534" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" /> </line> <line direction="TopDown"> <reportElement mode="Opaque" x="0" y="3" width="534" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" /> </line> </band> </title> <pageHeader> <band height="9"> </band> </pageHeader> <columnHeader> <band height="0"> <line direction="BottomUp"> <reportElement mode="Opaque" x="0" y="0" width="535" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </line> </band> </columnHeader> <detail> <band height="145"> <rectangle radius="5" > <reportElement mode="Transparent" x="1" y="9" width="535" height="97" forecolor="#808080" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </rectangle> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="93" y="17" width="429" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.Integer"><![CDATA[$F{ID}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Transparent" x="10" y="17" width="83" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[iD]]></text> </staticText> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="93" y="34" width="429" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{FIRSTNAME}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Transparent" x="10" y="34" width="83" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[FIRSTNAME]]></text> </staticText> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="93" y="51" width="429" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{LASTNAME}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Transparent" x="10" y="51" width="83" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[LASTNAME]]></text> </staticText> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="93" y="68" width="429" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{STREET}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Transparent" x="10" y="68" width="83" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[sTREET]]></text> </staticText> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="93" y="85" width="429" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{CITY}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Transparent" x="10" y="85" width="83" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[CITY]]></text> </staticText> <subreport isUsingCache="true"> <reportElement mode="Opaque" x="-1" y="108" width="535" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <subreportParameter name="ADDRESSID"> <subreportParameterExpression><![CDATA[ $F{ID} ]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[ $P{REPORT_CONNECTION} ]]></connectionExpression> <subreportExpression class="java.lang.String"><![CDATA[ $P{SUBREPORT_FILE_NAME} ]]></subreportExpression> </subreport> <line direction="TopDown"> <reportElement mode="Opaque" x="0" y="127" width="534" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="Float" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" /> </line> <staticText> <reportElement mode="Opaque" x="10" y="1" width="54" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[Address]]></text> </staticText> </band> </detail> <columnFooter> <band height="0"> </band> </columnFooter> <pageFooter> <band height="27"> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="325" y="4" width="174" height="19" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Right" verticalAlignment="Top" lineSpacing="Single"> <font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" > <reportElement mode="Transparent" x="499" y="4" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> <line direction="TopDown"> <reportElement mode="Opaque" x="1" y="3" width="535" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" /> </line> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="1" y="6" width="209" height="19" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="Times-Roman" pdfFontName="Times-Roman" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="0"> </band> </summary> </jasperReport> _____SUBREPORT_EXAMPLE.XML________ <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="SRWGCantieriProroghe" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="535" pageHeight="782" columnWidth="516" columnSpacing="0" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <parameter name="ADDRESSID" isForPrompting="true" class="java.lang.Integer"/> <queryString><![CDATA[ SELECT * FROM DOCUMENT WHERE ADDRESSID = $P{ADDRESSID} ]]></queryString> <field name="ID" class="java.lang.Integer"/> <field name="ADDRESSID" class="java.lang.Integer"/> <field name="TOTAL" class="java.lang.Double"/> <title> <band height="32"> <rectangle> <reportElement mode="Opaque" x="0" y="18" width="535" height="14" forecolor="#C0C0C0" backcolor="#D6D6D6" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="None" fill="Solid" /> </rectangle> <staticText> <reportElement mode="Transparent" x="5" y="19" width="65" height="13" forecolor="#3C5ADC" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Right" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="10" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[Total]]></text> </staticText> <rectangle> <reportElement mode="Transparent" x="0" y="7" width="535" height="11" forecolor="#A0A0A0" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="1Point" fill="Solid" /> </rectangle> <rectangle> <reportElement mode="Transparent" x="0" y="18" width="535" height="14" forecolor="#A0A0A0" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="1Point" fill="Solid" /> </rectangle> <staticText> <reportElement mode="Opaque" x="36" y="2" width="85" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Center" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-BoldOblique" size="10" isBold="true" isItalic="true" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[subreport]]></text> </staticText> </band> </title> <pageHeader> <band height="0"> </band> </pageHeader> <columnHeader> <band height="0"> </band> </columnHeader> <detail> <band height="14"> <rectangle> <reportElement mode="Opaque" x="0" y="0" width="535" height="14" forecolor="#808080" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </rectangle> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="4" y="0" width="116" height="13" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.Double"><![CDATA[$F{TOTAL}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0"> </band> </columnFooter> <pageFooter> <band height="0"> </band> </pageFooter> <summary> <band height="0"> </band> </summary> </jasperReport> By: Darren - darren2003 RE: Sub-Report Example 2003-02-28 21:04 Sorry, Giulio, I follow your instruction and test the example in iReport0.06, but I get some error which is shown as following : dori.jasper.engine.JRException: Could not load object from location : D:ChungJasperReportiReport-0.06subreport_example.jasper <-----my sub-report at dori.jasper.engine.util.JRLoader.loadObjectFromLocation(JRLoader.java:234) at dori.jasper.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:297) at dori.jasper.engine.fill.JRFillBand.evaluate(JRFillBand.java:359) at dori.jasper.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1022) at dori.jasper.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269) at dori.jasper.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:160) at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:421) at dori.jasper.engine.fill.JRFiller.fillReport(JRFiller.java:143) at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:348) at dori.jasper.engine.JasperFillManager.fillReport(JasperFillManager.java:288) at IReportCompiler.main(IReportCompiler.java:154) **Moreover, I want to know how did I compile the sub-report file before I compile the main report Thank you! Giulio By: Giulio Toffoli - gt78 RE: Sub-Report Example 2003-03-01 00:54 1. You should download iReport 0.0.8 and then download the lastest patched version from cvs repository http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ireport/iReport/iReport.exe 2. You must first compile the subreport example report. In this way subreport_example.jasper is created (about the error, I think that you don't have compiled the subreport before launching the master report...) Giulio By: Darren - darren2003 RE: Sub-Report Example 2003-03-02 18:03 Giulio, I've compiled the subreport before, and the jasper file is also created yet, but the above error is displayed. Have any setting of database connection and query before compile? Thank you! By: Giulio Toffoli - gt78 RE: Sub-Report Example 2003-03-03 01:37 1. Test if the subreport run succesfully (you must provide a valid query, i.e. without the portion with parameters, like xxx = $P{XXX}. 2. If the subreport run succesfully, check that the file D:ChungJasperReportiReport-0.06subreport_example.jasper exists. You should not recive this exception (Could not load object from location) if the file really exist at this location. Giulio By: Darren - darren2003 RE: Sub-Report Example 2003-03-03 01:57 I already compile the subreport successfully, and I also find the jasper exists, but I started to compile the master report will display the above error ( I leave blank the query field in the compiler form and my connection in the compiler form is "no connection"), is it right? Giulio By: Giulio Toffoli - gt78 RE: Sub-Report Example 2003-03-03 02:02 No, you should specify a connection, but leave the field of the query blank. But, this is not the cause of your problem. D:ChungJasperReportiReport-0.06subreport_example.jasper Are you sure that the name is "iReport-0.06"? I think that the name is "iReport-0.0.6" (please note the dot before the number 6. If this is the root of your problem I go at your home and I kill it!!!!!! Giulio By: Darren - darren2003 RE: Sub-Report Example 2003-03-03 02:08 Sorry!Sorry!Sorry!Sorry!, Giulio you are right, is that problem (I miss the dot), I'll go to die (don't kill me) But I specify a connection, I have another error, this will shown as following : org.gjt.mm.mysql.jdbc2.NotImplemented at org.gjt.mm.mysql.jdbc2.ResultSet.getStatement(ResultSet.java:1979) at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:381) at dori.jasper.engine.fill.JRFillSubreport.run(JRFillSubreport.java:380) at java.lang.Thread.run(Thread.java:536) NESTED BY : dori.jasper.engine.JRException: Error closing ResultSet or Statement for report data source : SRWGCantieriProroghe at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:390) at dori.jasper.engine.fill.JRFillSubreport.run(JRFillSubreport.java:380) at java.lang.Thread.run(Thread.java:536) Caused by: org.gjt.mm.mysql.jdbc2.NotImplemented at org.gjt.mm.mysql.jdbc2.ResultSet.getStatement(ResultSet.java:1979) at dori.jasper.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:381) ... 2 more Thank you, Giulio! By: Giulio Toffoli - gt78 RE: Sub-Report Example 2003-03-03 02:20 Yes, this could be a bug in jasperreports 0.4.5 (but I'm not sure). The problem was discovered in MS SQLServer and not in MySQL but I think that the cause could be the same. Workarounds: 1. apply this patch and recompile jsaperreports: http://sourceforge.net/tracker/index.php?func=detail&aid=681655&group_id=36382&atid=416705 2. use a prior version of jasperreports 3. Give me your email. I'll post you an already patched version of jasperreports.jar. Giulio By: Darren - darren2003 RE: Sub-Report Example 2003-03-03 02:24 My e-mail address : darren@logicsystem.com.hk Thank you, Giulio!!! By: ramesh - rbkannan RE: Sub-Report Example 2003-06-16 22:12 hi Giulio, can you also forward the patched version to me, as i'm having the same problems. my email id is rbkannan@yahoo.com thanks. Ramesh By: Giulio Toffoli - gt78 RE: Sub-Report Example 2003-06-17 01:11 The jasperreports.jar shipped with iReport 0.1.0 and in 0.2.0 is already patched. Giulio Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now