简体   繁体   English

DynamicJasper-不显示子报表

[英]DynamicJasper - subreport not displaying

i'm new to DynamicJasper. 我是DynamicJasper的新手。

I'm building a report that contain a subreport, i can run my original report successfully without any error, but the subreport is not displaying. 我正在构建一个包含子报表的报表,我可以成功运行我的原始报表而没有任何错误,但是该子报表没有显示。

I'm using DynamicReportBuilder(drb) for building my main report, i'm wondering i'm adding my subreport in the wrong way. 我正在使用DynamicReportBuilder(drb)构建主报表,我想知道我以错误的方式添加了子报表。

Below is how i build my subreport 以下是我建立子报表的方式

private DynamicReport subReportTesting() throws Exception 
{

      DynamicReportBuilder drb = new DynamicReportBuilder();
      DynamicReport dr = drb.addColumn(subAbstractColumn1)
            .addColumn(subAbstractColumn2)
            .addColumn(subAbstractColumn3)
            .setPrintColumnNames(true)
            .setIgnorePagination(true)
            .setMargins(0, 0, 0, 0) 
            .setTitle("Sales Report") 
            .setSubtitle("This report was generated at " + new Date()) 
            .setUseFullPageWidth(true)
            .build();

    return dr;

}

and here is how i add my main report and subreport. 这是我添加主报告和子报告的方式。

public DynamicReport buildReport() throws Exception {
{

     DynamicReportBuilder drb = new DynamicReportBuilder();
     drb.setTitle("This is original report")
        .setSubtitle("This is subtitle")            
        .setMargins(15, 15, 15, 15)
        .setUseFullPageWidth(true);
        .setDetailHeight(30);
        .setAllowDetailSplit(true);
        .addColumn(mainAbstractColumn1);
        .addColumn(mainAbstractColumn2);
        .addColumn(mainAbstractColumn3);

     DynamicReport myDynamicReport = new DynamicReport();

        try {
            myDynamicReport = subReportTesting();
        } catch (Exception e) {
            e.printStackTrace();
        }

        SubReportBuilder srb = new SubReportBuilder();
        srb.setDynamicReport(myDynamicReport, new ClassicLayoutManager());

        try {
            mySubReport = srb.build();

            **drb.addConcatenatedReport(mySubReport);**

          } catch (DJBuilderException e) {
              e.printStackTrace();
          }
       DynamicReport myMainReport = drb.build();

       return myMainReport;
}

My contents is add by using preparedStatement and HashMap. 我的内容是通过使用prepareStatement和HashMap添加的。
I expect the subreport will display it's title, subtitle and column header even there is no data to be show in the subreport's content, but currently it show nothing about the subreport. 我希望子报表将显示其标题,副标题和列标题,即使在子报表的内容中没有要显示的数据,但当前它不显示任何有关子报表的信息。

Please correct me if i make any mistake. 如果我有任何错误,请纠正我。 Thank you so much. 非常感谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM