我正在使用 python pptx 模块自动更新 powerpoint 文件中的值。我可以使用以下代码提取文件中的所有文本:
from pptx import Presentation
prs = Presentation(path_to_presentation)
# text_runs will be populated with a list of strings,
# one for each text run in presentation
text_runs = []
for slide in prs.slides:
for shape in slide.shapes:
if not shape.has_text_frame:
continue
for paragraph in shape.text_frame.paragraphs:
for run in paragraph.runs:
text_runs.append(run.text)
Run Code Online (Sandbox Code Playgroud)
此代码将提取文件中的所有文本,但无法提取 ppt 表中的文本,我想更新其中一些值。我试图从这个问题中实现一些代码:Reading text values in a PowerPoint table using pptx? 但不能。有任何想法吗?谢谢。