我正在使用的Java代码如下:
InputStream in = GenerateStakeholderReport.class.getResourceAsStream( "StakeholderReport_Template.docx" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Velocity );
FieldsMetadata metadata = report.createFieldsMetadata();
metadata.load( "stakeholders", StakeHolder.class, true );
IContext context = report.createContext();
Project project = new Project( "Project 1", "A project for Oragisational Change",
"System Implementation", "Bob Yardley","Peter");
context.put( "project", project );
List<StakeHolder> stakeholders = new ArrayList<StakeHolder>();
stakeholders.add( new StakeHolder( "01", "External", "President", "Head Quarter", "High", "5000", "Key Infulencer" ) );
stakeholders.add( new StakeHolder( "02", "Internal", "CEO", "Head Quarter", "High", "2500", "Key Infulencer" ) );
context.put( "stakeholders", stakeholders );
OutputStream out = new FileOutputStream( new File( "StakeHolderReport_Out.docx" ) );
report.process( context, out );
我得到的输出不是我期望的;表中的行未填充(应该有2行)。另外,两个列标题都没有显示
我在做什么错了?
答案 0 :(得分:0)
尝试在@before-row
之前将#foreach...
放在第一个MergeField之前,将@after-row
放在最后一个MergeField之前。
查看此:https://github.com/opensagres/xdocreport/wiki/ODTReportingJavaMainListFieldAdvancedTable
答案 1 :(得分:0)
您将foreach放在一列中。您必须排队。