我正在处理动态jasper子报表,我有一个包含以下内容的数据源: 一对多映射,带有角色列表的用户详细信息,我正在尝试实现 主报告应包含用户详细信息,子报告应包含角色列表,这两个之间的主键是userId
来自http://dynamicjasper.com/2010/10/06/how-to-add-subreports-fast-way/的引用 我以相同的方式进行操作,但遇到错误时我遇到错误roleId有时找不到,有时只是空白的pdf
公共类SubReportTest扩展了BaseDjReportTest {
$AddServerwpf.ServerGrid.SelectedItems[0].SelectedAccount
}
我遇到错误public DynamicReport buildReport() throws Exception {
FastReportBuilder drb = new FastReportBuilder();
drb.addColumn("UserId", "userId", Integer.class.getName(),30)
.addColumn("Name", "name", String.class.getName(),30)
.addColumn("Product Line", "productLine", String.class.getName(),50)
.addColumn("Item", "item", String.class.getName(),50)
.addColumn("Item Code", "id", Long.class.getName(),30,true)
.addColumn("Quantity", "quantity", Long.class.getName(),60,true)
.addColumn("Amount", "amount", Float.class.getName(),70,true)
.addGroups(1)
.setMargins(5, 5, 20, 20)
.setTitle("November " + getYear() +" sales report")
.setSubtitle("This report was generated at " + new Date())
.setUseFullPageWidth(true);
drb.addField("userRolesList", List.class.getName());
DynamicReport drFooterSubreport = createFooterSubreport();
drb.addSubreportInGroupHeader(2, drFooterSubreport, new ClassicLayoutManager(),
"userRolesList", DJConstants.DATA_SOURCE_ORIGIN_FIELD, DJConstants.DATA_SOURCE_TYPE_COLLECTION);
drb.setUseFullPageWidth(true);
DynamicReport dr = drb.build();
return dr;
}
private DynamicReport createFooterSubreport() throws Exception {
FastReportBuilder rb = new FastReportBuilder();
DynamicReport dr = rb
.addColumn("RoleID", "roleId", Integer.class.getName(), 100)
.addColumn("Type", "type", String.class.getName(), 50)
.addColumn("Status", "status", String.class.getName(), 50)
.addGroups(1)
.setMargins(5, 5, 20, 20)
.setUseFullPageWidth(true)
.setTitle("Footer Subreport for this group")
.build();
return dr;
}
public static void main(String[] args) throws Exception {
SubReportTest test = new SubReportTest();
test.testReport();
JasperViewer.viewReport(test.jp);
}
,发现了很多jrxml解决方案,也不想使用jrxml,我只是在寻找纯Java解决方案。