Reading text values in a PowerPoint table using pptx?

喜夏-厌秋 提交于 2019-12-24 14:27:06

问题


Using the pptx module,

 tbl.cell(3,3).text

is a writable, but not a readable attribute. Is there a way to just read the text in a PowerPoint table? I'm trying to avoid COM and pptx is a great module, but lacks this particular feature.

Thanks!


回答1:


At present, you'll need to go a level deeper to get text out of a cell using python-pptx. The cell.text 'getter' is on the roadmap.

Something like this should get it done:

cell = tbl.cell(3, 3)
paragraphs = cell.textframe.paragraphs
for paragraph in paragraphs:
    for run in paragraph.runs:
        print run.text

Let me know if you need more to go on.



来源:https://stackoverflow.com/questions/24045996/reading-text-values-in-a-powerpoint-table-using-pptx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!