csv2xlsx: make an Office Open XML file from files of comma-separated values
This simple C program reads one or more comma-separated values (CSV) files and uses the libxlsxwriter library to make a Office Open XML spreadsheet file (usually with the .xlsx file extension).
Download
Compile
- If you have not already done so, install the libxlsxwriter library and its header files. For example, in Debian: sudo apt -q install libxlsxwriter-dev
- Download one of the archive files.
-
Unpack the archive file. For example:
- To unpack csv2xlsx.tar.gz: tar -xzf csv2xlsx.tar.gz
- To unpack csv2xlsx.zip: unzip -q csv2xlsx.zip
- Go to the csv2xlsx directory. For example: cd csv2xlsx
-
Compile and link the executable file. For example:
- With make: make
- Without make: gcc -o csv2xlsx csv2xlsx.c -lxlsxwriter
Examples
Single sheet
Make data.xlsx with a sheet with the name data from data.csv:
- ./csv2xlsx data.csv
- ./csv2xlsx -o data.xlsx -s data data.csv
- ./csv2xlsx --output-file-name=data.xlsx --sheet-name=data data.csv
- cat data.csv | ./csv2xlsx -o data.xlsx -s data
Multiple sheets
Make data.xlsx with sheets with the names data1, data2, and data3 from the files file1.csv, file2.csv, and file3.csv: ./csv2xlsx -o data.xlsx -s data1 -s data2 -s data3 file1.csv file2.csv file3.csv