🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101

Excel to PDF report automation

Turn a raw monthly sales Excel file into a formatted summary workbook and a one-page PDF report with charts, in one command.

Intermediate⏱ 6–8 hoursđŸĒœ 7 stepsPythonpandasopenpyxlmatplotlib

What you'll learn

  • ◆Reading and writing Excel with pandas and openpyxl
  • ◆Pivot tables in pandas
  • ◆Generating charts and PDFs

What you'll build

  • ✓Reads any month's sales.xlsx
  • ✓Totals by region, product and salesperson
  • ✓Formatted Excel output with bold headers and number formats
  • ✓PDF report with two charts and key numbers

Step-by-step guide

  1. 1

    Create sample data

    Make sales.xlsx with columns Date, Region, Product, Salesperson, Units, Price (or generate 500 rows with pandas and random).

  2. 2

    Load and clean

    pd.read_excel("sales.xlsx"); add Revenue = Units * Price; drop empty rows; parse dates.

  3. 3

    Summarise

    Use df.pivot_table(index="Region", columns="Product", values="Revenue", aggfunc="sum") and groupby("Salesperson").sum().

  4. 4

    Write a formatted workbook

    Use pd.ExcelWriter(engine="openpyxl") to write each summary to its own sheet, then style headers and set number formats with openpyxl.

  5. 5

    Make charts

    Plot revenue by region (bar) and by day (line) with matplotlib and save as PNG.

  6. 6

    Build the PDF

    Use matplotlib.backends.backend_pdf.PdfPages (or the reportlab library) to place the key numbers and both charts on one page.

  7. 7

    One command

    Wrap it in report.py --input sales.xlsx --month 2026-11 and print where the files were saved.

🚀 Make it stand out

  • +Email the PDF automatically with smtplib
  • +Compare with last month and highlight changes
  • +Run it on a schedule