python-pptx in 2026: Automate PowerPoint Reports with Python

Automation Oct 13, 2026

Watch on YouTube

Every Monday someone on your team opens PowerPoint, pastes last week's numbers into a chart, fixes the table formatting and exports the deck. python-pptx turns that ritual into a script. It reads and writes .pptx files directly, with no PowerPoint installation, so it runs on Linux servers, in CI and in scheduled jobs. This tutorial was tested with python-pptx 1.0.2 on Python 3.13.5.

Why python-pptx in 2026?

  • Pure Python, works on any OS and in containers.
  • Native, editable PowerPoint charts (not static images).
  • Tables, text, images and slide layouts from any template.
  • Pairs perfectly with Excel automation with openpyxl for full Office reporting pipelines.

Install

pip install python-pptx

Build a complete sales report deck

The script below creates a 16:9 deck with a title slide, then a second slide holding a native clustered column chart and a formatted table. Finally it reopens the saved file to verify the result.

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.chart.data import CategoryChartData
from pptx.enum.chart import XL_CHART_TYPE

sales = {"North": 125000, "South": 98000, "East": 143500, "West": 87250}

prs = Presentation()
prs.slide_width, prs.slide_height = Inches(13.333), Inches(7.5)

title = prs.slides.add_slide(prs.slide_layouts[0])
title.shapes.title.text = "Q3 2026 Sales Report"
title.placeholders[1].text = "Generated automatically with python-pptx"

slide = prs.slides.add_slide(prs.slide_layouts[5])
slide.shapes.title.text = "Revenue by Region"
data = CategoryChartData()
data.categories = list(sales)
data.add_series("Revenue (USD)", list(sales.values()))
slide.shapes.add_chart(XL_CHART_TYPE.COLUMN_CLUSTERED, Inches(0.7), Inches(1.5),
                       Inches(7), Inches(5.5), data)

rows = len(sales) + 1
table = slide.shapes.add_table(rows, 2, Inches(8.2), Inches(1.8),
                               Inches(4.5), Inches(3)).table
table.cell(0, 0).text, table.cell(0, 1).text = "Region", "Revenue"
for i, (region, value) in enumerate(sales.items(), start=1):
    table.cell(i, 0).text = region
    table.cell(i, 1).text = f"${value:,.0f}"

prs.save("q3_sales_report.pptx")

check = Presentation("q3_sales_report.pptx")
print("Slides:", len(check.slides))
for n, s in enumerate(check.slides, start=1):
    kinds = [sh.shape_type for sh in s.shapes]
    print(f"Slide {n}: {s.shapes.title.text!r} -> {len(kinds)} shapes")
best = max(sales, key=sales.get)
print(f"Top region: {best} (${sales[best]:,.0f})")
print(f"Total revenue: ${sum(sales.values()):,.0f}")

Real output

Slides: 2
Slide 1: 'Q3 2026 Sales Report' -> 2 shapes
Slide 2: 'Revenue by Region' -> 3 shapes
Top region: East ($143,500)
Total revenue: $453,750

The saved file is about 35 KB and opens in PowerPoint, LibreOffice Impress and Google Slides. The chart stays editable, so viewers can restyle it or change the data later.

How it works

  • Presentation() starts from the default template; pass a path such as Presentation("brand.pptx") to reuse your company theme.
  • slide_layouts[0] is the Title layout and slide_layouts[5] is Title Only.
  • CategoryChartData holds categories and series; add_chart embeds an Excel-backed chart.
  • add_table(rows, cols, left, top, width, height).table returns a table whose cells you fill through cell(r, c).text.
  • Sizes use Inches, Pt or Emu, so layout math stays readable.

Production tips

  • Keep a branded template and only fill placeholders from code.
  • Load data from pandas, Polars or SQL and loop to create one slide per region or client.
  • Run the script on a schedule or trigger it when a data file lands, for example with file watching with watchfiles.
  • Reopen the saved file in a test, as above, to assert slide and shape counts.

Conclusion

With fewer than 50 lines of python-pptx you get a repeatable, editable PowerPoint report. Combine it with the other techniques in the ultimate Python automation guide and recurring slide decks become a one-command job.

Share:
Last updated: October 2026
Built-in Functions in Python 2026 str() in Python 2026: String Conversion + Modern Formatting & Best Practices memoryview with JAX in Python 2026: Zero-Copy NumPy → JAX Array Interop + Efficient ML Examples memoryview with TensorFlow in Python 2026: Zero-Copy NumPy → Tensor Interop + GPU Pinning & ML Examples memoryview with TensorFlow in Python 2026: Zero-Copy NumPy → Tensor Interop + ML Examples memoryview with NumPy & PyTorch in Python 2026: Zero-Copy Views, Efficient Slicing & ML Interop Examples memoryview with NumPy in Python 2026: Zero-Copy Views, Efficient Slicing & Real ML Examples memoryview() in Python 2026: Zero-Copy Magic for Large Binary Data + Real Examples import() in Python 2026: How It Works, Security Risks & Modern Alternatives (importlib) zip() in Python 2026: How to Use It, strict=True Behavior & Real-World Examples vars() in Python 2026: Accessing Object Namespace + Modern Introspection Patterns type() in Python 2026: Dynamic Type Inspection & Object Creation + Modern Patterns tuple() in Python 2026: Immutable Sequences + Modern Patterns & Best Practices super() in Python 2026: Method Resolution & Modern Inheritance Patterns sum() in Python 2026: Summing Iterables + Modern Numeric Patterns & Best Practices staticmethod() in Python 2026: Static Methods, Utility Functions & Modern Best Practices sorted() in Python 2026: Sorting Iterables + Modern Patterns & Best Practices slice() in Python 2026: Creating Slice Objects + Modern Patterns & Best Practices setattr() in Python 2026: Dynamic Attribute Setting + Modern Patterns & Safety set() in Python 2026: Mutable Sets Creation + Modern Patterns & Best Practices