Automate Your Monthly Report Deck with Python

On the first working day of every month, the same routine: open last month's deck, save it as a new file, change the month in the title, paste in the latest chart, type the numbers into each box, nudge everything until it lines up, export to PDF, send. Twelve slides, fifteen to twenty minutes for someone who has done it a hundred times, and almost always one figure that does not match, sending you back to Excel to check.

This post shows how to compress that into about ten seconds with Python: the numbers stay in Excel, the design stays in a template, and the script only connects the two.

The idea: separate what is fixed from what changes

A monthly report is tedious because every slide mixes two kinds of content. Layout, colours, fonts, footer and logo do not change all year: that is the fixed part. Month, revenue, cost, charts and commentary change every time: that is the variable part. A person working by hand handles both at once, so the layout gets rebuilt each month.

The automation approach is straightforward. Build everything fixed in advance and save it as report_template.pptx; let Excel supply whatever changes. The script then does three things only: replace text, insert pictures, save the file.

Setup

pip install python-pptx openpyxl matplotlib

python-pptx reads .pptx only, so an older .ppt file has to be re-saved once in PowerPoint. openpyxl reads Excel, matplotlib draws the charts. All three are pure Python, with no extra software to install.

Step 1: Build the template

Open a new 16:9 deck with four slides: cover, revenue trend, cost breakdown, next month's focus. Wherever a value changes monthly, type a marker such as {{month}} or {{revenue}}. Do not leave an empty box and expect the script to guess.

Type each marker in one go. If you change the font or size halfway through, PowerPoint splits {{month}} into several runs and the text match will miss it.

Save it as report_template.pptx in the same folder as the script and data.xlsx.

Step 2: Replace markers with Excel numbers

In Excel, create a sheet called summary with this month's revenue in B2 and cost in B3. Then write make_report.py:

from pptx import Presentation import openpyxl MONTH = "2026-10" wb = openpyxl.load_workbook("data.xlsx", data_only=True) ws = wb["summary"] revenue = ws["B2"].value cost = ws["B3"].value profit = revenue - cost values = { "{{month}}": "October 2026", "{{revenue}}": "${:,.0f}".format(revenue), "{{cost}}": "${:,.0f}".format(cost), "{{profit}}": "${:,.0f}".format(profit), } prs = Presentation("report_template.pptx") for slide in prs.slides: for shape in slide.shapes: if not shape.has_text_frame: continue for para in shape.text_frame.paragraphs: for run in para.runs: for key, val in values.items(): if key in run.text: run.text = run.text.replace(key, val) prs.save("report_" + MONTH + ".pptx")

Lines that matter

  • data_only=True: reads the calculated value. Without it, a cell holding a formula returns the string =SUM(B2:B9), which then lands in the slide.
  • has_text_frame: tables, pictures and lines have no text frame, so skipping the check raises AttributeError.
  • Edit the run, not the paragraph: rewriting a whole paragraph wipes the font, size and colour back to the default style.
  • ${:,.0f}: adds thousands separators. A raw float shows up as 1020000.0, which nobody wants to read on a client slide.

Step 3: Render charts as PNG with matplotlib

In theory python-pptx can edit the data behind a native PowerPoint chart, but the number of data points changes month to month (six months here, twelve there), and that gets messy. The more reliable approach is to render a PNG with matplotlib and place it at a fixed position.

import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt months = ["May", "Jun", "Jul", "Aug", "Sep", "Oct"] sales = [820000, 795000, 910000, 880000, 960000, 1020000] plt.rcParams["font.sans-serif"] = ["Microsoft JhengHei"] plt.rcParams["axes.unicode_minus"] = False fig, ax = plt.subplots(figsize=(8, 4.5), dpi=200) ax.bar(months, sales, color="#F97316", width=0.6) ax.set_title("Revenue, last six months", fontsize=16) ax.spines[["top", "right"]].set_visible(False) ax.grid(axis="y", linestyle=":", alpha=0.4) fig.tight_layout() fig.savefig("chart_sales.png", facecolor="white") plt.close(fig)

Then add a few lines to the same script to place the image on slide two:

from pptx.util import Cm slide = prs.slides[1] slide.shapes.add_picture("chart_sales.png", Cm(2.5), Cm(4.2), width=Cm(17))

Position in centimetres, not pixels. A 16:9 slide is 33.87cm wide and 19.05cm tall, so starting at 2.5cm with a 17cm width still leaves room for a comment box on the right.

Step 4: The monthly routine

Update data.xlsx, then run one command:

python make_report.py

To remove the need to remember anything, schedule it in Windows Task Scheduler at 09:00 on the first of each month, pointing at a .bat containing the single line python make_report.py. That only works if data.xlsx is refreshed automatically by something else: a POS export, the accounting system, or a scheduled download from a cloud sheet.

Three practical details

  • Chinese fonts: matplotlib ships no CJK font, so without font.sans-serif you get empty boxes. Use Microsoft JhengHei or MingLiU on Windows, PingFang HK on macOS.
  • Locked file: if report_2026-10.pptx is still open in PowerPoint, saving raises PermissionError. Wrap it in try/except and save under a timestamped name instead, so the rest of the run carries on.
  • Check the numbers: have the script print revenue, cost and profit, and glance at them against Excel before sending. The real risk in automation is not a crash, it is a wrong number that nobody notices.

When not to automate

If the report changes structure every month, with new slides and a different angle, the script will cost more time than it saves. The test is simple: three months in a row with the same format and only the numbers changing means it is worth doing. If you redesign it every time, keep doing it by hand until the format settles.

Summary

Python Tutorial: the hard part of automating a monthly report is not python-pptx itself; it is splitting fixed from variable first. Keep the fixed part in the template, read the variable part from Excel, and let the script do only three things: replace text, insert pictures, save. Once that is in place, a twelve-slide report drops from fifteen minutes to ten seconds, and the wrong month, the missing thousands separator and last month's chart pasted by mistake all stop happening.