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

Free Support Forum - aspose.com

Import a node(table) from one document into a new empty document

Hi.
I got a problem trying to deal with a template that im converting to Aspose code.

Im trying to import a node(table) from one document into a new empty document using a bookmark to find it.

I will use mailmerge on that new document.

Then i will insert the new document at the bookmark node.

I found code to insert the document but i didnt find any code to import a node to a empty document and i have a hard time to get this working correctly.

Can you help me with this issue?

Regards
/Joel

Hi
Thanks for your inquiry. You should just import node to another document and insert the imported node into the destination document. For example see the following code:

// Open source document
Document srcDoc = new Document(@"Test039\src.doc");
// Open or create destination document
Document dstDoc = new Document();
// Get node form src document
// Let's get first table for example
Table srcTable = srcDoc.FirstSection.Body.Tables[0];
// Import this node
Node dstNode = dstDoc.ImportNode(srcTable, true, ImportFormatMode.KeepSourceFormatting);
// Insert this node into the destination document
// You also can use InsertAfter and InsertBefore methods
dstDoc.LastSection.Body.AppendChild(dstNode);
// Save dst document
dstDoc.Save(@"Test039\out.doc");

I hope this could help you.
Best regards.

dstDoc.LastSection.Body.AppendChild(dstNode);

This line is what was missing.

This seems to work nice with for the nested repeaters in the original MHTML report i had.

Thank you so much for the help.