VOOZH about

URL: https://qiita.com/daiki7nohe/items/11019e90cd43c82095fa

⇱ Pythonで簡単なパワポファイルの作成 #Python - Qiita


👁 Image
33

Go to list of users who liked

35

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@daiki7nohe(Daiki Urata)in👁 Image
株式会社Fusic

Pythonで簡単なパワポファイルの作成

33
Last updated at Posted at 2015-06-09

Pythonライブラリpython-pptxをつかってプログラムから簡単なpptxファイルを作成します。

まずはpipをつかってライブラリをインストールします。
Pythonのパッケージ管理ツールpipのインストール(Windows)

pip install python-pptx

これでOKです。

では簡単なパワポをつくってみます。

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')

実行しますとtest.pptxというファイルが同じディレクトリにつくられます。
python test.py

開くとこんな感じのスライドができます。
👁 hello-world.png

ドキュメンテーション
https://python-pptx.readthedocs.org/en/latest/index.html#api

33

Go to list of users who liked

35
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33

Go to list of users who liked

35