Chapter 36 Further Reading: Automated Report Generation
The resources below are real, actively maintained, and worth your time. Each annotation explains what you'll find there and who it's most useful for.
Official Documentation
Jinja2 — Template Designer Documentation
URL: https://jinja.palletsprojects.com/en/3.1.x/templates/
The definitive reference for Jinja2 template syntax. Start with the "Variables", "Filters", "Tests", and "Template Inheritance" sections. The "Global Functions" section is particularly useful for reports — range(), namespace(), and joiner() come up frequently. The filter reference is comprehensive; you'll find many built-in filters that save you from writing custom ones.
Best for: Understanding all the template syntax options; bookmark the filters table.
openpyxl — A Python Library to Read/Write Excel
URL: https://openpyxl.readthedocs.io/en/stable/
The official docs are well-organized. For report generation, focus on: "Working with charts" (the chart types and series configuration), "Styling" (fills, fonts, borders, number formats), and "Worksheet properties" (print areas, page setup, freeze panes). The "Performance" section explains the write_only mode for generating large files efficiently.
Best for: Complete reference for all formatting and chart options; the cookbook section has working examples.
WeasyPrint — User Documentation
URL: https://doc.courtbouillon.org/weasyprint/stable/
Covers HTML/CSS compatibility (not all CSS features are supported), the @page rule for headers/footers and page numbering, and advanced features like footnotes and running elements. The "CSS compatibility" table tells you which CSS properties WeasyPrint supports — knowing this upfront saves significant debugging time.
Best for: Understanding what CSS works in WeasyPrint PDFs; the @page rules section is essential.
matplotlib — Tutorials
URL: https://matplotlib.org/stable/tutorials/index.html
The "Introductory" and "Intermediate" tutorial sections cover everything you need for report charts. The "Customizing matplotlib" section shows how to set consistent styles across all charts using plt.rcParams. The "Artists" tutorial explains the object model, which helps when you need to customize individual chart elements programmatically.
Best for: Systematic matplotlib learning; the plot types gallery is the fastest way to find chart code.
Tutorials and Guides
Real Python — Generating PDF Reports with Python
URL: https://realpython.com/creating-modifying-pdf/
Real Python's treatment of PDF generation compares multiple approaches: ReportLab for complex layouts, WeasyPrint for HTML-first workflows, and fpdf2 for simple documents. Useful for understanding the landscape of tools and choosing the right one for your use case. The WeasyPrint section includes working examples with CSS for print.
Best for: Comparing PDF libraries before committing to one approach.
Real Python — Jinja2 Template Engine Tutorial
URL: https://realpython.com/primer-on-jinja-templating/
A thorough walkthrough of Jinja2 from basics to advanced features including template inheritance, macros (reusable template fragments), and testing. The tutorial approach complements the official reference docs — it explains the "why" where the docs focus on the "what." The section on macros is worth reading even if you don't need it immediately.
Best for: Learning Jinja2 from scratch or filling gaps in your understanding.
Python Excel Tutorial with openpyxl
URL: https://www.pythonexcel.com/ (or search "openpyxl tutorial pythonexcel")
Practical openpyxl tutorials organized by use case: reading data, writing data, styling, charts, formulas. The chart tutorials show working code for each chart type (bar, line, pie, scatter). Useful as a complement to the official docs when you want example-first learning.
Best for: Specific how-to examples for openpyxl tasks.
Books
"Python for Data Analysis" — Wes McKinney (O'Reilly)
The authoritative guide to pandas, written by pandas' creator. While Chapter 36 focuses on report output rather than analysis, the data manipulation techniques in this book — groupby, pivot tables, time series resampling — are exactly what you need to prepare data for reports. Chapter 11 (Time Series) and Chapter 10 (Data Aggregation and Group Operations) are most directly relevant.
Best for: Mastering pandas data preparation before report generation.
"Effective Python" — Brett Slatkin (Addison-Wesley)
Not report-specific, but several items directly improve report code quality: Item 5 (f-strings over older formatting), Item 24 (use None as default for dynamic defaults in dataclasses), and the section on generators for memory-efficient data processing. These patterns appear throughout production-quality report pipelines.
Best for: Python code quality and idiom improvement.
Tools Worth Knowing
Playwright / Selenium for HTML-to-PDF
If WeasyPrint's CSS support is limiting for complex layouts, Playwright (Microsoft) can control a headless Chrome browser and print any HTML to PDF with full CSS support. The trade-off is heavier infrastructure (requires Chrome installed), but the output is pixel-perfect because it uses the actual browser rendering engine. See: https://playwright.dev/python/docs/api/class-page#page-pdf
Plotly for Interactive HTML Reports
When your HTML report will be viewed in a browser (not converted to PDF), Plotly creates interactive charts that users can hover, zoom, and filter. plotly.express makes chart creation nearly as simple as matplotlib. For executive dashboards where interactivity adds value, Plotly charts embedded in HTML reports are more engaging than static images. See: https://plotly.com/python/
Datapane for Publishing Python Reports
Datapane (https://datapane.com) is a platform specifically for publishing Python-generated reports as shareable web pages. You write Python, define report sections, and Datapane handles hosting and sharing. Worth knowing as a deployment option for reports that need to be accessible via URL without building a full Flask app.
CSS Resources for Print
"CSS Paged Media Module" — W3C Specification
URL: https://www.w3.org/TR/css-page-3/
The technical specification for @page rules, named pages, running headers/footers, and page breaks. You don't need to read the full spec, but the examples in sections 4 (@page rule), 7 (running headers/footers), and 9 (page breaks) explain the features WeasyPrint implements. Useful when you need something specific that isn't covered in WeasyPrint's docs.
"Designing for Print with CSS" — Rachel Andrew (A List Apart)
URL: https://alistapart.com/article/designing-for-print-with-css/
A practical, readable introduction to CSS paged media — the CSS features that control how HTML renders as printable or PDF output. Covers @page, page breaks, widows/orphans, and running headers. Written for web developers new to print CSS, which makes it accessible and practical.
Best for: Understanding print CSS concepts before writing WeasyPrint templates.
Community
Stack Overflow — [jinja2] tag
URL: https://stackoverflow.com/questions/tagged/jinja2
The most common Jinja2 questions (escaping HTML, template context, custom filters, inheritance edge cases) have thoroughly answered threads here. Search before asking — Jinja2 has been widely used for over a decade and most practical questions are already answered.
Stack Overflow — [openpyxl] tag
URL: https://stackoverflow.com/questions/tagged/openpyxl
Similarly comprehensive. Chart configuration questions in particular are well-covered here, since the openpyxl chart documentation is less detailed than the rest of the library.