sarveshawasthi Posted October 28, 2009 Share Posted October 28, 2009 Hi all,I am new in jasper design, now I am trying to add a sub report (.jrxml or .jsper) in our master report (JasperDesign Code) in java class but I am not getting any hint that how I can do it . Can any on please provide me a sample code for my problem.Please do it ASAP, Thank’s in Advance Post Edited by test4only at 10/28/2009 11:49 Link to comment Share on other sites More sharing options...
jvway Posted November 2, 2009 Share Posted November 2, 2009 Look in the subreport example from jasper reports download. In the .java file you'll see an entry like this:JasperReport subreport = (JasperReport)JRLoader.loadObjectFromLocation("ProductReport.jasper");//Preparing parametersMap parameters = new HashMap();parameters.put("ProductsSubreport", subreport);Then in you .jrxml file there will be a section like this. iReport will create this. In iReport the parameter class is net.sf.jasperreports.engine.JasperReport. The subReportParameter Name is the parameter where the data link is passed. This part is from my report since it include the parameter name for the data link between the two. (that and I happened to have it opened :).<band height="27"><subreport><reportElement x="0" y="0" width="572" height="25"/><subreportParameter name="OPPTSOL_LINK"><subreportParameterExpression><![CDATA[$F{oppt_id}]]></subreportParameterExpression></subreportParameter><connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression><subreportExpression class="java.lang.String"><![CDATA["SolutionOverview_Solution1.jasper"]]></subreportExpression></subreport></band>Post Edited by jvway at 11/02/2009 23:32 Link to comment Share on other sites More sharing options...
sarveshawasthi Posted November 5, 2009 Author Share Posted November 5, 2009 Thanks for replay,But this code we can use in our Master.jrxml while designing with ireport or jrxml designing tool. In fact I want to write this code through java code because master report I am designing by the use of JasperDesign API. So further I am requesting to Please Provide the Java Code for Adding The sub report (jasper Or jrxml) file . Thanks Sarvesh Awasthi Send mail me : test4only@gmail.com Link to comment Share on other sites More sharing options...
bninan Posted November 25, 2010 Share Posted November 25, 2010 Hi, Did you find a solution to your problem?I am facing the same issue. Link to comment Share on other sites More sharing options...
hozawa Posted December 19, 2010 Share Posted December 19, 2010 Are you trying to write a Java scriptlet which will add a subreport into your report? Link to comment Share on other sites More sharing options...
asmithndreww Posted July 29, 2011 Share Posted July 29, 2011 hey i am also facing the same problem . getting the given error. net.sf.jasperreports.engine.JRException: Could not load object from location : .\netIncomeStatement_subreport0.jasper when i am execute this report as standalone it works fine. but when i calling from my java code it show the above error.please help me. I am in trouble. regards smith Link to comment Share on other sites More sharing options...
szaharia Posted August 2, 2011 Share Posted August 2, 2011 Hi,Perhaps it's a classpath matter here. When you are running the report from java, the relative path "./" does not point to the same current directory as when running the report from iReport.Try to see which is the current directory when running from java, and set the corect path to the netIncomeStatement_subreport0.jasper object.Hope this helps,sanda Link to comment Share on other sites More sharing options...
davidcurious Posted May 19, 2017 Share Posted May 19, 2017 I think i had an answer for this. But it is some sort temp solution.Basically the fillManager is looking for the compiled object while jrxml is not compiled.So in the SUBREPORT_DIR should look like:class="net.sf.jasperreports.engine.JasperReport" isforprompting="false" name="SUBREPORT_DIR"and the subreportExpression in the subreport tag under main report should be the above SUBREPORT_DIRfor some reason i can not paste my code here, it looks like the HTML editor is messed up here. I am using IE10http://stackoverflow.com/questions/12063947/connect-master-report-and-subreport-passing-list-of-objects-to-subreport 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