Jump to content
We've recently updated our Privacy Statement, available here ×

Subreport not inserted


abdujaparov

Recommended Posts

Hi,

I have 3 jasper files, a main report and two sub report.

I created a java class that create a jrprint file.

So I have this code:

Class.forName(DRIVER);
        Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);

              FileInputStream subDesign1=new FileInputStream(subReport1);
              JasperReport subReport1J=(JasperReport)JRLoader.loadObject(subDesign1);
       
        FileInputStream subDesign2=new FileInputStream(subReport2);
        JasperReport subReport2J=(JasperReport)JRLoader.loadObject(subDesign2);
       

        FileInputStream jasperDesign=new FileInputStream(mainReport);
        JasperReport jasperReport=(JasperReport)JRLoader.loadObject(jasperDesign);
       
        parameters = new HashMap();
        parameters.put("subReportGestore", subReport2J);
        parameters.put("subReportFondi", subReport1J);
       
       
       
                JasperFillManager.fillReportToFile(jasperReport, "/findb/sw/fin/java/CreateReportCPPI/build/reports/Excel.jrprint", parameters, conn);

 

In this way I have only the jrprint of the main report and the file generated from the jrprint contain only the main report the subreport are not inserted in the main.

How can I fill the main raport with the subreport?

Thanks, bye bye.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi,

I read it, but I don't understand what I wrong.

I have the jasper file and I pass the jasper files to the mainreport.

But I also tried to pass the jrxml files and the problem is the same.

Now. I don't pass the subreport dir, I pass directly the comple path to the subreport jasper (or jrxml) file.

Here subReport1 there is the complete path of the first subreport.

In the main report I inserted this xml code:

    <parameter name="subReportGestore" class="java.lang.Object"/>

......

......

                <subreport  isUsingCache="true">
                    <reportElement
                        x="1"
                        y="5"
                        width="534"
                        height="126"
                        key="subreport-1"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>   
                    <subreportExpression  class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{subReportGestore}]]></subreportExpression>
                </subreport>

I inserted the parameter of the object subreport and then the subreport.

The subreport has the same connection of the main report.

The main report contrains a query and the subreport contrains another query.

So how can I load correctly the subreport?

I read the link you passed but I don't understand what is wrong.

Thanks, bye bye.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...