5
3

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 3 years have passed since last update.

【Python】python-pptxでテーブルスタイルを書き換える方法【python-pptx】

Posted at

概要

  • pythonで自動pptx作成をしたい。
  • tableのstyleが気に食わないので変更したい!
  • document見ながらやってるのになぜ動かん。。。

問題

  • githubを参考にしても、うまく動かなかった。
  • shape._elementがそもそもいないんだが?

解決方法

  • UUIDをgithubから拾って、入れ替えることで任意のスタイルに変更ができる。
table = slide.shapes.add_table(rows, cols, table_left, table_top, table_width, table_height).table

tbl = table._graphic_frame.element.graphic.graphicData.tbl
style_id = '{E8B1032C-EA38-4F05-BA0D-38AFFFC7BED3}' #UUIDはgithub参照
tbl[0][-1].text = style_id

まとめ

  • 業務時間削減のために、自動化してるのにデザインに凝ってしまい、結果増大させることになった。
  • 悩んでいる人の助けになれば…
5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?