2005 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: anna - annashekhtman problems with subreport 2004-06-14 03:32 I'm trying to cretae a master report with sub report. It compiles okay, but I get just fields from master report and can't see fields from sub report. Please advise what is wrong. my mainreport is: <?xml version="1.0"?> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="MainReport" pageWidth="595" pageHeight="842" columnWidth="515" columnSpacing="0" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50"> <reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isItalic="true" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <parameter name="ReportTitle" class="java.lang.String"/> <parameter name="BaseDir" class="java.io.File"/> <parameter name="TestSubReport" class="dori.jasper.engine.JasperReport"/> <queryString><![CDATA[select * from employee ]]></queryString> <field name="id" class="java.lang.Integer"/> <title> <band height="50"> <line><reportElement x="0" y="0" width="950" height="0"/> <graphicElement stretchType="NoStretch"/> </line> <textField isBlankWhenNull="true"> <reportElement x="0" y="10" width="165" height="30"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Normal" size="22"/> </textElement> <textFieldExpression class="java.lang.String">$P{ReportTitle}</textFieldExpression> </textField> </band> </title> <pageHeader> <band height="20"> <staticText> <reportElement mode="Opaque" forecolor="red" backcolor="#DFDFDF" x="0" y="5" width="100" height="15" /> <textElement> <font reportFont="Arial_Bold" isUnderline="false" isBold="true"/> </textElement> <text>bbbbbb</text> </staticText> <subreport isUsingCache="true"> <reportElement x="205" y="25" width="325" height="20" backcolor="blue" isPrintRepeatedValues="false" isPrintWhenDetailOverflows="false" isRemoveLineWhenBlank="true"/> </band> </pageHeader> <detail> <band height="15"> <textField> <reportElement x="0" y="5" width="50" height="15" /> <textFieldExpression class="java.lang.Integer"> $F{id} </textFieldExpression> </textField> <subreportParameter name="id"> <subreportParameterExpression> $F{id} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{REPORT_CONNECTION} </connectionExpression> <subreportExpression class="dori.jasper.engine.JasperReport"> $P{TestSubReport} </subreportExpression> </subreport> </band> </detail> </jasperReport> and my sub report is: <?xml version="1.0"?> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="SubReport" pageWidth="595" pageHeight="842" columnWidth="515" columnSpacing="0" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50"> <reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isItalic="true" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <parameter name="ReportTitle" class="java.lang.String"/> <parameter name="BaseDir" class="java.io.File"/> <parameter name="id" class="java.lang.Integer"></parameter> <queryString><![CDATA[select * from address WHERE id= $P{id}]]></queryString> <field name="id" class="java.lang.Integer"/> <field name="city" class="java.lang.String"/> <field name="state" class="java.lang.String"/> <title> <band height="50"> <line> <reportElement x="0" y="0" width="950" height="0"/> <graphicElement stretchType="NoStretch"/> </line> <textField isBlankWhenNull="true"> <reportElement x="0" y="10" width="165" height="30"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Normal" size="22"/> </textElement> <textFieldExpression class="java.lang.String">$P{ReportTitle}</textFieldExpression> </textField> </band> </title> <pageHeader> <band height="20"> <staticText> <reportElement mode="Opaque" forecolor="blue" backcolor="#DFDFDF" x="200" y="15" width="100" height="15" /> <textElement> <font reportFont="Arial_Bold" isUnderline="false" isBold="true"/> </textElement> <text>city</text> </staticText> </band> </pageHeader> <detail> <band height="15"> <textField> <reportElement x="200" y="15" width="100" height="15" /> <textFieldExpression class="java.lang.String"> $F{city} </textFieldExpression> </textField> <textField> <reportElement x="300" y="15" width="100" height="15" /> <textFieldExpression class="java.lang.String"> $F{state} </textFieldExpression> </textField> </band> </detail> </jasperReport> Thanks 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