Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Last active August 29, 2015 14:23
Show Gist options
  • Save pesterhazy/bc0131c18f32daa403c9 to your computer and use it in GitHub Desktop.
Save pesterhazy/bc0131c18f32daa403c9 to your computer and use it in GitHub Desktop.
csv2xls: convert CSV file to XLS (Excel 2007 format) on the command line
#!/usr/bin/env bash
#
# You need gnumeric installed, which provides the
# ssconvert tool (on Ubuntu: sudo apt-get install gnumeric)
#
# Usage:
#
# generate_csv | csv2xls > out.xls
set -euo pipefail
if [[ $# -eq 0 ]]; then
in=/dev/stdin
else
in="$1"
shift
fi
if [[ $# -eq 0 ]]; then
out=/dev/stdout
else
out="$1"
shift
fi
exec ssconvert -T Gnumeric_Excel:excel_biff8 "$in" "$out"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment