I need to show/hide a table in the document.
Hello
Thanks for your inquiry. Yes of course it is possible. If you need to conditionally show/hide part of content in your document, then you should consider using IF fields. For instance, please see the attached template. If you press Alt+F9 you will see field codes. If condition is true you will see the first text if false the second. Here is a simple code I used for testing:
Document doc = new Document("in.doc");
doc.MailMerge.Execute(new string[] {"test"}, new object[] {"true"});
doc.Save("out.doc");
Hope this approach could help you.
In additional, you can do not use mergefields in IF fields at all. I put a mergefield just to demonstrate how IF fields work.
Please follow the link to learn more about IF fields:
http://office.microsoft.com/en-us/word-help/field-codes-if-field-HP005186163.aspx
Best regards,
I’ve read it.
Hello
Thanks for your inquiry. You can put anything you want inside your IF field (paragraphs, tables etc).
Best regards,
Can you give an example where table or image inside IF?
Hello
Thanks for your inquiry. Please see the attached template.
Best regards,
Ok, I did it. But I have taken a strange result.
Hi
Thank you for additional information. Have you called UpdateFields method? Maybe in your case it is enough just call UpdateFields() to evaluate IF field.
http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/how-to-update-fields.html
Best regards,
Thanks. It helps.