Hello,
we are building table(main) in word with FIXED_COLUMN_WIDTHS, and in one of the row we are adding another table(nested table), by doing this the nested table is adding in the first column of the main table, not the entire row. the nested table column is having its own width.
if the main table is of auto fit, then it is working as expected.
attached the screenshots, could you please help me what causing the issue.
Technical details:
Table table = new Table(this.doc);
table.setAllowAutoFit(false); // by disabling autofit, table will consider column width only
table…autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS); // optional
Row row = new Row(this.doc);
– adding cells to the row–
table.appendChild(row);
then creating the nested table and adding to the main table
if (nestedTable != null)
{
Row tablContainerRow = new Row(this.doc);
table.appendChild(tablContainerRow);
Cell firstCell = new Cell(this.doc);
firstCell.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
firstCell.appendChild(nestedTable );
tablContainerRow.appendChild(firstCell);
Cell secondCell = new Cell(this.doc);
secondCell.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);
tablContainerRow.appendChild(secondCell);
Cell thirdCell = new Cell(this.doc);
thirdCell.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);
tablContainerRow.appendChild(thirdCell);
Cell fourthCell = new Cell(this.doc);
fourthCell.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);
tablContainerRow.appendChild(fourthCell);
}
Regards,
Ramesh