Delete Empty Rows from Table in Word Document using C# .NET or Java | Remove Rows without any Text or Value

I have a very long doc,and I have many tables in the document,but now some tables(at the end of the document) have few rows without valve,I want to konw if i have way to delete this rows.PS :just above these tables I want to Modify,there some other tables.so maybe I should ues a bookmark to locate?I’m a green hand,It is very appreciate if you can show me the sample code.

@tint,

The following C# code should remove all Rows (which have no Text in them) from Word document:

Document doc = new Document("E:\\Temp\\Table.docx");

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    foreach (Row row in table.Rows)
    {
        if (string.IsNullOrEmpty(row.ToString(SaveFormat.Text).Trim()))
            row.Remove();
    }
}

doc.Save("E:\\Temp\\20.5.docx");

If this is not what you are looking for, then please ZIP and attach the following resources here for testing:

  • Your simplified input Word document you want to remove Row(s) from
  • Your expected DOCX file showing the desired output. You can create this document by using MS Word.

As soon as you get these pieces of information ready, we will start further investigation into your scenario and provide you code to achieve the same by using Aspose.Words. Thanks for your cooperation.