By default, the CSV output goes to STDOUT:
excel2csv --file file.xlsx > file.csv
You can also save to a file directly:
excel2csv --file file.xlsx --output file.csv
Or even write to STDERR:
excel2csv --file file.xlsx --output STDERR
By default, the CSV file will be in the UTF-8 encoding. You can
change the encoding:
excel2csv --file file.xlsx --output_encoding CP1252 --output file_cp1252.csv
It can also autmatically trim whitespace from around all cell
values:
excel2csv --file file.xlsx --trim
Use the --sheet option to read from a sheet/tab other than the
first one. The following will pull from sheet 2:
excel2csv --file file.xlsx --sheet 2
You do not have to pass the --file and --output option keys. The
first non-keyed option will be used as the filename, and the second
non-keyed option will be the output. Other keyed options can still be passed
in:
excel2csv file.xlsx file.csv --trim
Bash file globbing is also supported. This will parse through each
xls file in the current directory and print out the CSV output from each one
to STDOUT.
excel2csv *.xls
gz files can also be parsed:
excel2csv file.xls.gz
excel2csv *.xls.gz
You can even pipe in the binary excel data:
cat file.xls | excel2csv > file.csv
- --file=(string)
- The path to the spreadsheet file.
- --output=(string)
- The path to where you want to store the CSV file.
If you do not pass this, the CSV output will go to STDOUT.
If this is a directory, a csv filename will be created
automatically using the excel filename. The extension will simply be
changed to .csv.
- --formatted
- Be default, the raw cell values from xls files will be returned. If this
is set, the "formatted" cell values will be returned instead.
This is really only useful to get formatted numbers, such as
currency values that include a currency symbol, or large numbers that
contain commas.
- --trim
- If set, whitespace around each value will be trimmed.
- --output_encoding=(string)
- The character encoding that you want the CSV output to be in. Defaults to
UTF-8.
- --max_blank=(integer)
- If this many blank lines are found, parsing will stop. Defaults to
10.
- --sheet=(integer)
- The sheet (tab) in the spreadsheet to parse. Defaults to sheet 1.
You can pass this option multiple times to parse multiple
sheets. Each sheet's data will be added sequentially to the same CSV
output.
- --match=(regex)
- If set, only rows that have a value matching this regex will be
returned.
- --color
- Use color when outputting results. This option only makes sense when you
are outputting to STDOUT.
When using --match, each match will also be highlighted in
red.