WordDocument wordDocument = new WordDocument("Template.docx"); MailMergeDataSet dataSet = new MailMergeDataSet(); MailMergeDataTable dataTable = new MailMergeDataTable("Persons", GetPerson()); dataSet.Add(dataTable); dataTable = new MailMergeDataTable("Languages", GetLanguage()); dataSet.Add(dataTable); List<DictionaryEntry> commands = new List<DictionaryEntry>(); DictionaryEntry entry = new DictionaryEntry("Persons", string.Empty); commands.Add(entry); entry = new DictionaryEntry("Languages", string.Empty); commands.Add(entry); wordDocument.MailMerge.ExecuteNestedGroup(dataSet, commands); wordDocument.Save("Sample.docx"); |