Page 1 of 1

Vertical and Horizontal Table Cell Merging

PostPosted: Wed Sep 26, 2018 12:30 am
by capocomico
Hi there,
I've have a to merge the cell content of a table, which content was populated by code.
I've found examples of doing this for a new table, but not for a table with content previously loaded.

Capture1.PNG
Table result after populating the cells
Capture1.PNG (11.03 KiB) Viewed 2315 times

Capture2.PNG
Expected Table with Vertical Merging
Capture2.PNG (9.76 KiB) Viewed 2315 times


Is there a way to do it?
Thanks in advance

Re: Vertical and Horizontal Table Cell Merging

PostPosted: Tue Oct 09, 2018 5:16 pm
by jason
You could manipulate the existing w:tbl contents.

Or, we have https://github.com/plutext/docx4j/blob/ ... Model.java which represents a docx table in a way which is a bit easier to work with.

You could extend this, with:

(1) methods to say: mergeVertical(colnum, fromRow, rowCount), mergeHorizontal

(2) a method to write out the table as OpenXML.

https://github.com/plutext/docx4j/blob/ ... riter.java writes it as HTML.

May be of some interest/use https://github.com/plutext/docx4j-Impor ... .java#L494