Table.MergeCells(TableCell, TableCell) Method
Merges the cells in the specified range into a single cell.
A TableCell that marks one end of the merged range.
A TableCell that marks the opposite end of the merged range.
All cells that fall within a table range marked by specified cells (including them) are merged into a single cell. The order in which cells are specified as method arguments does not matter.
This code snippet performs the following:
- creates a table containing 6 rows and 8 columns
- merges cells horizontally in the third row from the third to the sixth column
- merges cells vertically in the third column from the fourth to the eighth row
Document document = server.Document; Table table = document.Tables.Create(document.Range.Start, 6, 8); table.BeginUpdate(); table.MergeCells(table[2, 1], table[5, 1]); table.MergeCells(table[2, 3], table[2, 7]); table.EndUpdate();