DocumentBuilderDeleteRow Method

Deletes a row from a table.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0

Syntax

public Row DeleteRow(
	int tableIndex,
	int rowIndex
)

Parameters

tableIndex
Type: SystemInt32
The index of the table.
rowIndex
Type: SystemInt32
The index of the row in the table.

Return Value

Type: Row
The row node that was just removed.

Remarks

If the cursor is inside the row that is being deleted, the cursor is moved out to the next row or to the next paragraph after the table.

If you delete a row from a table that contains only one row, the whole table is deleted.

For the index parameters, when index is greater than or equal to 0, it specifies an index from the beginning with 0 being the first element. When index is less than 0, it specified an index from the end with -1 being the last element.

Examples

Shows how to delete a row from a table.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a table with 2 rows
Table table = builder.StartTable();
builder.InsertCell();
builder.Write("Cell 1");
builder.InsertCell();
builder.Write("Cell 2");
builder.EndRow();
builder.InsertCell();
builder.Write("Cell 3");
builder.InsertCell();
builder.Write("Cell 4");
builder.EndTable();

Assert.AreEqual(2, table.Rows.Count);

// Delete the first row of the first table in the document
builder.DeleteRow(0, 0);

Assert.AreEqual(1, table.Rows.Count);

See Also