Remove Empty Data Tables


I have a table that is being populated with data from a datatable using the MailMerge.ExecuteWithRegions function along with TableStart and TableEnd markers. It is working perfectly when I have data, but I have instances where the datatable will be empty. Current behavior seems to be that if the datatable is empty, ExecuteWithRegions will leave the “placeholder” table intact with merge fields still present.

Ideally, I would like an option similar to “RemoveEmptyParagraphs” where by setting “RemoveEmptyDataRegions” to true, it will completely remove that table. Or maybe simply that row.

I just can’t have the merge fields remaining in my resulting document when I have 0 rows of data.

Can this be implemented quickly? I have a need for it immediately. I am preparing a product mock-up to convince my company to buy Aspose.



Try MailMerge.DeleteFields, let me know if that still does not solve the problem.


Close, but not quite.

I have a document that is to contain a table with x rows of the following:


<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

Current Levy. ?levy? Maximum Tax Rate. ?maxtax?<o:p></o:p>

<o:p> </o:p>

Ending Year. ?endyear?<o:p></o:p>

<o:p> </o:p>

Authorized Facilities. ?facilities?<o:p></o:p>

<o:p> </o:p>

Authorized Services. ?services?<o:p></o:p>

<o:p> </o:p>?TableEnd:NOST?

MailMerge.DeleteFields simply removes the fields, but leaves the “labels” still in place. If I have no data for that particular table, I would like to either delete the entire table, or at least delete the “template row”.

So like I said before, a switch similar to RemoveEmptyParagraphs that could specify whether empty tables/template rows are to be removed would be very nice.


Actually I just realized this is partially working. It works on some of my tables, but not all. I haven't been able to identify why it works on some and not on others, but I've just gone and copied the tables that worked and used them as the basis for building new tables.