Which library should I use to write an XLS from Linux / Python?
Asked Answered
D

5

7

I'd love a good native Python library to write XLS, but it doesn't seem to exist. Happily, Jython does.

So I'm trying to decide between jexcelapi and Apache HSSF: http://www.andykhan.com/jexcelapi/tutorial.html#writing http://poi.apache.org/hssf/quick-guide.html

(I can't use COM automation because I'm not on Windows, and even if I was, I couldn't afford Office licenses.)

My initial thoughts are that POI/HSSF is very thorough, but also very Java-- everything seems a bit harder than it needs to be. Good documentation, but my head hurts trying to bridge the gap between what it describes and what I need to accomplish.

jexcepapi seems to have a simpler, nicer (for me) interface, but doesn't have very good documentation or community.

Which would you use, and why?

Disavow answered 28/10, 2008 at 23:11 Comment(0)
T
18

What's wrong with xlwt?

Telltale answered 28/10, 2008 at 23:37 Comment(5)
I'd ask the same question, and recommend Jeremy take a look at it; I've used pyexcelerator (of which xlwt is an improved fork) in real-world projects and been quite happy with it.Trifocals
This is what gave me pause: sourceforge.net/mailarchive/… I saw various blog posts about bugs. I don't really want to hit a bug that requires me to learn a lot about the binary format-- it seems like a deep field. Agree, though, xlwt seems to win.Disavow
@Jeremy Dunck: It isn't "deep" it's a load of Microsoft crap. It's simply an awful thing. You're almost better off building an XML workbook document than trying to build a binary.Telltale
I've used pyexcelerator, too, with great results. Anyone know if xlwt allows ordering of worksheets within the workbook?Eladiaelaeoptene
Perhaps that's a separate question: "How do I order the pages in a xlwt workbook?"Telltale
G
3

+1 for xlwt. See Matt Harrison's blog for posts on how to use xlwt and how to deal with large spreadsheets. Also, check out the python-excel group on Google "If you use Python to read, write or otherwise manipulate Excel files".

Grabowski answered 29/10, 2008 at 2:14 Comment(0)
T
1

I'd use JExcelApi, but only because I've used it before. Never have touched HSSF. Biggest show-stopper I can recall is JExcelApi doesn't support multiple formats in one cell (e.g. half the text in bold, the other half in italic or something like that). I think in general JExcelApi is more limited than HSSF, but the limitations never got in my way.

And yes, documentation is sparse for the interface (and nonexistent for the underlying mechanisms), but I thought it was doable...

Tyne answered 28/10, 2008 at 23:34 Comment(0)
E
1

i personally dis-advise JExcel if you intent to use anything more then very simple text to excel and vice versa.

the more advanced features are abstracted very leaky from the underlying (basically undocumented) low-level code / (documented) Excel specs.

another problem we ran into is jexcel fails fatally when encountering invalid formulas. and if you need to parse client supplied spreadsheets this is a problem.

also the new POI version support (almost) seemless both xls and xlsx at the same time.

Extortion answered 21/7, 2009 at 12:26 Comment(0)
K
0

Excel exposes the same OLE automation API used by VBA to anything that supports COM. You can use win32com (which is included with ActiveState Python by default) to manipulate spreadsheets in much the same way that you would do in VBA.

Klehm answered 28/10, 2008 at 23:33 Comment(1)
This is described in depth here: oreilly.com/catalog/pythonwin32/chapter/ch12.htmlPelagianism

© 2022 - 2024 — McMap. All rights reserved.