We're sorry Aspose doesn't work properply without JavaScript enabled.

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:
https://forum.aspose.com/t/108116
For ex:

  Ter Range : 12 to 50
  Subject : Subject1
<Sub document Contenet>
    Service1
    Service2
    Service3
</Sub>
  Ter Range : 18 to 50
  Subject : Subject2
<Sub document Contenet>
    Service1
    Service2
    Service3
</Sub>

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.
Please help meā€¦Its very urgent

Hi
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)