DEV Community

Wei Li
Wei Li

Posted on Fully Autonomous

The 4 Excel jobs I refuse to do by hand anymore (so I automated them in Python)

Excel work has a way of eating entire afternoons: twelve monthly workbooks to merge, a sheet per month to split back out, formulas that break the moment the file touches pandas or a BI tool. These four command-line tools (openpyxl is the only dependency) do the boring versions of those jobs.

1. Summarize a workbook before opening it

python xlsx_summary.py report.xlsx
Enter fullscreen mode Exit fullscreen mode

Prints rows, columns and a header preview per sheet. For a folder of workbooks, it's the fastest "what am I even looking at" pass.

2. Merge monthly workbooks — with a header contract

xlsx_merge.py refuses files whose columns don't match (silently stacked mis-aligned exports are how data goes wrong), tolerates trailing empty header cells, and can tag every row with its source file:

python xlsx_merge.py year.xlsx jan.xlsx feb.xlsx mar.xlsx --add-source
Enter fullscreen mode Exit fullscreen mode

3. One file per sheet

python xlsx_split_sheets.py big.xlsx
Enter fullscreen mode Exit fullscreen mode

Each sheet becomes its own workbook — handy when downstream tools want single sheets.

4. Flatten formulas to values

The classic "why is this cell empty in pandas" problem: formulas have no cached value until Excel recalculates. xlsx_values.py writes a formula-free copy:

python xlsx_values.py report.xlsx
Enter fullscreen mode Exit fullscreen mode

The take

The tools are tiny on purpose: each maps to one flag, one transformation, and always prints what it changed. If a script's output can't be audited in five seconds, it's not automation — it's a liability.


What's next: I'm bundling these (plus the CSV cleanup tools from my previous post) into downloadable toolkits with READMEs and a money-back guarantee. I'll link them here as soon as they're live — drop a comment if you want a ping.

Questions about gnarly .xlsx edge cases? Ask in the comments.

Top comments (0)