xlsxgrep
xlsxgrep is a CLI utility designed to search text inside spreadsheet files including XLSX, XLS, XLSM, CSV, TSV, and ODS formats. Built to mimic the behavior of traditional Unix/GNU Linux grep, it bridges the gap between terminal efficiency and tabular data. Whether you need to count matches across a directory of legacy .xls files, extract specific patterns using Python regular expressions, or output clean tab-separated data for your automation scripts, xlsxgrep handles it natively without requiring you to boot up heavy office suites.
Features
- Grep compatible: supports common grep-style options such as
-r,-i, and-c. - Batch search: search many spreadsheet files at once, including recursive directory scans.
- Parallel execution: multi-process search via
-j/--jobsfor faster multi-file processing. - Regular expressions: Python regex and POSIX extended regular expressions via
-E, with fixed-string mode via-F. - Supported formats: csv, ods, tsv, xls, xlsx, xlsm.
- Display-aware values: formatted numeric cells are searched and printed as displayed by XLSX/XLSM, XLS, and ODS spreadsheets; CSV and TSV values remain unchanged.
- Cross-platform: works on Windows, macOS, BSD, and Linux.
- Search modes: row mode (default) prints matching rows; column mode prints whole matching columns vertically.
Installation
pip install xlsxgrep
Usage
xlsxgrep [OPTION]... PATTERN FILE [FILE]...
See the manual page for full option descriptions, search modes, exit status, and additional examples.
Examples
Search a spreadsheet case-insensitively:
xlsxgrep -i "foo" foobar.xlsx
Count matches and include file names when searching a folder recursively with 4 CPU cores:
xlsxgrep -c -H -r -j 4 "(?i)foo|bar" /folder
Search columns and print matching columns vertically:
xlsxgrep --column "error" report.xlsx
List only files that contain a match:
xlsxgrep -l "invoice" reports/
Search modes
- Row mode (
--row, default) - If any cell in a row matches the pattern, the entire row is printed with fields separated by the configured separator.
- Column mode (
--column) - If any cell in a column matches the pattern, every cell in that column is printed, one per line.