Creating a simple PowerPoint file with Python

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. hello-world.png

documentation https://python-pptx.readthedocs.org/en/latest/index.html#api

Recommended Posts

Creating a simple PowerPoint file with Python
Creating a simple app with flask
I made a simple blackjack with Python
I made a configuration file with Python
How to read a CSV file with Python 2/3
Procedure for creating a LineBot made with Python
Start a simple Python web server with Docker
[Python] Make a simple maze game with Pyxel
A memo when creating a python environment with miniconda
Commands for creating a python3 environment with virtualenv
A simple to-do list created with Python + Django
Create a Photoshop format file (.psd) with python
Read line by line from a file with Python
I want to write to a file with Python
Open a file dialog with a python GUI (tkinter.filedialog)
Try creating a compressed file using Python and zlib
Draw netCDF file with python
Divide each PowerPoint slide into a JPG file and output it with python
Creating an egg with python
Make a simple Slackbot with interactive button in python
Let's make a simple game with Python 3 and iPhone
Problems when creating a csv-json conversion tool with python
Make a fortune with Python
Creating a temperature control system with Raspberry Pi and ESP32 (3) Recipient Python file
Run a Python file with relative import in PyCharm
[Python] Create a Tkinter program distribution file with cx_Freeze
Create a directory with python
What is God? Make a simple chatbot with python
[Piyopiyokai # 1] Let's play with Lambda: Creating a Python script
Download csv file with python
[Vagrant] Set up a simple API server with python
Create a 2d CAD file ".dxf" with python [ezdxf]
Try creating a Deep Zoom file format .DZI in Python
I made a simple typing game with tkinter in Python
[Python] Create a file & folder path specification screen with tkinter
I made a simple book application with python + Flask ~ Introduction ~
Create a simple video analysis tool with python wxpython + openCV
Creating a GUI as easily as possible with python [tkinter edition]
Create a simple Python development environment with VSCode & Docker Desktop
[Python] Make a simple maze game with Pyxel-Make enemies appear-
(For beginners) Try creating a simple web API with Django
[Python] What is a with statement?
Solve ABC163 A ~ C with Python
Extract the xz file with python
Operate a receipt printer with python
A python graphing manual with Matplotlib.
Creating a wav file split program
[Python] Write to csv file with Python
[Automation with python! ] Part 1: Setting file
Creating a decision tree with scikit-learn
Implemented file download with Python + Bottle
Let's make a GUI with python.
Creating a Flask server with Docker
Build a deb file with Docker
Solve ABC166 A ~ D with Python
Output to csv file with Python
Create a virtual environment with Python!
Create an Excel file with Python3
Creating a simple table using prettytable
I made a fortune with Python.
Create a binary file in Python