I'd love a good native Python library to write XLS, but it doesn't seem to exist. Happily, Jython does.
我喜欢一个好的原生Python库来编写XLS,但它似乎并不存在。令人高兴的是,Jython确实如此。
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
所以我想在jexcelapi和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.)
(我不能使用COM自动化,因为我不在Windows上,即使我是,我也买不起Office许可证。)
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.
我最初的想法是POI / HSSF非常彻底,但也非常Java--一切似乎都比它需要的更难。良好的文档,但我的头痛害试图弥合它描述的内容和我需要完成的之间的差距。
jexcepapi seems to have a simpler, nicer (for me) interface, but doesn't have very good documentation or community.
jexcepapi似乎有一个更简单,更好(对我而言)的界面,但没有非常好的文档或社区。
Which would you use, and why?
你会用哪个,为什么?
5 个解决方案
#2
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".
+1表示xlwt。有关如何使用xlwt以及如何处理大型电子表格的帖子,请参阅Matt Harrison的博客。另外,请查看Google上的python-excel组“如果您使用Python来读取,写入或以其他方式操作Excel文件”。
#3
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.
我使用JExcelApi,但仅仅因为我之前使用过它。从未接触过HSSF。我记得最大的show-stopper是JExcelApi不支持一个单元格中的多种格式(例如粗体的一半文本,另一半用斜体或类似的东西)。我认为一般来说JExcelApi比HSSF更有限,但是这些限制从来没有妨碍我。
And yes, documentation is sparse for the interface (and nonexistent for the underlying mechanisms), but I thought it was doable...
是的,文档对于接口是稀疏的(并且对于底层机制是不存在的),但我认为它是可行的......
#4
1
i personally dis-advise JExcel if you intent to use anything more then very simple text to excel and vice versa.
如果您打算使用任何更简单的文本来表现出色,我个人会劝告JExcel,反之亦然。
the more advanced features are abstracted very leaky from the underlying (basically undocumented) low-level code / (documented) Excel specs.
更高级的功能从底层(基本上未记录的)低级代码/(记录的)Excel规范中抽象出来。
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.
我们遇到的另一个问题是,当遇到无效的公式时,jexcel会致命地失败。如果您需要解析客户提供的电子表格,这是一个问题。
also the new POI version support (almost) seemless both xls and xlsx at the same time.
同时,新的POI版本支持(几乎)xls和xlsx都是无效的。
#5
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.
Excel将VBA使用的相同OLE自动化API公开给支持COM的任何内容。您可以使用win32com(默认情况下包含在ActiveState Python中)来操作电子表格,就像在VBA中一样。
#1
#2
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".
+1表示xlwt。有关如何使用xlwt以及如何处理大型电子表格的帖子,请参阅Matt Harrison的博客。另外,请查看Google上的python-excel组“如果您使用Python来读取,写入或以其他方式操作Excel文件”。
#3
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.
我使用JExcelApi,但仅仅因为我之前使用过它。从未接触过HSSF。我记得最大的show-stopper是JExcelApi不支持一个单元格中的多种格式(例如粗体的一半文本,另一半用斜体或类似的东西)。我认为一般来说JExcelApi比HSSF更有限,但是这些限制从来没有妨碍我。
And yes, documentation is sparse for the interface (and nonexistent for the underlying mechanisms), but I thought it was doable...
是的,文档对于接口是稀疏的(并且对于底层机制是不存在的),但我认为它是可行的......
#4
1
i personally dis-advise JExcel if you intent to use anything more then very simple text to excel and vice versa.
如果您打算使用任何更简单的文本来表现出色,我个人会劝告JExcel,反之亦然。
the more advanced features are abstracted very leaky from the underlying (basically undocumented) low-level code / (documented) Excel specs.
更高级的功能从底层(基本上未记录的)低级代码/(记录的)Excel规范中抽象出来。
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.
我们遇到的另一个问题是,当遇到无效的公式时,jexcel会致命地失败。如果您需要解析客户提供的电子表格,这是一个问题。
also the new POI version support (almost) seemless both xls and xlsx at the same time.
同时,新的POI版本支持(几乎)xls和xlsx都是无效的。
#5
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.
Excel将VBA使用的相同OLE自动化API公开给支持COM的任何内容。您可以使用win32com(默认情况下包含在ActiveState Python中)来操作电子表格,就像在VBA中一样。