# Inserting Table

## Content

Table is used in word documents to present data in a well formatted form with the help of rows and columns. It is a very common practice to use tables in word documents to represent formatted data in rows and columns. **Word** component enables you to add table to your document using [RtfTable](/componentone/api/win/online-wordlibrary/dotnet-framework-api/C1.C1Word.4.8/C1.C1Word.Objects.RtfTable.html) class to create a table and [RtfParagraph](/componentone/api/win/online-wordlibrary/dotnet-framework-api/C1.C1Word.4.8/C1.C1Word.Objects.RtfParagraph.html) class to insert content in table.

Following code adds a table to a word document:

```vbnet
Dim rows As Integer = 4
Dim cols As Integer = 2
Dim table As New RtfTable(rows, cols)
C1Word.Add(table)
For row As Integer = 0 To rows - 1
        For col As Integer = 0 To cols - 1
                Dim paragraph As New RtfParagraph()
                paragraph.Content.Add(New RtfString(String.Format("table cell {0}:{1}.", row, col)))
                table.Rows(row).Cells(col).Content.Add(paragraph)
        Next
Next
```

```csharp
int rows = 4;
int cols = 2;
RtfTable table = new RtfTable(rows, cols);
C1Word.Add(table);
for (int row = 0; row < rows; row++)
{
        for (int col = 0; col < cols; col++)
        {
        RtfParagraph paragraph = new RtfParagraph();
        paragraph.Content.Add(new RtfString(string.Format("table cell {0}:{1}.", row, col)));
        table.Rows[row].Cells[col].Content.Add(paragraph);
        }
}
```