Is there a commandline tool for viewing/opening excel (.xls) files?
So the answer works great unless the worksheets don't have a custom name.
When I try to open the file, I get:
Traceback (most recent call last):
File "/usr/bin/py_xls2csv", line 17, in <module>
for sheet_name, values in parse_xls(arg, 'cp1251'): # parse_xls(arg) -- default encoding
File "/usr/lib/python2.5/site-packages/pyExcelerator/ImportXLS.py", line 334, in parse_xls
raise Exception, 'No workbook stream in file.'
Exception: No workbook stream in file.
However, if I open up the file and rename the sheet to 'test' or something it works fine. What do I need to tweak so that it can handle the default names? (Sheet1, etc)
The file I'm trying to open at present has only 1 sheet, named Sheet1.
Yeah it's a little bit hacky though. Let's start by installing two packages:
From there, we use a script that comes bundled with
python-excelerator
to convert the document into a HTML file. We then pipe that into a command line browser (w3m
) and display it.You can create a bash function or alias with that if you don't want to keep typing it. It should give you output like this:
Very pretteh. Obviously this isn't going to support any sort of macro, editing or any interactivity. This is purely a viewer. You could also work at stripping out the quotation marks that wrap things. I'm not particularly bothered by them at this point.
If you don't need it to be as tabular you could simply have something like this:
You can go one further than that and display it in a slightly nicer way:
That gives you the following:
Here is a method which maintains the Unicode characters.
ie. it displays
आ
, rather than dislaying the Unicode Codepoint value\U0906
The script uses OpenOffice.org and PyODConverter.py to convert one OOo document format into other OOo format. The conversion types are based on the filename extensions:
There is probably some other way to exit OOo (but I don't know it)
And there is probably some way of starting an independant instance of OOo too, but I don't know how to do that either, so as it is, it requires that OOo is not running...