Skip to content

Instantly share code, notes, and snippets.

@gsdefender
Last active April 10, 2017 15:27
Show Gist options
  • Save gsdefender/dc9555504d4eaa0a441cf25dea5ed807 to your computer and use it in GitHub Desktop.
Save gsdefender/dc9555504d4eaa0a441cf25dea5ed807 to your computer and use it in GitHub Desktop.
View xlsx file with Midnight Commander
# Add this to your mc.ext user file, search for
# Microsoft Excel Worksheet and _prepend_ this rule to the existing one.
regex/i/\.xlsx$
Open=/usr/lib/mc/ext.d/doc.sh open msxls
View=%view{ascii} /usr/local/bin/xlsx2csv %f
# Please note that if you do not prepend this block to the existing block for xls/xlsw, its regexp
# will catch the xlsx and so xlsx2csv will not be called
# Be sure to keep the existing viewer directives, as in this example:
# Microsoft Excel Worksheet
#regex/i/\.xlsx$
# Open=/usr/lib/mc/ext.d/doc.sh open msxls
# View=%view{ascii} /usr//bin/xlsx2csv %f
# Be sure to keep the existing viewer directives.
#regex/i/\.xl[sw]$
# Open=/usr/lib/mc/ext.d/doc.sh open msxls
# View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msxls
#type/^Microsoft\ Excel
# Open=/usr/lib/mc/ext.d/doc.sh open msxls
# View=%view{ascii} /usr/lib/mc/ext.d/doc.sh view msxls
@gsdefender
Copy link
Author

gsdefender commented Mar 31, 2017

If a xlsx2csv cannot be found anywhere in the system, you need to create a shell script with the correct path to your site-packages/.
For example on a Mac OS X system with Python 2.7 from MacPorts, after I installed xlsx2csv with pip, I had to create the /usr/local/bin/xlsx2csv script containing:

#!/bin/bash
python /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/xlsx2csv.py $*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment