I have a sql table as shown below
Name | Address | Industry
N1 | Add1 | Ind1
N2 | Add2 | Ind2
I am trying to merge the sql table as shown below
But it repeats the header as well
i just want to repeat the first 2 rows and not the header as shown below
so is there any option to repeat the particular section of table instead ?
@SachinSingh You should build your template like this:
And use MailMergeCleanupOptions.RemoveEmptyParagraphs
cleanup option to get rid the empty paragraph between tables, in this case the tables will be joined into one table. For example see the following code and attached template and result documents:
DataTable data = new DataTable("tblEmployerDetails");
data.Columns.Add("EmployerName");
data.Columns.Add("EmployerAddress");
data.Columns.Add("EmployerIndustry");
data.Rows.Add("John Dou", "Unknown city, Unknown street", "Unknown");
data.Rows.Add("James Bond", "85 Albert Embankment in Vauxhall, London", "Spy");
Document doc = new Document(@"C:\Temp\in.docx");
// Instruct Aspose.Words to remove empty paragraphs after executing mail merge.
doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs;
doc.MailMerge.ExecuteWithRegions(data);
doc.Save(@"C:\Temp\out.docx");
in.docx (13.1 KB)
out.docx (10.4 KB)