Free Support Forum -

Use Nested Mail Merge Field inside IF Field to Conditionally Show Hide Table in Word DOCX Document using JAVA

We have recently upgraded Aspose.word from 13.5.0 to 20.4 and running in to issue with If condition on table.
Basically {IF {MERGEFIELD some} = “test” “YES” “NO”} is working for simple text. But if we want to show/hide table then it is not working. In above example, Instead of “YES” we want to show a table.

Could you please provide suggestion on this issue?


Please check following documents where I placed a Table inside True part of IF field.

Following C# code will show the Table while specifying false to merge field will hide it.

Document doc = new Document("E:\\Table inside true part of IF field\\Table inside true part of IF field.docx");
doc.MailMerge.Execute(new String[] { "show" }, new String[] { "true" });
doc.Save("E:\\Table inside true part of IF field\\20.5.docx");

Hope, this helps.

Could you please test “false” result in order do not show the table?


Sure, I have attached both the outputs (generated by specifying “true” & “false”) here for your reference:

It seems if we have “if statement” with in «TableStart:objectList» … «TableEnd:objectList» then it is not working correctly.


To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Aspose.Words 20.5 generated output DOCX file showing the undesired behavior
  • Your expected DOCX file showing the desired output. You can create this document by using MS Word.
  • Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you more information. Thanks for your cooperation.

It seems there is bug in Aspose.word with getChildDataSource and “if statement”.It looks like getChildDataSource() is not calling when we have “if statement”. Please find the sample code where we are able to reproduce this (857.4 KB)


We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-20477. We will further look into the details of this problem and will keep you updated on the status of the linked issue. Sorry for the inconvenience.