我必须编辑一个pptx模板,其中包含如下表:

如何将存储在python中的值附加到空字段?我正在使用pptx模块,但是我找不到任何这样做的例子。
from pptx import Presentation
prs = Presentation('template.pptx')
slide = prs.slides[2] #<- This is the slide that contains the table
shape = slide.shapes #<- As I understood This gives access to the shapes
textframe=shape.textframe
textframe.clear()
prs.save('test.pptx') #<- Saves the new file发布于 2014-04-09 09:37:22
引用python-ppty developer的dev-group
-if --你知道它的索引,类似于table = slide.shapes[2]的东西--就能做到这一点。然后,您需要在更改单元格的内容之前导航它们:
for idx, row in enumerate(table.rows):
if idx = 0: # skip header row
continue
name_cell = row.cells[0]
name_cell.text = 'foobar'
corners_cell = row.cells[1]https://stackoverflow.com/questions/22912467
复制相似问题