在jaspersoft中创建连续表 [英] Create consecutive tables in jaspersoft

查看:560
本文介绍了在jaspersoft中创建连续表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是JasperReports,我找不到创建连续表格的方法。当第一个被填写时,下一个将被覆盖而不是被移位。

I am using JasperReports and I cannot find the way to create consecutive tables. When the first one is filled in, the next one will cover it instead of being shifted.

之前有没有人遇到过这个问题?

Did anyone face this problem before?

更新

我在每个细节带中使用带有两个细节带和一个表的子报告。

I am using the subreport with two detail bands and one table into each of the detail bands.

到目前为止,我生成了父报告的页面,但子报告区域是空白的。

So far I generate the page for the parent report but the subreport area is blank.

这是代码所在我与报告互动:

This is the code where I interact with the reports:

try {

    HashMap param = new HashMap();

    JRBeanCollectionDataSource tableA = new JRBeanCollectionDataSource(tableAItems);
    param.put("AtableDatasource", tableA);
    JRBeanCollectionDataSource tableB = new JRBeanCollectionDataSource(tableBItems);
    param.put("BtableDatasource", tableB);
    param.put("tableHeadA","TABLE A HEADER");
    param.put("column1AHead","A COL 1");
    param.put("column2AHead","A COL 2");
    param.put("column3AHead","A COL 3");
    param.put("header","SAMPLE REPORT");
    param.put("theDetails", "THE DETAILS");
    param.put("detail1Label", "DETAIL BAND 1");
    param.put("detail2Label", "DETAIL BAND 2");

    InputStream parent = Main.class.getResourceAsStream("/sample_parent.jasper");
    JasperPrint jpParent = JasperFillManager.fillReport(parent, param, new JREmptyDataSource(1));

    JasperExportManager.exportReportToPdfFile(jpParent, "C:\\REPORTS\\sampleReport.pdf");


} catch (JRException e) {
    e.printStackTrace();
}

像往常一样,示例代码上传到下面链接的GitHub仓库。

As usual, the sample code is uploaded to the GitHub repo linked below.

GitHub回购: https://github.com /MichaelKnight/jaspertest.git

GitHub repo: https://github.com/MichaelKnight/jaspertest.git

推荐答案

您的直接问题是包含的框架jr:table 没有 positionType =float,你已将它设置为 jr:table 但你需要将其设置为框架。)

Your immediate problem is that the frame containing the jr:table does not have positionType="float", you have set it to the jr:table but you need to set it to frame).

然而,为了更好地控制和实现所需的布局(因为你有桌子)在右边),考虑创建2个子报告。

However to better control and achieve your desired layout (since you have tables to the right), consider to create 2 subreport.

传递给子报告 new JREmptyDataSource(1)作为数据源生成1条记录详细信息带和参数图,在子报表中获取参数 $ P {B3questionsDatasource} 等。

Pass to subreport new JREmptyDataSource(1) as datasource to generate 1 record detail band and your parameter map, to get parameter $P{B3questionsDatasource} etc. in your subreport.


  1. 子报告,包含图片中的表A,B,要么将它们放在彼此之下,要么使用多个细节带

  1. subreport, containing the table A,B in image, either put them on below each other or use multiple detail band's

<detail>
  <band height="50">
      ... table 1 ....
  </band>
  <band height="50">
      ... table 2 ....
  </band>
</detail>


  • 子报告,表C和新表D(如上例所示。)

  • sub report, with table C and new table D (as in example above).

    主报告中包含每个子报表旁边的子报表其他。

    In main report included the subreport's on next to each other.

    示例

    <subreport>
       <reportElement x="0" y="20" width="400" height="20" uuid="a7a89ebb-54d4-4b6e-8c9f-c107e8a40bbb"/>
        <parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
        <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource(1)]]></dataSourceExpression>
        <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subreport1.jasper"]]></subreportExpression>
    </subreport>
    

    这篇关于在jaspersoft中创建连续表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆