【问题标题】:I have the problem with adding datasource to the subreport of my Jasper Report in Java我在用 Java 将数据源添加到 Jasper 报告的子报告时遇到问题
【发布时间】:2020-01-31 16:02:40
【问题描述】:

在主数据源中,我有一个字段“List someDto”。我需要将此字段添加到子报表数据源。也许我可以使用一些表达式,返回 JRDataSource 类型?

report.addDetail(subreport(report()
                .addDetail(text(field("text", String.class)))
                .addDetail(image(fieldExpression("image")))
                .setDataSource(----*here i need to add field from main datasource*----)

【问题讨论】:

    标签: java jasper-reports datasource


    【解决方案1】:

    天哪,我只是使用 subDatasourceBeanCollection 并将 .setDataSource 从 report().setDataSource 替换为 subreport(...).setDataSource():

    report.addDetail(subreport(report() .addDetail(text(field("text", String.class))) .addDetail(image(fieldExpression("image")))) .setDataSource(subDatasourceBeanCollection("*here my field from main datasource")));

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多