TableCell
The TableCell class represents a single cell in a Table. Cells are added to a TableRow instance in the rows collection of a table. The main purpose of the cell is to contain, organize, and layout tabular data.
Inserting a TableCell
To add a cell to a Table, add it in the TableCellCollection of a TableRow.
The code in Example 1 shows how to create a table with a single row and add a cell in the first row.
Example 1: Create TableCell
Table table = new Table();
TableRow firstRow = table.Rows.AddTableRow();
TableCell firstCell = firstRow.Cells.AddTableCell();
Adding Cell Content
Use the Blocks property of TableCell to add one or several IBlockElement instances to the cell.
Example 2 shows how to create a cell with a single Block in it.
Example 2: Add content to TableCell
Block block = firstCell.Blocks.AddBlock();
block.InsertText("Text in the cell.");
Modifying a TableCell
You can change the cell presentation by using the following properties:
-
RowSpan: Defines the number of rows that theTableCellinstance occupies. -
ColumnSpan: Defines the number of columns that theTableCellinstance occupies. -
Padding: Specifies the distances between the cell borders inner contour and the cell content. If the value is null, the cell uses the padding from the tableDefaultCellProperties. -
Borders: Specifies the borders of the cell. If the value is null, the cell uses the value from the tableDefaultCellProperties. -
Background: Specifies the background of the cell. If null, the cell uses the background from the tableDefaultCellProperties. -
PreferredWidth: Specifies the preferred width of the cell. The final width of the cell may be bigger than the set value if another cell from the same column requires a biggerPreferredWidth. -
VerticalAlignment: Specifies the vertical alignment of the content inside the cell.
Example 3 demonstrates how to set the cell properties locally to a specific cell. This helps achieve a different appearance for this cell by changing its borders and background. Additionally, the cell spans two rows and two columns.
Example 3: Change TableCell appearance
firstCell.RowSpan = 2;
firstCell.ColumnSpan = 2;
firstCell.Borders = new TableCellBorders(new Border(1, new RgbColor(150, 0, 0)));
firstCell.Background = new RgbColor(255, 100, 100);
The result from Example 3 is illustrated in Figure 1.
Figure 1: TableCell

See Also
- Table
- TableRow
- Block
- How to Generate a Table with Images with PdfProcessing
- Creating Custom Layout Tables with RadPdfProcessing
- Implementing Column Span in RadPdfProcessing Tables
- Creating a PDF Table with Form Fields Inside the Cells
- Inserting HTML Content into PDF TableCell with RadPdfProcessing
- How To Rotate Cell Content