Free Support Forum - aspose.com

Word mergefield doubt

i am new to aspose i have a doubt

how can i display a set of values using a single merge field

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your interest in Aspose.Words. I think that you can use mail merge with regions. Please see the following links to learn more:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/mail-merge-with-regions-explained.html

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/execute-mail-merge-with-regions.html

Hope this helps.

Best regards.

hi alex,

thank u for kind suggestion, but mine requirement is different

can i itterate the same executeregion method with different argument,

i tried that but it does not shown me all the possible result , instead it just shown me a single result in a single page

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I created small demo for you. See the following code and attached documents.

//Create DataTable that will be used as data source for mail merge

DataTable clientInfo = new DataTable("clientInfo");

//Add columns to dattaTable

clientInfo.Columns.Add("FirstName");

clientInfo.Columns.Add("LastName");

clientInfo.Columns.Add("Company");

clientInfo.Columns.Add("City");

//Insert some data into the datatable

clientInfo.Rows.Add(new object[] { "Alexey", "Noskov", "Aspose", "<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Auckland" });

clientInfo.Rows.Add(new object[] { "John", "Smith", "Microsoft", "Los Angeles" });

clientInfo.Rows.Add(new object[] { "Jain", "Martin", "IBM", "London" });//etc...

//Open first template (without regions)

Document doc = new Document(@"Test312\in_withoutRegions.doc");

//Execute simple mail merge

//Data from each row will be placed on the separate page

doc.MailMerge.Execute(clientInfo);

//Sace result document

doc.Save(@"Test312\out_whithoutRegions.doc");

//Open enother template (with regions)

Document doc1 = new Document(@"Test312\in_withRegions.doc");

//Execute mail merge with regions

//Data from each row will be placed on the single page(without breaks)

doc1.MailMerge.ExecuteWithRegions(clientInfo);

//Save result document

doc1.Save(@"Test312\out_withRegions.doc");

Also please attach your template and create the result document manually to show me how the output should look. I will try to help you.

Best regards.