Free Support Forum - aspose.com

Merging Sections/Regions in a word Document with views

Dear All,

I am trying to merge a word document with views. I want a section of a document to be merged with the first view and another section of document to be merged with second view. So when i see the document using aspose pdf , it will show the contents from different view dynamically. For that i have already used a dataset which will fetch data from two different datatable and later i have to merge the document with those datatables but when i try using this concept it doesnt work.I have used doc.mailmerge.executewithregions(), but still no results.

Please help asap.

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

Thanks for your request. Could you please attach your document and provide me code that will allow me to reproduce this issue?

As an example you can use the following code and attached documents.

//Create DataTable

DataTable info = new DataTable("Info");

//Add columns

info.Columns.Add("FirstName");

info.Columns.Add("LastName");

info.Columns.Add("Company");

//Add rows

info.Rows.Add(new object[] { "Alexey", "Noskov", "Aspose" });

info.Rows.Add(new object[] { "Den", "Michel", "Nicon" });

//Create another DataTable

DataTable companyInfo = new DataTable("CompanyInfo");

//Add columns

companyInfo.Columns.Add("Name");

companyInfo.Columns.Add("City");

//Add rows

companyInfo.Rows.Add(new object[] { "Aspose", "Cidney" });

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

//Create DataSet

DataSet ds = new DataSet();

//Add tables

ds.Tables.Add(info);

ds.Tables.Add(companyInfo);

//Open template document

Document doc = new Document(@"Test153\in.doc");

//Execute maeil merge

doc.MailMerge.ExecuteWithRegions(ds);

//Save output document

doc.Save(@"Test153\out.doc");

Best regards.

Thanks a lot for your quick support . the issue has been resolved.