We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Deleting a row in a table with multiple merge fields


I have a created a table as shown in the attached document. The final row of the table is not always required.

As the output on the document shows, the final row is not being removed but displays as an empty line which is not the desired outcome.

I have tried setting the merge fields to blank, to a single space and also removing the tab and space at the beginning of the row (and the various combinations) but I cannot seem to work around this. I have noticed some older posts which had similar problemsand some code to work around it but as the posts were a few years old, I do not know if things have changed.

I code in VB. I do use the following settings:

doc.MailMerge.RemoveEmptyParagraphs = Truedoc.MailMerge.RemoveEmptyRegions = True

Any assistance would be appreciated.


Thanks for your request. You can get the last row using table.LastRow property. Then you can the text contained in this row using row.ToTxt() method. Please see the following links for more information:

Also see example code which is shown below:

//your input document
string filename = @“input.docx”;
Document doc = new Document(filename);

//get all tables from document
NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);

//for each table check last rows
foreach (Table table in tables)
while (String.IsNullOrEmpty(table.LastRow.ToTxt().Trim()))

//save document
doc.Save(“out.doc”, SaveFormat.Doc);

Best regards,