Questions tagged [python-pptx]

python-pptx is a Python library for creating and updating PowerPoint (.pptx) files.

python-pptx is a Python library for creating and updating PowerPoint (.pptx) files.

Latest documentation

Available from pypi.

734 questions
15
votes
2 answers

Fail: AttributeError: module 'collections' has no attribute 'Container'

I try to start python-pptx, but I have Error: AttributeError: module 'collections' has no attribute 'Container' in File "...\lib\site-packages\pptx_init_.py", line 14 Use Python 3.10, python-pptx (0.6.21), lxmx (4.6.3). Please, help me.
Vladzrabbit
  • 167
  • 1
  • 1
  • 3
15
votes
2 answers

How to delete unpopulated placeholder items using python-pptx

This is very simple, but I cannot find the actual method anywhere in the documentation or otherwise. I am using the python-pptx module and all I need to do is delete a single placeholder item, an empty text box, on some slides (without having to…
Jacristi
  • 153
  • 1
  • 5
14
votes
6 answers

How to copy a slide with python-pptx?

How can I copy a slide? I created a template slide and I need to copy it and edit shapes of each copy separately. Or how I can add my template slide to presentation.slide_layouts?
Renat Nagaev
  • 746
  • 2
  • 6
  • 16
13
votes
2 answers

python pptx align image to center of slide

I need to add an image to a pptx slide, and want to locate it in the center of the slide, without having to calculate the size and alignment manually, I found a question about doing so with text: question about center aligning text And the…
thebeancounter
  • 4,261
  • 8
  • 61
  • 109
11
votes
2 answers

python inserts pictures to powerpoint, how to set the width and height of the picture?

New to python-pptx package. https://python-pptx.readthedocs.io/en/latest/ Would like to insert pictures to powerpoint. How can I set the width and height of the picture? Code I have now: from pptx import Presentation from pptx.util import…
Lisa
  • 4,126
  • 12
  • 42
  • 71
9
votes
3 answers

Python PPTX: Adding Entire Slide from Another Presentation

It seems this issue was brought up and requested back in 2015 but I cannot find any updates on it. I'm trying to copy an entire slide (including its text and images) from another presentation into my working presentation by doing something like the…
CBK
  • 660
  • 1
  • 7
  • 16
9
votes
3 answers

Center-align text with Python-pptx

Question in short: Is it possible to align text to the center in Python-pptx? Since I'm using Python-pptx, I have been able to automate quite a lot of things and I really enjoy using it! However, I've run into a problem. I'm trying to center my text…
PythonPupil1906
  • 125
  • 1
  • 1
  • 8
8
votes
1 answer

Can you change the Placeholder type using python-pptx?

The standard layouts for Powerpoint appear to have "Content" placeholders which appear as the type SlidePlaceholder. Is there a way to change these placeholders to another type? For example, I would really like to insert a picture into one of these…
mcdevitts
  • 83
  • 1
  • 3
8
votes
1 answer

Python PPTX table.cell color

So guys here's my problem I would like to fill my table cells with different colors from the default ones... I've checked the docs and made multiple searches on google but couldn´t find something helpful. Here's my code: def…
João Figueiredo
  • 107
  • 1
  • 1
  • 12
8
votes
1 answer

python pptx change entire table font size

I use python 2.7 with python pptx to create a presentation with a slide that contain a table with data. I need to control the size of the table and text. I looked for ways to do so, and I found some things about changing a particular cell's font…
thebeancounter
  • 4,261
  • 8
  • 61
  • 109
7
votes
1 answer

How to create a text shape with python pptx?

I want to add a text box to a presentation with python pptx. I would like to add a text box with several paragraphs in the specific place and then format it (fonts, color, etc.). But since text shape object always comes with the one paragraph in the…
user1039698
  • 143
  • 1
  • 6
7
votes
1 answer

Why does saving a presentation to a file-like object produce a blank presentation?

As a response to this answer to a previous question of mine, I wrote the following short program to try and reproduce the problem. from pptx import Presentation from io import BytesIO p = Presentation() slide =…
MichaelPlante
  • 452
  • 1
  • 4
  • 14
7
votes
3 answers

How to save a presentation to a file-like object in Python 3

Python 3 replaced StringIO.StringIO with io.StringIO. I've been able to successfully save presentations using the former, but it doesn't appear to work for the latter. from pptx import Presentation from io import StringIO presentation =…
MichaelPlante
  • 452
  • 1
  • 4
  • 14
7
votes
3 answers

Python-PPTX: Changing table style or adding borders to cells

I've started putting together some code to take Pandas data and put it into a PowerPoint slide. The template I'm using defaults to Medium Style 2 - Accent 1 which would be fine as changing the font and background are fairly easy, but there doesn't…
JJFord3
  • 1,976
  • 1
  • 25
  • 40
7
votes
1 answer

Edit Header and Footer using python-pptx

Can I edit the Header & Footer of an existing Presentation using python-pptx? The values I want to set are as shown in the attached image. Thanks.
Vishal
  • 2,097
  • 6
  • 27
  • 45
1
2 3
48 49