Output format¶
The default output format is to show one match per line à la grep:
You can use flags to control the output. The filename and part sections can be suppressed, and
you can add a section for the matching XML element's tag (or parent element for attribute and text
matches):
filename:part: value (default)
filename:part:<tag/>: value (--tag)
part: value (--no-filename)
part:<tag/>: value (--no-filename --tag)
filename: value (--no-part)
filename:<tag/>: value (--no-part --tag)
value (--no-filename --no-part)
<tag/>: value (--no-filename --no-part --tag)
JSON output¶
Passing --json switches the output to
newline-delimited JSON: one JSON object per match, one
match per line. Each object always has a value field, and can optionally have file, part, and
tag fields.
- By default
fileandpartare included tagis only included when--tagis passed--no-filenamedropsfile--no-partdropspart
Default:
With --tag:
{"file":"workbook.xlsx","part":"xl/workbook.xml","tag":"<x:sheet name=\"Sheet1\" sheetId=\"1\"/>","value":"Sheet1"}
With --no-filename and --no-part:
All values are strings. --json cannot be combined with --count or --only-filenames.
CSV output¶
xlpath can't produce CSV directly, but you can combine its ND-JSON output with
jq's @csv filter. Pick the fields you want, put them in an array, and
jq takes care of quoting and escaping:
"workbooks/report.xlsx","xl/workbook.xml","Summary"
"workbooks/report.xlsx","xl/workbook.xml","Data"
"workbooks/sales.xlsx","xl/workbook.xml","Q1"
To include a header row, use jq's slurp mode (-s) so the header can be emitted once before the
data rows: