A command-line tool for converting CSV files to binary Excel XLS workbooks.
XLS output is generated by xls-writer. This project handles CSV parsing and command-line options.
Install Go 1.20 or later, then run:
go install github.com/sergrom/csv2xls/v3@v3.1.0Convert a CSV file using the default semicolon delimiter:
csv2xls --csv-file-name="file.csv" --xls-file-name="file.xls"Show all available options:
csv2xls --help| Flag | Description | Default |
|---|---|---|
--csv-file-name |
Input CSV file (required). | — |
--xls-file-name |
Output XLS file (required). An existing file is overwritten. | — |
--csv-delimiter |
Field delimiter: a single character. | ; |
--title |
Document title. | Empty |
--subject |
Document subject. | Empty |
--creator |
Document creator. | Empty |
--keywords |
Document keywords. | Empty |
--description |
Document description. | Empty |
--last-modified-by |
Name of the last person to modify the document. | Empty |
Save the following comma-separated data as cities.csv:
ID,City,Country
1,Paris,France
2,Berlin,Germany
3,Madrid,SpainConvert it to XLS with a document title:
csv2xls --csv-file-name="cities.csv" --xls-file-name="cities.xls" --csv-delimiter="," --title="European cities"The resulting cities.xls contains a sheet named worksheet:
| ID | City | Country |
|---|---|---|
| 1 | Paris | France |
| 2 | Berlin | Germany |
| 3 | Madrid | Spain |
- Input text must be UTF-8. An initial UTF-8 BOM is removed before parsing; embedded BOM characters are preserved.
- All values are written as text: leading zeros are preserved, and values such
as
=1+1remain text rather than becoming formulas. - Records may have different numbers of fields. Permissive quote parsing is enabled.
- Records are split into sheets of 65,535 rows named
worksheet,worksheet1, etc. - Empty CSV input produces one empty worksheet.
- XLS limits are enforced by xls-writer. Invalid input and file errors are reported as conversion errors.
- The workbook is built in memory before it is saved.
Run the Go checks:
go build ./...
go test -race ./...
go vet ./...Integration tests read generated workbooks with the independent xlrd reader
and check cell values, types, sheet names, row boundaries, and BOM handling:
python3 -m venv .venv
.venv/bin/pip install -r tests/requirements.txt
.venv/bin/python -m unittest discover -s tests -vThe integration suite builds the CLI in a temporary directory. Python and
xlrd are test-only dependencies; the converter does not require them.
MIT.