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

Free Support Forum - aspose.com

Aspose.words copying only one table/section from one docx to another docx


Can you please help me here? I was wondering whether we can copy only one table from one docx to another docx?

Say for example, I have a docx “master.docx”. I have another docx “child.docx”.

Can I copy table1 from child.docx and put it in a specific place in master.docx?

Please let me know.

Thanks & Regards,
Sivaraj. I

Hi Sivaraj,

Thanks for your inquiry. Please try executing the following code to copy a Table from one Document to another.
Document dstDoc = new Document(getMyDir() + “doc1.docx”);
Document srcDoc = new Document(getMyDir() + “doc2.docx”);

Table importedTable = (Table)dstDoc.importNode(srcDoc.getFirstSection().getBody().getTables().get(0), true);
Paragraph para = dstDoc.getFirstSection().getBody().getFirstParagraph();
para.getParentNode().insertBefore(importedTable, para);

dstDoc.save(getMyDir() + “out.docx”);

I hope, this helps.

Best regards,


Thanks for the quick response and it really helped me. I was out of station hence a late reply.