Search code examples
javaapache-poixwpf

Apache POI (DOCX) XWPFTable asymmetric cell


I want to create a table looks like this.

but the only way to to this is with an horrible merge of cells. i try to make two separate table but the top table, follow the cell width of bottom table like this.

There is a way to make an asymmetric table without merge cells?


Solution

  • You don't have to 'merge' cells, but you do have to tell it how many grid columns or rows the cell spans. Picture a grid that has a column that matches every column position, and a row that matches every row position. In your example, you would have a grid with 18 columns and 3 rows. Then for each cell that spans one or more grid column or row, you must have a span attribute that tells how many grid positions are spanned by the cell. The result is the same as merging, and it might even be what you meant by merging, but that is the way the spec reads.