Hi, when using the ‘Mustache’ mail merge option if the <span style=“font-size:10.0pt;font-family:“Arial”,sans-serif;
mso-fareast-font-family:Arial;mso-bidi-font-family:“Times New Roman”;
mso-ansi-language:EN-AU;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>{{#foreach}} <span style=“font-size:10.0pt;font-family:“Arial”,sans-serif;
mso-fareast-font-family:Arial;mso-bidi-font-family:“Times New Roman”;
mso-ansi-language:EN-AU;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>{{/foreach}} section spans a section break the error below is thrown:
{“Mail merge region ‘PL_NOA’ is badly formed. TableStart and TableEnd should be in the same section, same table row or same table cell.”}
Sample code below:
DataSet ds = new DataSet();
ds.ReadXml(@“c:\temp\PL_NOA_data.xml”);
Aspose.Words.Document doc = new Aspose.Words.Document(@“c:\temp\PL_NOA.docx”);
doc.MailMerge.CleanupOptions=Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveUnusedFields|Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveEmptyParagraphs|Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveUnusedRegions|Aspose.Words.MailMerging.MailMergeCleanupOptions.RemoveContainingFields;
doc.MailMerge.UseNonMergeFields = true;
doc.MailMerge.ExecuteWithRegions(ds);
doc.Save(@“c:\temp\PL_NOA_output.docx”);
Am I doing something wrong or is this a bug?
Have attached the template and XML
Regards,
Bernard
Hi Bernard,
Thanks for your inquiry.
Please note that TableStart and TableEnd fields must be inside the same
section in the document. Please remove the section break inside {{#foreach}} and {{/foreach}} from your document.
I suggest you please read the rules when marking a region from here:
http://www.aspose.com/docs/display/wordsnet/Mail+Merge+with+Regions+Explained
In your case, I suggest you please replace section break with page break. Please check the attached document. Hope this helps you.
Thanks for the tip. All good.
Hi Bernard,
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.