ilogs Posted June 18, 2007 Share Posted June 18, 2007 Hi, Im using jasper reports withing java and created my reports my ireport. It all works fine, until I have tried to use subreports. I do a select * form tab; and for each table I want to count the rows. The report works inside iReport 1.3.2, but using the following statemnts, it seems that the parameter for the table name is not filled. Other reports without subreports work fine in my environment. In Java I do:: public void test() throws Exception { JasperReport rep=(JasperReport)JRLoader.loadObject("./var/jasper/seltab_count_all_sub_mit_selstern.jasper"); Map params=new HashMap(); JasperPrint jasperPrint = JasperFillManager.fillReport(rep, params, SQLBroker.getConnection()); JRExporter exporter=new JRPdfExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"all.pdf"); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); exporter.exportReport(); } The output looks like : table1table2talbe3 but it should contain a count(*) for each table (which works fine within iReport): table120table2454table30 I appreciate any help! Walter Here are the files generated by iReport: The mainreports looks like this: <?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="seltab_count_all_sub_mit_selstern" 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"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <queryString><![CDATA[select * from tab where tname like 'AVW_%']]></queryString> <field name="TNAME" class="java.lang.String"/> <field name="TABTYPE" class="java.lang.String"/> <field name="CLUSTERID" class="java.math.BigDecimal"/> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="50" isSplitAllowed="true" > <staticText> <reportElement x="36" y="5" width="437" height="40" key="staticText"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Center"> <font size="14" isBold="true"/> </textElement> <text><![CDATA[avw tables and number of entries]]></text> </staticText> <line direction="TopDown"> <reportElement x="0" y="48" width="534" height="0" forecolor="#000000" key="line" positionType="FixRelativeToBottom"/> <graphicElement stretchType="NoStretch" pen="2Point"/> </line> <line direction="TopDown"> <reportElement x="0" y="3" width="534" height="0" forecolor="#000000" key="line"/> <graphicElement stretchType="NoStretch" pen="2Point"/> </line> </band> </title> <pageHeader> <band height="15" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="1" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="29" isSplitAllowed="true" > <textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="8" width="195" height="15" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" leftPadding="2" rightBorder="None" rightBorderColor="#000000" rightPadding="2" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font fontName="Times-Roman" size="12"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{TNAME}]]></textFieldExpression> </textField> <subreport isUsingCache="true"> <reportElement x="210" y="8" width="136" height="15" key="subreport-1"/> <subreportParameter name="tablename"> <subreportParameterExpression><![CDATA[$F{TNAME}]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression class="java.io.InputStream"><![CDATA[com.iLogs.wf.reporting.dms.SwitchingReportProvider.getInstance().getReport("./selstern.jasper")]]></subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="27" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="325" y="4" width="170" height="19" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Right"> <font fontName="Helvetica" size="10"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression> </textField> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="499" y="4" width="36" height="19" forecolor="#000000" backcolor="#FFFFFF" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> <font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> <line direction="TopDown"> <reportElement x="0" y="1" width="535" height="0" forecolor="#000000" key="line"/> <graphicElement stretchType="NoStretch" pen="2Point"/> </line> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="1" y="6" width="209" height="19" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font fontName="Times-Roman" size="10"/> </textElement> <textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary></jasperReport> The subreport like this: <?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="selstern" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="782" pageHeight="595" columnWidth="782" columnSpacing="0" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <property name="ireport.scriptlethandling" value="0" /> <property name="ireport.encoding" value="UTF-8" /> <import value="java.util.*" /> <import value="net.sf.jasperreports.engine.*" /> <import value="net.sf.jasperreports.engine.data.*" /> <parameter name="tablename" isForPrompting="true" class="java.lang.String"> <defaultValueExpression ><![CDATA[new String("avw_stepinstance")]]></defaultValueExpression> </parameter> <queryString><![CDATA[select count(*) from $P!{tablename}]]></queryString> <field name="COUNT(*)" class="java.math.BigDecimal"/> <background> <band height="0" isSplitAllowed="true" > </band> </background> <title> <band height="0" isSplitAllowed="true" > </band> </title> <pageHeader> <band height="0" isSplitAllowed="true" > </band> </pageHeader> <columnHeader> <band height="0" isSplitAllowed="true" > </band> </columnHeader> <detail> <band height="19" isSplitAllowed="true" > <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > <reportElement x="0" y="0" width="118" height="17" forecolor="#000000" key="textField"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <textElement> <font size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{COUNT(*)}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0" isSplitAllowed="true" > </band> </columnFooter> <pageFooter> <band height="0" isSplitAllowed="true" > </band> </pageFooter> <summary> <band height="0" isSplitAllowed="true" > </band> </summary></jasperReport> Thanks for any help! Walter 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