Using Aspose Words Hide/Show table in Word Template

Hi all,

I need some input of below scenario how to show/hide a table in word template while converting into PDF using aspose words. Is it any API we can achieve or any aspose words interface to do it.


If A= Yes show Table 1. else hide Table 1.
Table 1 will be some how like below

2 rows 3 columns i have to hide everything here as well as if possible need to hide one column inside the table

Kindly provide some input on how to achieve this one using aspose.


Please see this template document ( (9.7 KB)) and try running the following code:

Document doc = new Document("E:\\temp\\in.docx");
doc.MailMerge.UseNonMergeFields = true;
// doc.MailMerge.Execute(new string[] { "A"}, new object[] { "No"});
doc.MailMerge.Execute(new string[] { "A" }, new object[] { "Yes" });

Hope, this helps.

@awais thanks for response. But i need entire table to be hide and shown how can we create if condition for this.IF “{{ A }}” = “Yes” " 1 2 3 4 5 6 7 8 9 " “false text” This well create false text if No and 1223456789 if A= “Yes” but if A = “Yes” i need to show the entire table in the word document.
Table contains 2 rows and 3 columns and if possible need to hide 1 column alone inside the table.
Any inputs for this.


The sample I shared with you earlier shows the table if the value is Yes and hides it if the value is other than Yes. You can toggle to view the field codes by pressing ALT+F9 inside in.docx in MS Word. Here is how the template looks like in toggled field codes view.

Secondly, I am afraid, there is no way to hide a particular column. If we can help you with anything else, please feel free to ask.


How to compare mergefields with more than one field example as below

{ IF “<<field1>>” = “Yes” && <<field2>> = “true” “Table” “”}

Opertor how to use it instead of && or AND


Please ZIP and upload your template document (you are getting this problem with) here for testing. We will then investigate the issue on our end and provide you more information.