How to add table and image on the same line using docx?

270 Views Asked by At

now i try to generate docx which using python-docx library, and my question is i want to known how to add the table and image locate at on the same line like the example below.

enter image description here

And this is my code.

from docx import Document
document = Document()
table = document.add_table(rows=3, cols=3,style='Table Grid')
document.add_picture('graph.png') 
document.save('test.docx')

The result.

enter image description here

1

There are 1 best solutions below

0
On

This would require "floating" items (floating table and/or floating chart), neither of which have API support in python-docx yet.