Spread.Services Documentation
Add and Delete Table Columns and Rows
Spread.Services Documentation > Developer's Guide > Manage Data in Spread Component > Use Table > Add and Delete Table Columns and Rows

You can add and delete columns and rows of a table using the methods and properties of the following interfaces:

Add and delete table columns

To add and delete table columns, you can use the Add method of the ITableColumns interface and the Delete method of the ITableColumn interface respectively.

Refer to the following example code in order to add and delete table columns.

C#
Copy Code
//Create first table
ITable table1 = worksheet.Tables.Add(worksheet.Range["D3:I6"], true);

//Create second table
ITable table2 = worksheet.Tables.Add(worksheet.Range["A1:C6"], true);

//Insert a table column before first column in first table
table1.Columns.Add(0);

//Insert a table column before first column in second table
table2.Columns.Add(0);

//Delete the first table column from the first table.
worksheet.Tables[0].Columns[0].Delete();

Add and delete table rows

To add and delete table rows, you can use the Add method of the ITableRows interface and the Delete method of the ITableRow interface respectively.

Refer to the following example code in order to add and delete table rows.

C#
Copy Code
//insert a new row at the end of the first table.
table1.Rows.Add();

//insert a new row at the end of the second table.
table2.Rows.Add();

//Delete the second row in the second table.
table2.Rows[1].Delete();