2017-02-09 56 views
0

如何在使用Pentaho报表引擎进行编码时在Subreport中使用ItemBand?Pentaho报表引擎 - 如何在Subreport中使用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在我的报表?

回答

0

感谢,

我能够做到这一点:

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);