Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to know if there is a Linux tool or a script available to convert .xlsx file to .txt.

share|improve this question

migrated from stackoverflow.com Oct 20 '10 at 18:07

This question came from our site for professional and enthusiast programmers.

2  
Not a very clear question to be honest. What do you have in the file? Just data? Or are there charts, macros, etc. as well? –  Zaid Oct 20 '10 at 8:42
    
There are lots of them available online. xlsx is a proprietary (and a relatively new) format so the effectiveness of open source tools will be limited I think. Try tinyurl.com/2vbb7m5 –  Noufal Ibrahim Oct 20 '10 at 8:56
1  
something like wizard.ae.krakow.pl/~jb/xls2txt , but for xlsx –  Anonymous Oct 20 '10 at 8:57
add comment

7 Answers 7

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.

share|improve this answer
3  
+1 interesting. I'm looking at these XML files now, and at least in this case it is more complicated than you imply -- sheet1.xml doesn't have any actual text in, but seems to refer to another XML file called sharedStrings.xml, which is where the "content" of the file is stored. –  handsofaten Oct 20 '10 at 18:51
add comment

The ssconvert tool that comes with Gnumeric can convert xlsx files to text:

ssconvert Book1.xlsx file.csv
share|improve this answer
    
and it's flexible and fast ! #recommended –  knb Jul 10 '12 at 14:22
add comment

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.

share|improve this answer
add comment

If it's just textual/numerical data (which I have to assume it is, otherwise a text file would be a bit ambitious), then you could try xlsx2csv to generate CSV files from your spreadsheets.

I can't vouch for its effectiveness, but it's worth a try.

share|improve this answer
add comment

Not command line, but OpenOffice can read .xslx files and save as csv. Its probably already on your Linux machine.

share|improve this answer
add comment

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
share|improve this answer
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.