drmacro / wordinator

Generate high-quality DOCX files using a simplified XML format (simple word processing XML).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested tables appear in the schema not to be allowed

gkholman opened this issue · comments

Reviewing the schema, it seems that tables are allowed only in body content and footnote content.

Body content is allowed only in headers, footers, and the body.

It seems that tables are not allowed in table cells, but such is needed a lot in my data as I have nested tables all over the place. (Maybe I can mitigate many of them, but I don't think all)

Since the recommendation is to validate SWPX before processing it, I've built that into my workflow and so I am stuck.

I'll have to see what it will take to support nested tables--it might be easy or it might not.

I've managed to flatten my primary use of nested tables (as implied in my strikeout above). For now, I think this can be of lesser priority. Thanks!

OK, I'm just seeing what is involved in supporting it. The POI 4.x XWPF API does not provide an addTable() method for table cells but it might not be hard to just add the table XML manually. The underlying OO XML is simple enough--the cell just contains the table markup directly.

Turns out the XWPF API does have an add table method for cells, but my first attempt to use it did not produce a working table.

I am able to generate a nested table that opens in Word without complaint but the table's properties are not being set properly--it appears to be a POI DOCX generation issue but it would take more time than I have now to track it down.

The code is on branch feature/Issue-80-nested-tables.

This code required adding the "doc" parameter to the makeTable methods and the to the methods that call it as the document is required in order to construct the nested table.

This appears to be an area of the XWPF API that has not been well tested at the POI level (at least in POI 4).