I have a .doc template where I am using a table nested within a parent table. Sometimes, the nested table is empty while the parent table has some data, so I would just like to remove the nested table from the output document. I am currently using a subclass from DocumentVisitor found in this thread : http://www.aspose.com/community/forums/263476/problem-merging-with-empty-table/showthread.aspx#263476, that I translated into java. It works perfectly when both tables are empty, but when only the nested table is empty, it is not removed, since the “tablestart” field from the nested table is not found when the visitor does its work (even though it is visible in the output document). Does someone have some hints about this problem ?
thanks in advance for the help.
Thanks for your request. Do you use Mail Merge feature to fill the document with data? If so, you can just set RemoveEmptyRegions option, in this case empty regions will be removed upon mail merge:
If you do not use mail merge, then please attach the document where you need to remove empty tables, I will check it and provide you more information.
My problem (with both methods) came from the fact that when my dataset was empty, I did not perform the mailmerge and then nothing was deleted. Just works perfectly now.
Thanks a lot for the help,
It is perfect that you managed to resolve the problem. Please let me know if you need more assistance, I will be glad to help you.
Your answer worked for our new version of product where we use new version of Aspose.Words. But when I wanted to merge the fix to older version where we have used older version of Aspose.Words this property does not exists, and the empty region is not removed automatically. In fact the region is not empty. The region is as below.
<TableStart:Child><> Numbers <TableEnd:Child>
When the MailMerge.ExecuteWithRegions is executed, in case parent has value but child not it still shows Numbers, but if parent does not have any value Total is not shown (As it should not).
Would you please let me know how can I fix this problem in older version where “RemoveEmptyResions” is not introduced.
Thank you i advance,
Thanks for your request. In this case you can try using RemoveEmptyRegions class:
// Open the template document
Document doc = new Document(@"in.doc");
// Merge data
// Remove any remaining unused regions from the document
RemoveEmptyRegions class is attached.