Merging with different styles in IF and regions

I am trying to achieve a dynamic brochure listing where rows of catalogue items may be 5 or 3 items across - depending on the data.
I already have a fixed 5 items per row catalogue working, so this question is not about the mail merge, use of Next or any of these other fields in the screenshot.

I thought I could use an IF to test a data value for the column “ItemPerRow” which is in the “Property” table, but using the format as shown I get no output at all.
I would a like simple steer as to where to start to try to achieve as per the screenshot please.

Capture.JPG (159.3 KB)


Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

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

PS: To attach these resources, please zip and upload them.

Hi Tahir,
I am only looking for a simple steer in the right direction at the moment.
As you can see in the attached ZIP file, the documentxml.xml has several tables in it. One of them is called Property, which has a column called ItemPerRow.
The word template has tablestart and tableend for Property. It has some debug merge fields to print out ItemPerRow.
There are two IF statements wrapping row designs. The IF statement tests ItemPerRow and should only render the row design IF those statements are true. This does not happen. The IF statements and BOTH rows are rendered.
If I remove the IF statement everything works.
So my question is - how do I have the document render different row layouts based on conditional logic?


Thanks for sharing the detail. Unfortunately, we have not found the ZIP file with your post. Please attach it again. Thanks for your cooperation. (4.5 MB)


Thanks for sharing the detail. Please use the ItemPerRow mail merge field as shown below in the IF field. We have attached the modified input document with this post for your kind reference. (34.1 KB)

{ IF “{ MERGEFIELD ItemPerRow }” = “4” “table content” }

Hope this helps you.

Excellent, thanks.


Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.