XDocReport generate report : loop thru collection in table (java)

3k views Asked by At

I have been struggling with trying to follow a code sample by XDocReport(open source project). I followed this tutorial from the website: https://code.google.com/p/xdocreport/wiki/DocxReportingJavaMainListFieldInTable

I used the Freemarker template style.

I would not iterate and create the table, I just get back: $variable as text in the output doc. Then I dug further, and discovered that this tutorial on the website was probably not updated for the newer version. I found some more examples in this url, which contains a zip file. https://code.google.com/p/xdocreport/downloads/detail?name=docxandfreemarker-1.0.4-sample.zip

I still could not get it to work.

I was hoping someone would have a working code sample that takes a java collection and populates a table in a Word document.

I hope one of the developers of XDocReport, angelo.zerr, would give some input on this.

Sincerely, P

2

There are 2 answers

0
Palu On BEST ANSWER

It seems that the issue was the template. If one sets up a mail merge field in a Word template and don't use it in the Java program, the program then complains it can't find the variable, or something to that effect. And if you just delete the mail merge text in the document, it may still exist as a mail merge field variable in the word document.

So one needs to be very careful it seems with how to set things in the template.

I think the API should be able to ignore if there is a field setup in the template, and we are not referencing it in the code though. But that solved the problem.

1
Angelo On

I was hoping someone would have a working code sample that takes a java collection and populates a table in a Word document.

What is the problem with https://code.google.com/p/xdocreport/wiki/DocxReportingJavaMainListFieldInTable?

I suggets you that you create an issue on XDocReport forum with a very simple case (simple Java main + docx)