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

Free Support Forum - aspose.com

Aspose word - Extract a row from table from one document

I am new to Aspose Word and i have a scenario where i need to extract particular content of a word macro .docm file and paste in specfic sections of another word document.

How to do this?

@agowtham3

You can use NodeImporter.ImportNode method to import a row node from one document into another.

Before a node from another document can be inserted into this document, it must be imported. During import, document-specific properties such as references to styles and lists are translated from the original to the importing document. After the node was imported, it can be inserted into the appropriate place in the document using CompositeNode.InsertBefore or CompositeNode.InsertAfter.

Below code example shows how to import a row from one document into another document.

Document dstDoc = new Document(MyDir + "Doc2.docx");
Document srcDoc = new Document(MyDir + "Doc1.docx");

NodeImporter nodeImporter = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting);

Row row = srcDoc.FirstSection.Body.Tables[0].Rows[1];
Node impNode = nodeImporter.ImportNode(row, true);

Table table = dstDoc.FirstSection.Body.Tables[0];
table.Rows.Add(impNode);

dstDoc.Save(MyDir + "out.docx");