Free Support Forum - aspose.com

Merge some fields only on last page

I wonder if I can ask this question here?

I’ve created a word template which displays the details and summary portions. The problem is that the Summary portion is required only at the last page after all the details are output. For example:

pg 1
-----
detail 1
detail 2
detail 3

pg 2
-----
detail 4
detail 5

Summary fields


I would really appreciate if anyone can give me some idea on how to achive this.

Thanks,
Ben

Hi Ben,

Mail Merge Regions were added in Aspose.Word 1.2 just for this sort of task.

You need to use two data tables and wrap them using TableStart:xxx and TableEnd:xxx mail merge fields. Your document should look something like this:

TableStart:MyDetailTable
DetailField1, MERGEFIELD DetailField2 and so on
TableEnd:MyDetailTable

TableStart:MySummaryTable
SummaryField1, SummaryField2
TableEnd:MySymmaryTable

Then you need to create data tables and set their names to MyDetailTable and MySummaryTable respectively.

Then you either need to run mail merge twice passing table each time or put both tables into a dataset and invoke mailmerge once passing the dataset as a parameter.


Thanks for the reply. I’ll give it a try.

Regards,
Ben