我正在使用DynamicJasper创建报告。我为此编写的代码创建了一个表,并用传递给它的集合填充了该表。
现在,我想在表格顶部添加一些静态文本。我该怎么办?
我编写的代码如下:
private DynamicReport getReport(Style headerStyle, Style detailTextStyle, Style detailNumStyle) throws ColumnBuilderException, ClassNotFoundException {
DynamicReportBuilder report=new DynamicReportBuilder();
AbstractColumn columnName = createColumn("pluginName", String.class,"Plugin Name", 30, headerStyle, detailTextStyle);
AbstractColumn columnSalary = createColumn("displayName", String.class,"Display Name", 30, headerStyle, detailNumStyle);
AbstractColumn columnCommission = createColumn("pluginDescription", String.class,"Plugin Description", 30, headerStyle, detailNumStyle);
report.addColumn(columnName).addColumn(columnSalary).addColumn(columnCommission);
StyleBuilder titleStyle=new StyleBuilder(true);
titleStyle.setHorizontalAlign(HorizontalAlign.CENTER);
titleStyle.setFont(new Font(20, Font._FONT_GEORGIA, true));
StyleBuilder subTitleStyle=new StyleBuilder(true);
subTitleStyle.setHorizontalAlign(HorizontalAlign.CENTER);
subTitleStyle.setFont(new Font(Font.MEDIUM, Font._FONT_GEORGIA, true));
report.setTitle("Plugin Output Report");
report.setTitleStyle(titleStyle.build());
report.setSubtitle("Commission received by Employee");
report.setSubtitleStyle(subTitleStyle.build());
report.setUseFullPageWidth(true);
return report.build();
}
创建的报告如下
我想在此表顶部添加一些静态文本。请帮助
答案 0 :(得分:1)
DynamicJasper自动图文集可能会有所帮助。
选中http://dynamicjasper.com/2010/10/06/how-to-create-autotext-ie-page-xy-out-of-the-box/
AutoText title = new AutoText("Plugin Output Report"),
AutoText.POSITION_HEADER,
HorizontalBandAlignment.CENTER);
title.setWidth(new Integer(500));
report.addAutoText(title);