如何使用docx在同一行上添加表格和图像?

问题描述

现在我尝试使用python-docx库生成docx,我的问题是我想知道如何添加表和图像,就像下面的示例一样,位于同一行。

enter image description here

这是我的代码

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')

结果。

enter image description here

解决方法

这将需要“浮动”项(浮动表和/或浮动图表),而python-docx中都没有API支持。