如何打印拆分为多个页面的列

时间:2016-06-30 06:03:28

标签: jasper-reports

我的报告有5 columns。 我想将其分为2 pages

Page APage B

Page A将是这样的:

|| No  || Col 1  || Col 2 || Col 3 || 
------------------------------------- 
||  1  ||        ||       ||       ||
||  2  ||        ||       ||       ||

虽然Page B会是这样的:

|| No || Col 4 || Col 5 ||
--------------------------
|| 1  ||       ||       ||
|| 2  ||       ||       ||

因此,每次打印时,我都希望页面显示ABABAB。 我试图做两份报告。

第一份报告包含Page A,第二份报告包含Page B。 我将Subreport放在第一份报告中,该报告与第二份报告相关联。

但是,当我打印时,打印的页面就像AAAABBBB

如何将打印页面设置为ABABAB

1 个答案:

答案 0 :(得分:0)

好问题。你有源代码/模型吗?你是如何为数据库建模的? 我将样品模型放在下面以供参考。

public class DataBean {
       private String name;
       private String school;
       private List<SubReportBean> subReportBeanList;
//getters and setters

}


public class SubReportBean {

       private String address;
       private String city;
       //getter and setter
}

public class DataBeanList {
       public ArrayList<DataBean> getDataBeanList() {

          // Create sub report data
          SubReportBean subBean1 = new SubReportBean();
          //set subbean1
          SubReportBean subBean2 = new SubReportBean();
         //set subbean2
          SubReportBean subBean3 = new SubReportBean();
          //set subbean3

          ArrayList<DataBean> dataBeanList = new ArrayList<DataBean>();

          // Create master report data
          dataBeanList.add(generate("John", "xyz school",
             Arrays.asList(subBean1)));
          dataBeanList.add(generate("somename", "nice school",
             Arrays.asList(subBean2)));
          dataBeanList.add(generate("somename1", "cA school",
             Arrays.asList(subBean1)));


          return dataBeanList;
       }


       private DataBean generate(String name, String school,
          List<SubReportBean> subBean) {
          DataBean dataBean = new DataBean();

          dataBean.setName(name);
          dataBean.setSchool(school);
          dataBean.setSubReportBeanList(subBean);

          return dataBean;
       }
    }