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

Free Support Forum - aspose.com

Words - MergeFields not removed in Child Table

Hello

I have a problem that I think there might be a ready-made solution for.

In the Word template that I have attached there is a child table. Depending on the data in the database, sometimes there is data for the parent (Base) table, but no rows for the child table. When this occurs the Mergefields are left in the document in clear sight. They should obviously never be visible regardless if there is data or not.

What can I do to accomplish this. I tried a quick fix whereby I added an empty row if the child table was empty. This gets a bit complicated though when I have multiple fields to join the parent and child table on. So, I am hoping that there is some sort of built-in functionality that can solve this.

Grateful for help as always,

!Rob

Hi Rob,

Thanks for your request. I think, RemoveEmptyRegions option should help you:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.reporting.mailmerge.removeemptyregions.html

Please let me know if you need more assistance, we are always glad to help you.

Best regards,

Hi Alexey

Sorry, but I tried RemoveEmptyRegions before contacting you, but it did not help. Regardless, I don't want that on since it potentially mucks up other things, as earlier discussed. If I understood things correctly in our previous discussions the RemoveEmptyRegions method is more of a legacy thing that causes as many problems as it solves?

Since what I am trying to achieve must be a fairly standard thing I must believe other people need this working too. Do they not get the same problem?

Are you able to test run my template to see if you get the same issue?

Maybe an option called RemoveEmptyMergeFields that always removes any fields that does not get populated would solve the problem? Actually, that should probably be the standard behaviour.

Regards,

!Rob

Oops,

Sorry Alexey, RemoveEmtpyRegions did work! I had set the RemoveEmptyParagraphs which we had discussed previously. I guess they looked too alike, sorry. I have now changed my code to include RemoveEmtpyRegions = true;.

Are there any potential pitfalls with always having that option set to true?

Regards,

!Rob

Hello

Thanks for your request. It is perfect that you already found the way to achieve what you need. There is no any problem to have this option always set, but the default behavior is - do not remove empty regions.

Best regards,