Need help with mailmerge conditional statement

I’ve been asked to try an resolve an issue with an existing project that uses Aspose.Words (16.6.0.0) & Aspose.Cells (8.9.0.0).

The issue I’m dealing with was one where a mailmerge (using Aspose.Word) is carried out and as a result there are many instances of the document created, this is due to there being multiple records, however I was able to amend the mailmerge statement causing this to:

Funding Name: { MAILMERGE TableStart:CoursBookingCost } { MAILMERGE CourseBookingCost_FundingTypeName } {MAILMERGE TableEnd:CourseBookingCost }

This gives me the one document but ends up with the record values repeated for each record in the table, this is a better result as they end up with only one document, but they still have to edit it to remove the surplus record results.

An example mailmerge result would be

“Funding Name: TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1 TEST1”

What I’m looking for is for a way to return just the first record and display it in the document so that it appears as:

“Funding Name: TEST1”

Is anyone aware of a mailmerge conditional statement I can use within the template document that would accomplish this, as the system is live I’m not in a position to amend any of the underlying code.

Many Thanks

Rudi

@rarcoles,

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

  • Your simplified input Word document
  • Sample XML file containing the data to build report from
  • Aspose.Words 18.8 generated output DOCX file showing the undesired behavior
  • Your expected DOCX Word document. You can create expected document by using Microsoft Word.
  • Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your 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 issue and provide you code to achieve the same by using Aspose.Words. Thanks for your cooperation.