Name
xlsxgrep — search text in spreadsheet files
Synopsis
xlsxgrep [OPTION]... PATTERN FILE [FILE]...
Description
xlsxgrep searches for a text pattern in spreadsheet files. It works similarly to grep(1), but operates on XLSX, XLS, XLSM, CSV, TSV, and ODS files.
When a match is found, output depends on the selected search mode. In row mode (the default), matching rows are printed with fields separated by a tab. In column mode, whole columns containing at least one match are printed vertically, one cell per line.
Numeric cells in XLSX, XLSM, XLS, and ODS files are searched and printed using their spreadsheet display values, including number formats such as currency, grouping, and negative-value notation. CSV and TSV values are used as stored.
Options
-h,--help- Show help message and exit.
-V,--version- Display version information and exit.
-P,--python-regex- Treat PATTERN as a Python regular expression.
-E,--extended-regexp- Treat PATTERN as a POSIX extended regular expression (Default).
-F,--fixed-strings- Treat PATTERN as a fixed string, not a regular expression.
-i,--ignore-case- Ignore case distinctions in PATTERN and input data.
-w,--word-regexp- Force PATTERN to match only whole words.
-c,--count- Print only a count of matches per file.
-r,--recursive- Search directories recursively.
-H,--with-filename- Print the file name for each match.
-N,--with-sheetname- Print the sheet name for each match.
-l,--files-with-match- Print only the names of files that contain a match.
-L,--files-without-match- Print only the names of files that do not contain a match.
-SSEPARATOR,--separatorSEPARATOR- Use SEPARATOR as the field separator in row output. The default is a tab character.
-Z,--null- Output a zero byte (ASCII NUL) instead of the usual newline after each match.
-jJOBS,--jobsJOBS- Number of parallel search jobs/processes (default is 1). Use 0 to auto-detect available CPU cores.
--row- Search rows and print matching rows. This is the default search mode.
--column- Search columns and print whole matching columns vertically.
Search modes
- Row mode (
--row, default) - If any cell in a row matches PATTERN, the entire row is printed on one line with fields separated by the configured separator.
- Column mode (
--column) - If any cell in a column matches PATTERN, every cell in that column is printed, one per line.
Supported formats
csv, ods, tsv, xls, xlsx, xlsm
Examples
Search a spreadsheet case-insensitively:
xlsxgrep -i "foo" foobar.xlsx
Count matches and include file names when searching a folder recursively with 4 parallel jobs:
xlsxgrep -c -H -r -j 4 "(?i)foo|bar" /folder
Search columns and print matching columns vertically:
xlsxgrep --column "error" report.xlsx
Exit status
- 0
- Matches were found, or no error occurred.
- 1
- No matches were found, or a usage error occurred.
See also
grep(1), pdfgrep(1)
Author
Ivan Cvitic <cviticivan@gmail.com>
Bugs
Report issues at https://github.com/zazuum/xlsxgrep