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

Free Support Forum - aspose.com

Table within a table using aspose?


i do have a case where a table is being merged with some data, it will be multiple rows.
i do have another table below that which also merges some data. My case is that, the 1st row in the first table is related to the second table.
So i should get the first row of the first table followed by some rows associated with the second table and then second row of first table followed by associated rows of second table. and soon.
How is it possible?
In the case you did not understand my question, i am attaching a word template.It is better if you see the attachment.
Please do tell me how to do that?



Thanks for your inquiry. I think that a solution for you is building up a resulting document from several documents. You should use two templates. See the following code. Templates are attached.

public void TestMailMerge_105146()


DataTable list = new DataTable("list");








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


DataRow row = list.NewRow();

row["LineNbr"] = i.ToString();

row["TermStart"] = DateTime.Now.ToString();

row["TermEnd"] = DateTime.Now.ToString();

row["NbrVisits"] = "10";

row["Product"] = "test";

row["Nbrs"] = "10";

row["Price"] = "100";



//open template

Document doc = new Document(@"400_105146_raviteja\in1.doc");

doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField_105146);


//save document



void MailMerge_MergeField_105146(object sender, MergeFieldEventArgs e)


if (e.FieldName == "list1")


DocumentBuilder builder = new DocumentBuilder(e.Document);


DataTable list1 = new DataTable("list1");




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


DataRow row = list1.NewRow();

row["LineQty"] = i.ToString();

row["LineType"] = "abc";

row["LineSN"] = i.ToString();



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


InsertDocument(builder.CurrentParagraph, doc2);



I hope that this information will help you. Please let me know if you would like to know something else.

Best regards.


where is the method for Insert Document. Can you pleae give me that one


Got the Insert Document, Dont worry about that.Thank you. Thats working.

when i am inserting data from the database the merge fields in the second document are not merging properly. i mean for the first row of first document, the second document rows are merignf fine, when coming to the second row, the second doucment mergefileds, i got twice the data,
In the documnet attached, the data in teh second document , there are only two rows, but for the second row, u can see 4 rows.

Please let me know how to solve it.



Are you sure that there are only 2 rows? Could you please provide me data that you use to perform mail merge (you can store data to XML file and attach it here). I will investigate this and provide you more information soon.

Best regards.

In database there are only two rows. but i think something wrong is there with teh code, i am attaching the code. Even the xml genereated is also coming with 4 rows. So please do let me know, if there is somwthing wrong with the code.I think the datatable for teh second document is filling twice, how to solve it.

Sorry once again, I got it. Thank you very much for every thing.

I modified your code. I think that this will solve your problem.

Best regards.