2004 IR Help Posted August 23, 2006 Share Posted August 23, 2006 By: dave - davedave99 Basic Sub Report 2005-08-23 06:40 Hi there, I am having some problems using subReports. I do not get any errors, my main report compiles and exports without any errors. The resulting pdf file does not contain the subreport. I am using jasperreports-0.6.8 and JasperAssistant 1.5.6. Here is the contents of my main.jrxml <?xml version="1.0" encoding="UTF-8"?> <!-- Created using an evaluation version of JasperAssistant (http://www.jasperassistant.com) --> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="main" language="java" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30"> <property name="com.jasperassistant.designer.GridWidth" value="12"/> <property name="com.jasperassistant.designer.GridHeight" value="12"/> <property name="com.jasperassistant.designer.SnapToGrid" value="false"/> <property name="com.jasperassistant.designer.Grid" value="false"/> <detail> <band height="100"> <staticText> <reportElement positionType="Float" x="28" y="9" width="80" height="20"/> <textElement/> <text><![CDATA[main report]]></text> </staticText> <subreport> <reportElement positionType="Float" x="21" y="41" width="495" height="30" backcolor="#555f"/> <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["C:\Program Files\eclipse\workspace\Xml2Pdf\samples\xml\subreport.jasper"]]></subreportExpression> </subreport> </band> </detail> </jasperReport> Here is the contents of my SubReport: <?xml version="1.0" encoding="UTF-8"?> <!-- Created using an evaluation version of JasperAssistant (http://www.jasperassistant.com) --> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="subreport" language="java" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30"> <property name="com.jasperassistant.designer.GridHeight" value="12"/> <property name="com.jasperassistant.designer.GridWidth" value="12"/> <property name="com.jasperassistant.designer.SnapToGrid" value="false"/> <property name="com.jasperassistant.designer.Grid" value="false"/> <detail> <band height="100"> <staticText> <reportElement positionType="Float" x="22" y="15" width="80" height="20" forecolor="#8000ff"/> <textElement/> <text><![CDATA[test]]></text> </staticText> </band> </detail> </jasperReport> And the following is my java code to do the compile, fill and export. String report = "C:\Program Files\eclipse\workspace\Xml2Pdf\samples\xml\main.jrxml"; String compiledReport = "C:\Program Files\eclipse\workspace\Xml2Pdf\samples\xml\main.jasper"; String pdfReport = "C:\Program Files\eclipse\workspace\Xml2Pdf\out\main.pdf"; String subReport = "C:\Program Files\eclipse\workspace\Xml2Pdf\samples\xml\subreport.jrxml"; String compiledSubReport = "C:\Program Files\eclipse\workspace\Xml2Pdf\samples\xml\subreport.jasper"; try { System.out.println(JasperCompileManager.compileReportToFile(subReport)); System.out.println(JasperCompileManager.compileReportToFile(report)); } catch (JRException e) { System.out.println("Problem with compile for file: " + report + e.getMessage()); } System.out.println("Compile Complete!"); try { System.out.println(JasperFillManager.fillReportToFile(compiledReport, null, new JREmptyDataSource())); System.out.println(JasperExportManager.exportReportToHtmlFile("C:\Program Files\eclipse\workspace\Xml2Pdf\samples\xml\main.jrprint")); System.out.println(JasperExportManager.exportReportToPdfFile("C:\Program Files\eclipse\workspace\Xml2Pdf\samples\xml\main.jrprint")); } catch (JRException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } The resulting pdf and html file contains the static text from the main.jrxml but the text from the subreport is missing. Any help is appreciated. Thanks, Dave By: jorge - sirion_oef RE: Basic Sub Report 2005-08-23 16:00 is the only export format that has this error? try increasing the height of your fields, maybe they are there but are too short By: dave - davedave99 RE: Basic Sub Report 2005-08-24 01:45 I exported to HTML and I got the same result. I will adjust the height of the fields and see if that helps. Thanks. By: mlaw93 - mlawson93 RE: Basic Sub Report 2005-09-06 13:09 I am having the same problem, did you ever work it out? By: jorge - sirion_oef RE: Basic Sub Report 2005-09-06 17:09 the params, fields and datasource of the subreport and the report are correct? try recompiling the main report and all the subreports did you changed the way you pass data to your reports but you didn?t change your reports? By: Dejan Nikolic - decky RE: Basic Sub Report 2005-09-07 00:16 In main.jrxml you put width="495" for the subreport, but subreport have pageWidth="595". Those values has to be the same. 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