# TableCell

The `TableCell` class represents a single cell in a [Table](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/overview). Cells are added to a [TableRow](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/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](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell#inserting-a-tablecell)

* [Adding Cell Content](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell#adding-cell-content)

* [Modifying a TableCell](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablecell#modifying-a-tablecell)

## 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**

```C#
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](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/block) in it.

**Example 2: Add content to TableCell**

```C#
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 the `TableCell` instance occupies.

* `ColumnSpan`: Defines the number of columns that the `TableCell` instance 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 table `DefaultCellProperties`.

* `Borders`: Specifies the borders of the cell. If the value is null, the cell uses the value from the table `DefaultCellProperties`.

* `Background`: Specifies the background of the cell. If null, the cell uses the background from the table `DefaultCellProperties`.

* `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 bigger `PreferredWidth`.

* `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**

```C#
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 the following image.

**TableCell**

![RadPdfProcessing TableCell](https://www.telerik.com/document-processing-libraries/documentation/assets/1303405cb503bf28a08fbb364fff3bbe/radpdfprocessing_editing_tablecell_01.png)

## See Also

* [Table](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/overview)
* [TableRow](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/table/tablerow)
* [Block](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/block)
* [How to Generate a Table with Images with PdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/generate-table-with-images-pdf-processing)
* [Creating Custom Layout Tables with RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/customize-table-layout-radpdfprocessing)
* [Implementing Column Span in RadPdfProcessing Tables](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/table-column-span-radpdfprocessing)
* [Creating a PDF Table with Form Fields Inside the Cells](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/insert-form-xobject-elements-pdf-table-cell)
* [Inserting HTML Content into PDF TableCell with RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/insert-html-content-into-pdf-tablecell-radpdfprocessing)
* [How To Rotate Cell Content](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/pdfprocessing-rotate-cell-content)
* [How to Clip Text in a Table Cell and Wrap Text in Another Cell](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/clip-text-in-table-cell-radpdfprocessing)
