Automating Weekly Reports with OfficeIMO.Excel and GitHub Actions
A real-world guide to building automated Excel reports in CI/CD using OfficeIMO.Excel and GitHub Actions, complete with YAML workflow and C# code.
Every Monday morning, your team lead asks for the same report: open issues by label, pull request merge times, and a trend chart. Instead of rebuilding it manually, you can have GitHub Actions generate the workbook on a schedule and publish it as an artifact or pass it on to the next delivery step.
Architecture
The workflow has three stages:
- Fetch data from the GitHub API using the
ghCLI. - Generate the Excel report with a small C# console app that uses OfficeIMO.Excel.
- Upload the artifact so it can be downloaded or forwarded.
The C# Report Generator
Create a console project:
dotnet new console -n WeeklyReport
cd WeeklyReport
dotnet add package OfficeIMO.Excel
dotnet add package System.Text.JsonThe generator reads a JSON file produced by the workflow and writes an Excel workbook:
using System.Text.Json;
using OfficeIMO.Excel;
var issues = JsonSerializer.Deserialize<List<Issue>>(
File.ReadAllText("issues.json"));
using var workbook = ExcelDocument.Create("WeeklyReport.xlsx");
var sheet = workbook.AddSheet("Open Issues");
// Header row
sheet.SetRow(0, new object[] { "Number", "Title", "Labels", "Created", "Age (days)" });
int row = 1;
foreach (var issue in issues!)
{
var age = (DateTime.UtcNow - issue.CreatedAt).Days;
sheet.SetRow(row++, new object[]
{
issue.Number,
issue.Title,
string.Join(", ", issue.Labels),
issue.CreatedAt.ToString("yyyy-MM-dd"),
age
});
}
sheet.AutoFitColumns();
workbook.Save();
Console.WriteLine($"Report generated with {issues.Count} issues.");
record Issue(int Number, string Title, List<string> Labels, DateTime CreatedAt);The GitHub Actions Workflow
name: Weekly Report
on:
schedule:
- cron: "0 7 * * 1" # Every Monday at 07:00 UTC
workflow_dispatch: # Allow manual trigger
permissions:
contents: read
issues: read
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Fetch open issues
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue list \
--repo ${{ github.repository }} \
--state open \
--limit 500 \
--json number,title,labels,createdAt \
> WeeklyReport/issues.json
- name: Generate Excel report
run: dotnet run --project WeeklyReport
- name: Upload report artifact
uses: actions/upload-artifact@v4
with:
name: weekly-report-${{ github.run_number }}
path: WeeklyReport/WeeklyReport.xlsx
retention-days: 30After each run, the Excel file is available as a downloadable artifact on the workflow run page.
Sending the Report via Email
Add a step using a mail action:
- name: Send report
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.office365.com
server_port: 587
username: ${{ secrets.MAIL_USER }}
password: ${{ secrets.MAIL_PASS }}
subject: "Weekly Issue Report - ${{ github.run_number }}"
to: [email protected]
from: [email protected]
body: "Attached is this week's open-issue report."
attachments: WeeklyReport/WeeklyReport.xlsxExtending the Report
Once the skeleton is working, you can add more sheets:
- PR Merge Times : fetch
gh pr list --state merged --json mergedAt,createdAtand compute duration. - Label Distribution : pivot issues by label into a summary table.
- Trend Sheet : append a row to a persistent CSV in the repo and chart it over time.
Each sheet is just another call to workbook.AddSheet() with its own data.
Operational Note
Runner availability, retention limits, and billing depend on your GitHub plan and repository type. Check the current GitHub Actions pricing and usage docs for the exact limits that apply to your environment.
Automating repeatable reports like this can take manual dashboard work out of the loop. OfficeIMO.Excel and GitHub Actions make a straightforward starting point for that workflow.
Continue with
- OfficeIMO.Excel for the package overview and reporting-focused capabilities.
- Excel documentation for workbook structure, tables, formulas, and formatting patterns.
- Building Excel Reports with Parallel Compute if your scheduled reports are large enough to benefit from parallel writes.
- PSWriteOffice if you want a PowerShell-driven automation path instead of a C# console app.