I want to know if there is a Linux tool or a script available to convert .xlsx file to .txt.
- 13,477
- 101
7 Answers
Another way is rename it as .zip and unzip it as all the .***x files are just zipped folders containing xml. Inside you will find a folder "xl" with a subfolder "worksheets", inside is an xml file for each worksheet. The format of them is pretty simple and should be easy to parse with any of the xml packages.
- 191
I do not know about a tool in linux, but you can use Google Docs.
You upload the spreadsheet there and you can then export it as txt.
Not a shell script, (unlike the script mentioned in Andy's post from Oct 20 '10 at 8:44), but a python script:
with the same name, xlsx2csv
This exports date values as floats though:
2012/07/01 => 41091,
"2012/07/01 01:00:00" => 41091.0416666667
xlsx2csv.py --help
Usage: xlsx2csv.py [options] infile [outfile]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-s SHEETID, --sheet=SHEETID
sheet no to convert (0 for all sheets)
-d DELIMITER, --delimiter=DELIMITER
delimiter - csv columns delimiter, 'tab' or 'x09' for
tab (comma is default)
-p SHEETDELIMITER, --sheetdelimiter=SHEETDELIMITER
sheets delimiter used to separate sheets, pass '' if
you don't want delimiters (default '--------')
-f DATEFORMAT, --dateformat=DATEFORMAT
override date/time format (ex. %Y/%m/%d)
-i, --ignoreempty skip empty lines
-r, --recursive convert recursively
- 165
I used the command below to convert all my xlsx files in the current directory (must have Libre Office installed):
for i in *.xlsx; do libreoffice --headless --convert-to csv "$i" ; done
Libreoffice is really good to read Excel and write CSVs. See if your executable isn't called scalc.
- 519
Not command line, but OpenOffice can read .xslx files and save as csv. Its probably already on your Linux machine.
- 32,350