Pentaho Reporting Engine——如何在子报表中使用ItemBand

Pentaho Reporting Engine - How to use ItemBand in Subreport

使用 Pentaho Reporting Engine 编码时如何在子报表中使用 ItemBand?

我已将我的 ItemBand 定义如下:

ItemBand rowBand = new ItemBand();
TextFieldElementFactory textFactory3 = new TextFieldElementFactory();
textFactory3.setFieldname("reportname");
Element element = textFactory3.createElement();
element.setDynamicContent(true);
rowBand.addElement(element);
itemBand2.addElement(rowBand);

现在如何在我的子报表中使用 ItemBand?

在这种情况下,项目测试通常很有帮助https://github.com/pentaho/pentaho-reporting/blob/85b5bb6c1b970f1c2648a6bf06b7cf66b9fd0c0b/engine/core/test-src/org/pentaho/reporting/engine/classic/core/SubReportIT.java

谢谢,

我能够通过 :

RelationalGroup subgroup = new RelationalGroup();
GroupDataBody subgroupData = new GroupDataBody();
ItemBand itemBand = new ItemBand();
itemBand.setVisible(true);
subgroupData.setItemBand(itemBand);
subgroup.setBody(subgroupData);
subReport.setRootGroup(subgroup);

ItemBand rowBand = new ItemBand();
rowBand.setLayout(BandStyleKeys.LAYOUT_ROW);

TextFieldElementFactory subtext = new TextFieldElementFactory();
subtext.setFieldname("reportname");
subtext.setX(new Float(12.0));
subtext.setMinimumWidth(new Float(100.0));
subtext.setHeight(new Float(20.0));
Element subelement = subtext.createElement();
subelement.setDynamicContent(true);
rowBand.addElement(subelement);

TextFieldElementFactory subtext2 = new TextFieldElementFactory();
subtext2.setFieldname("reportheader");
subtext2.setX(new Float(112.0));
subtext2.setMinimumWidth(new Float(100.0));
subtext2.setHeight(new Float(20.0));
Element subelement2 = subtext2.createElement();
subelement2.setDynamicContent(true);
rowBand.addElement(subelement2);

itemBand.addElement(rowBand);

report.getReportFooter().addSubReport(subReport);