Free Support Forum - aspose.com

Urgent ! Help in Insert document with Main Document

Hi,

I have one main document with the set of merge fields. And I am inserting one sub document to main document to acheive the nested mail merge.

My sub document also have some merge field.

I am using the code from the below path:

<A href="https://forum.aspose.com/t/108116</A></P> <P>For ex:</P> <P> Ter Range : 12 to 50</P> <P> Subject : Subject1</P> <P> <Sub document Contenet></P> <P> Service1</P> <P> Service2</P> <P> Service3</P> <P> </Sub document Contenet></P> <P> Ter Range : 18 to 50</P> <P> Subject : Subject2</P> <P> <Sub document Contenet></P> <P> Service1</P> <P> Service2</P> <P> Service3</P> <P> </Sub document Contenet></P> <P> The sub document data is repeating for all the merge fields in the main document. I want to show the sub document data only once in my main document or at the end of main document. </P> <P>Please help me...Its very urgent</P>

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

Thanks for your request. I think that you can merge document after performing mail merge. For example see the following code:

//Prepare datasource for first template

DataTable table = new DataTable("myTable");

table.Columns.Add("Name");

table.Columns.Add("Company");

for (int i = 0; i < 5; i++)

{

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

}

//Open first template

Document doc1 = new Document(@"Test187\in1.doc");

//Execute mail merge

doc1.MailMerge.Execute(table);

//Prepare data for second template

string[] names = { "Summary" };

string[] values = { "This is summary" };

//Open second template

Document doc2 = new Document(@"Test187\in2.doc");

//Execute mail merge

doc2.MailMerge.Execute(names, values);

//Marge documents togather

foreach (Section sect in doc2.Sections)

{

if (sect.Equals(doc2.FirstSection))

sect.PageSetup.SectionStart = SectionStart.Continuous;

//import section

Node newSection = doc1.ImportNode(sect, true, ImportFormatMode.KeepSourceFormatting);

doc1.Sections.Add(newSection);

}

//Save document

doc1.Save(@"Test187\out.doc");

Hope this helps.

Best regards.

The issues you have found earlier (filed as 39) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(60)