Subreports in Jasper Reports

前端 未结 3 855
迷失自我
迷失自我 2021-01-07 03:59

I have two tables to be printed in same page. Data for those tables will be supplied from a map from a custom data source. I need to implement it. I googled for implementing

相关标签:
3条回答
  • 2021-01-07 04:29

    Sub reports are just like any other normal reports. They have own JRXML file and use own data sources. You can invoke the subreport alone or inside a master report, using the sub report tool. The data source in this case is specified in the master JRXML, the sub report properties dialog, Subreport tab, and it is different than the master's report data source.

    I don't completely understand what are you trying to do, but you can also supply parameters to the sub report, so it filters its data based on the current row from the master table.

    0 讨论(0)
  • 2021-01-07 04:31

    I posted the answer for the similar question. You can check the answer here.

    Using iReport with eclipse to generate reports approperly

    0 讨论(0)
  • 2021-01-07 04:41

    If you have only one detail band and your subreportExpression is something like "SUBREPORT_1.jasper" you can use this to compile several subreports

       JRDesignBand jrBand = (JRDesignBand) jasperDesign.getDetailSection().getBands()[0];
       JRElement[] jrElements = jrBand.getElements();
       for (JRElement jrElement : jrElements) {
           if (jrElement instanceof JRDesignSubreport) {
           JRDesignSubreport subReportDesign = (JRDesignSubreport) jrElement;
           JRExpression jrExpression = subReportDesign.getExpression();
           String file = jrExpression.getText();
           file = file.substring(1, file.length()-8)+".jrxml";
           JasperCompileManager.compileReport(file);
           }
       }
    
    0 讨论(0)
提交回复
热议问题