XDocReport: generated docx document error "Word experienced an error trying to open the file"

1.3k views Asked by At

I am trying to generate a report in .docx format that contains a table in it using XDocReport and freemarker.

I am using a list to print the data inside the table.

I am using a list to print the data inside the table.

The problem is there is no error in java while generating the document, but the generated document cannot be open. The error said

Word experienced an error trying to open the file.

Word experienced an error trying to open the file.

I was expecting the output to be like this:

this.

I am using XDocReport 2.0.2 with Office 2016. Any help is appreciated. Thank You.

3

There are 3 answers

0
Dio On BEST ANSWER

So, after a few days of workaround and help from my friend, this issue was finally solved. so here is a change that I made

I added the @before-row tag before [#list p.cities as c] and with only a single @after-row tag. Now, the generated document can be open

5
ddekany On

I guess (without knowing XDocReport) that [#list p.cities ...] should be prefixed with @before-row too. Otherwise when you iterate for the cities, the start-tags of the table row will not be repeated, only the end-tags.

1
Imagyne Art On

Right Click on the File. Instead of clicking on "Open" click on "Edit" That's it, simple.