33
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

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
35
0

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
35

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?