使用ReportingEngine引擎给集合的前面加递增序号不生效

您好,我当前使用的Aspose-word版本是23.6,在使用ReportingEngine引擎给列表前加递增的序号时,没有生效,请问该如何修改?

LoadOptions opt = new LoadOptions();
opt.getLanguagePreferences().setDefaultEditingLanguage(EditingLanguage.CHINESE_PRC);
// 将输入流转为doc
Document doc = new Document(inputStream, opt);
ReportingEngine engine = new ReportingEngine();
ContractDto contractDto = this.buildContractDto();
OrderDto orderDto = this.buildOrderDto();
List<Rule> ruleList = this.buildRuleList();
Object[] objects = { contractDto, orderDto, ruleList };
String[] dataSourceNames = { "contractDto", "orderDto", "ruleList" };
// 声明对象类型,在foreach中会用到
engine.getKnownTypes().add(Rule.class);
// 将数据填充至模板
engine.buildReport(doc, objects, dataSourceNames);
// 转pdf
doc.save(outputStream, SaveFormat.PDF);

word中的标签
1. <<foreach [Rule item in ruleList]>><<[item.getRuleName()]>><</foreach>>

生成的pdf

@songyassen 为了获得预期的输出,您应该将 <</foreach>> 移至下一段。例如,请参阅所附模板和输出文档:

Document doc = new Document("C:\\Temp\\in.docx");
ReportingEngine engine = new ReportingEngine();
String[] items = { "First", "Second", "Third" };
engine.buildReport(doc, items, "items");
doc.save("C:\\Temp\\out.pdf");

in.docx (13.8 KB)
out.pdf (17.1 KB)