Exception in thread "main" java.lang.IllegalStateException: An error has been encountered at the end of expression 'Contract c '. Keyword 'in' is expected.
at com.aspose.words.internal.zzYm8.zzXSa(Unknown Source)
at com.aspose.words.internal.zzYm8.zzZd9(Unknown Source)
at com.aspose.words.internal.zzZfb.zzZtK(Unknown Source)
at com.aspose.words.internal.zzYbm.zzVPc(Unknown Source)
at com.aspose.words.internal.zzYbm.zzZvB(Unknown Source)
at com.aspose.words.internal.zzYbm.zzWcD(Unknown Source)
at com.aspose.words.internal.zzYbm.zzZ69(Unknown Source)
at com.aspose.words.internal.zzZfb.zzXSa(Unknown Source)
at com.aspose.words.internal.zzZfb.zzXSa(Unknown Source)
at com.aspose.words.internal.zzW9h.zzXSa(Unknown Source)
at com.aspose.words.internal.zzW9h.zzXSa(Unknown Source)
at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
at de.forcont.documentconverter.docx4j.service.AsposeConverter.tableFillingTest(AsposeConverter.java:395)
@zwei In your template you have explicitly specify iteration variable type. This type must be known by the engine. Please try using the following code:
final Document doc = new Document("C:\\Temp\\AsposeLinqTable.docx");
ReportingEngine.setUseReflectionOptimization(false);
final ReportingEngine engine = new ReportingEngine();
List<Contract> contracts = Common.getContracts();
engine.getKnownTypes().add(Contract.class);
engine.buildReport(doc, contracts, "Contracts");
doc.save("C:\\Temp\\out.docx");
Exception in thread "main" java.lang.IllegalStateException: An error has been encountered at the end of expression 'Contracts.Sum(c => c.getPrice())]'. Can not resolve method 'getPrice' on type 'class java.lang.Object'.
at com.aspose.words.internal.zzYm8.zzXSa(Unknown Source)
at com.aspose.words.internal.zzYm8.zzXSa(Unknown Source)
at com.aspose.words.internal.zzZfb.zzZir(Unknown Source)
at com.aspose.words.internal.zzYbm.zzXdh(Unknown Source)
at com.aspose.words.internal.zzYbm.zzWcD(Unknown Source)
at com.aspose.words.internal.zzYbm.zzZ69(Unknown Source)
at com.aspose.words.internal.zzZfb.zzXSa(Unknown Source)
at com.aspose.words.internal.zzZfb.zzXSa(Unknown Source)
at com.aspose.words.internal.zzW9h.zzXSa(Unknown Source)
at com.aspose.words.internal.zzW9h.zzXSa(Unknown Source)
at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
at com.aspose.words.ReportingEngine.buildReport(Unknown Source)
at de.forcont.documentconverter.docx4j.service.AsposeConverter.tableFillingTest(AsposeConverter.java:396)
at de.forcont.documentconverter.docx4j.Docx4JTestMain.main(Docx4JTestMain.java:27)
@zwei In your case you should use a variable to calculate sum in foreach block and then use the value of this variable. For example see the attached modified template: AsposeLinqTable_modified.docx (13.4 KB)
In the original template c variable is out of foreach scope.