I am using this code
DataSet dataSet = new DataSet();
// Approver's main information
DataTable tblApprovers = new DataTable("ApproverDetails");
tblApprovers.Columns.Add("ApproverDescription", typeof(string));
tblApprovers.Columns.Add("ApproverName", typeof(string));
tblApprovers.Columns.Add("ApprovalStatus", typeof(string));
tblApprovers.Columns.Add("ApprovalDate", typeof(string));
tblApprovers.Columns.Add("EmployeeCode", typeof(string));
tblApprovers.Rows.Add("Desc1", "Approver1", "Approved", "05 Jul, 2024 15:13","Admin");
// Approver's attributes
DataTable tblAttributes = new DataTable("ApproverAttr");
tblAttributes.Columns.Add("EmployeeCode", typeof(string));
tblAttributes.Columns.Add("Key", typeof(string));
tblAttributes.Columns.Add("Value", typeof(string));
tblAttributes.Rows.Add("Admin", "Location", "Mumbra");
tblAttributes.Rows.Add("Admin", "Designation", "Business Head");
dataSet.Tables.Add(tblApprovers);
dataSet.Tables.Add(tblAttributes);
dataSet.Relations.Add("Approvers_Attributes",
tblApprovers.Columns["EmployeeCode"],
tblAttributes.Columns["EmployeeCode"]);
Document doc = new Document("path_to_template.docx");
// Handle the mail merge with nested regions
doc.MailMerge.ExecuteWithRegions(dataSet);
// Save the output document
doc.Save("output.docx");
TestDoc.docx (32.8 KB)
But as you can see 2 rows are generating, how to resolve this.