Accessing Table from Cell and Adding Values Inside It Using Row and Column Offsets

The following screenshot shows the source Excel file used in the code. It contains an empty table and highlights cell D5, which lies inside the table. We will access this table from cell D5 using the Cell.GetTable() method and then add values inside it using both Cell.PutValue() and ListObject.PutCellValue methods.

Example

Screenshots Comparing the Source and Output Files

todo:image_alt_text

The following screenshot shows the output Excel file generated by the code. As you can see, cell D5 has a value, and cell F6, which is at the offset (2, 2) of the table, also has a value.

todo:image_alt_text

C# Code to Access a Table from a Cell and Add Values Inside It Using Row and Column Offsets

The following sample code loads the source Excel file as shown in the above screenshot, adds values inside the table, and generates the output Excel file as shown above.