Create a simple pptx file programmatically using the python library python-pptx.
First, use pip to install the library. Install Python package management tool pip (Windows)
pip install python-pptx
This is OK.
Let's make a simple PowerPoint.
test.py
from pptx import Presentation
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = "Hello, World!"
subtitle.text = "python-pptx was here!"
prs.save('test.pptx')
When executed, a file called test.pptx will be created in the same directory.
python test.py
When you open it, you can make a slide like this.
documentation https://python-pptx.readthedocs.org/en/latest/index.html#api
Recommended Posts