Skip to main content
A newer version of this page is available. .

How to: Delete a Table

The following example illustrates how to delete a table cell, row or an entire table.

  • To delete a single cell, use the TableCell.Delete method. The required cell will be deleted and the next one will be moved to the left.
  • The TableRow.Delete method deletes a specified row from the table.
Document document = server.Document;
Table tbl = document.Tables.Create(document.Range.Start, 3, 3, AutoFitBehaviorType.AutoFitToWindow);
tbl.BeginUpdate();
tbl.Rows[2].Delete();
tbl.Cell(1, 1).Delete();

tbl.EndUpdate();
  • To delete the whole table, delete it from the collection of tables contained in the current document. To do that, use the TableCollection.Remove method.
Table tbl = document.Tables.Create(document.Range.Start, 3, 4);
//To delete the table, uncomment the method below:
//  document.Tables.Remove(tbl);