python-pptx in 2026: Automate PowerPoint Reports with Python
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 asPresentation("brand.pptx")to reuse your company theme.slide_layouts[0]is the Title layout andslide_layouts[5]is Title Only.CategoryChartDataholds categories and series;add_chartembeds an Excel-backed chart.add_table(rows, cols, left, top, width, height).tablereturns a table whose cells you fill throughcell(r, c).text.- Sizes use
Inches,PtorEmu, 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.