Python: copy content from one document document to another document and save format?

As the title says, I would like to know if there is any module that will allow me to analyze the content from one Microsoft Word document to another through python and save the format.

I want to read the table data and transfer it to another table in another document.

enter image description here

Both documents A and B exist. I just want to be able to go through cells in both documents (not necessarily at the same time) and copy the contents without worrying about whether the text is formatted (font, italics, bold) or contains bullets.

I ask python since this is my favorite language ...

+4
source share
1

Kasra python-docx:

.

:

from docx import *

document = opendocx('xxxzzz.docx')
table = document.xpath('/w:document/w:body/w:tbl', namespaces=nsprefixes)[0]

:

output = opendocx('yyywwww.docx')
body = output.xpath('/w:document/w:body', namespaces=nsprefixes)[0]

body.append(table)

output.save('new-file-name.docx')
+4

All Articles