Read From PowerPoint Table in Python?

后端 未结 2 1869
旧巷少年郎
旧巷少年郎 2021-01-22 05:48

I am using the python pptx module to automatically update values in a powerpoint file. I am able to extract all the text in the file using the code below:

from          


        
2条回答
  •  既然无缘
    2021-01-22 05:54

    Your code will miss more text than just tables; it won't see text in shapes that are part of groups, for example.

    For tables, you'll need to do a couple things:

    Test the shape to see if the shape's .HasTable property is true. If so, you can work with the shape's .Table object to extract the text. Conceptually, and very aircode:

    For r = 1 to tbl.rows.count
       For c = 1 to tbl.columns.count
          tbl.cell(r,c).Shape.Textframe.Text ' is what you're after
    

提交回复
热议问题