gpt4 book ai didi

python - 使用 python-pptx 创建 PPT 时如何使用我公司的 PPT 幻灯片布局?

转载 作者:行者123 更新时间:2023-12-01 04:31:30 28 4
gpt4 key购买 nike

如果我编写并执行这段代码

from pptx import Presentation
prs = Presentation()
slide_layout = prs.slide_layouts[0]
prs.save("Final.pptx")

它创建一个只有一张幻灯片的 PPT,这是一张未经编辑的标准标题幻灯片。

但在 MS Powerpoint 中我可以看到我公司的许多布局。我想使用他们的布局。请告诉我该怎么做。

最佳答案

您可以使用 Powerpoint 保存具有所需布局的文件,然后将其打开:

from pptx import Presentation
prs = Presentation('company-layout.pptx')

参见the documentation :

You can open any PowerPoint 2007 or later file this way (.ppt files from PowerPoint 2003 and earlier won’t work). While you might not be able to manipulate all the contents yet, whatever is already in there will load and save just fine. The feature set is still being built out, so you can’t add or change things like Notes Pages yet, but if the presentation has them python-pptx is polite enough to leave them alone and smart enough to save them without actually understanding what they are.

If you use the same filename to open and save the file, python-pptx will obediently overwrite the original file without a peep. You’ll want to make sure that’s what you intend.

关于python - 使用 python-pptx 创建 PPT 时如何使用我公司的 PPT 幻灯片布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32347821/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com