Free Support Forum - aspose.com

Tables with IF Conditions no longer rendering with Aspose.Words 10.5

Word template docs that have tables within IF conditions which work find with Aspose.Words 9.5 are no longer working after the 10.5 upgrade. All it shows are the mergefield/field code names but no merged data.

If I remove the IF conditions, the tables display fine with 10.5. Something has changed around IF condition determination and "nested" tables within them.

Please find details attached. Thanks in advance.

Hello

Thanks for your request. Could you please provide me the code which will allow me to reproduce the problem on my side? I will check it and provide you more information.

Best regards,

Andrey - I've attached a little Windows Form app that will process the template and source XML files I attached earlier. I did NOT include the license file (for security reasons) OR the Aspose.Words 9.5 / 10.5 dlls.

For the TestMerge project, just swap out the Aspose.Words reference (currently it is the 9.5 version) to see the differing results from v9.5 to v10.5.

I'm just interested in the "PENSIONABLE EARNINGS AND YMPE" section of the merged document. Again, when using the 9.5 reference, merge works fine. If using 10.5, the table merge does not work due to the conditionals.

Thanks.

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi

Thank you for additional information. The behavior looks quite odd but it is correct. Aspose.Words actually fills the region inside IF field, but when you execute mail merge with regions, Aspose.Words updates fields only inside the regions, but since IF field is outside the region, it is not updated. On the other hand when you execute simple mail merge, Aspose.Words updates fields in whole document. Since you are executing simple mail merge before mail merge with regions, IF field is updated when the region is not filled. So as a result, you see not filled region as a value of IF field.

There are two simple solutions:

1. Switch simple mail merge and mail merge with regions, i.e. execute simple mail merge after executing mail merge with regions.

2. Call UpdateFields just before saving the document.

Best regards,

Andrey, thanks for the quick response. I have verified that both of your solutions offered work. Just two remaining questions.

1) Do you have a preference (based on your understanding) which solution fix is lower risk? Since we were doing Execute() and ExecuteWithRegions() in that order, should I just use the UpdateFields() fix?

2) Since merge worked with v9.5, was this an Aspose.Words processing/interpretation change?

Thanks again.

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi

Thanks for your request.

1. I think the first solution is better, because in this case UpdateFields is called only once (when simple mail merge is executed). So performance will not be affected by the second call of UpdateFields directly in your code.

2. Yes, this started to occur after changes/improvements in our reporting engine.

Best regards,