Ask Your Question

How to convert specific sheet to CSV via command line?

asked 2015-02-18 23:27:42 +0200

Mikeyy gravatar image

Looking at this question and answers ( ), plus checking some other resources, I found out that you can batch convert spreadsheet files to CSV. This is command you can use:

soffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":"59,ANSI,1" test.ods

Only problem I have is, I don't want to convert first/default sheet. I want to convert specific sheet (defined by order number or name). Does anyone know how to convert specific sheet with this command? My guess is that opening spreadsheet file in specific sheet and then converting would work also, but not sure how to do that via command line.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2015-03-26 13:55:00 +0200

0TOJ5 gravatar image

updated 2015-03-26 15:46:30 +0200

This worked for me to convert multiple ODS spreadsheet files with multiple sheets to separate CSV files:

Convert ODS to XLSX

libreoffice --headless --convert-to xlsx ./* --outdir ./spreadsheet-xlsx/

Convert XLSX to CSV

cd ./spreadsheet-xlsx/

for i in 2 3 4; do
    for j in $(ls -1 | sed -e 's/\..*$//'); do
    xlsx2csv -s $i $j.xlsx ../spreadsheet-csv/$j-$i.csv
edit flag offensive delete link more


Just to mention where to obtain xlsx2csv, it is available from GitHub.

erAck gravatar imageerAck ( 2015-09-11 00:19:20 +0200 )edit

Yes, that could work, but since my spreadsheet in quite complex, converting from ods to xlsx would probably destroy something. + it's longer way :) Anyway, thanks for solution.

Mikeyy gravatar imageMikeyy ( 2015-10-20 18:24:02 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-02-18 23:27:42 +0200

Seen: 28,959 times

Last updated: Mar 26 '15