Cell Merging

<< Click to display table of contents >>

Cell Merging

Cells have read-only ColSpan and RowSpan properties, similar to html <td colspan rowspan>, 1 by default.

If Cells[r,c].ColSpan>1, this cell spans over (ColSpan-1) cells to the right:

Cell[r,c], Cell[r,c+1], ..., Cell[r,c+Cell[r,c].ColSpan-1].

In this case, all overlapped cells  (Cell[r,c+1], ..., Cell[r,c+Cell[r,c].ColSpan-1]) are destroyed and equal to nil.

Number of cells in the row is still equal to the number of cells in all other rows, even with merging.

The same is with RowSpan: cell with RowSpan>1 spans over (RowSpan-1) cells below.

ColSpan and RowSpan example

ColSpan and RowSpan example

Example: iterating through all cells of table:

for r := 0 to table.RowCount-1 do

 for c := 0 to table.ColCount-1 do

   if table.Cells[r,c] <> nil then

     table.Cells[r,c].Color := clRed;

// ( Cells[r,c]=nil if it is overlapped by the top left cell)

You can get the top left cell which overlaps given cell with table.Rows.GetMainCell method:

function GetMainCell(ARow,ACol: Integer;

  out MRow, MCol: Integer): TRVTableCellData;

 

Methods for merging cells:

MergeCells,

MergeSelectedCells

Inverse operation:

UnmergeCells,

UnmergeSelectedCells

Splitting cells:

SplitSelectedCellsHorizontally,

SplitSelectedCellsVertically