GemBox Support Forum

Document - Mail Merging


I want to generate the report for the student where I have already set the template in the word document with the help of merge fields and I have a list of student details in excel in tabular format and I want to generate the report for each student details which is present in the excel sheet.

Can you please tell me the way for doing the same ?
How I will able to replicate the template in next page of the word document for each details ?

Please find the attached sample image of report.


With Regards
Nitin Srivastava

The mail merge you want looks very similar to this example:

It is possible to read in the Excel sheet and make it into a relational data source. It needs to be a DataSet with one DataTable for student name and one for the marks.
I’ve just done something similar by reading in a file with GemBox.Spreadsheet methods, converting that into a DataTable + added the extra table and dataset structure I needed.
The nested mail merge (as in the example) can do the rest.
There may be smarter ways of creating the data source, but this method will work.

Hi Nitin,

As Karin suggested, you could check the Nested Merge example, it demonstrates how to generate such a report.

Note, with nested merge you would create a single document that contains details for all the students.
But if you want to generate one document for each student, then you won’t need a nested merge, you would need just a Merge Range and execute a mail merge process multiple times, for each student record in your data source.

I hope this helps, let me know if you need anything else.