Wednesday, 20 August 2014

A very brief comparison of few Python tools for working with Excel files

As a part of a small Python script, it was required to export some data to Excel spreadsheet. I had a quick search to see what are the options and found these two packages:

  • xlutils (xlrd for reading and xlwt for writing): it was simple and straightforward to use it, but I encountered a couple of issues with it: if your output has more than 256 columns, then you're partially in trouble! This is a limitation of older Excel formats (xls), Excel 2003 and greater (with xlsx format), does not have that problem. But this package is not very happy with xlxs, e.g. it does not support keeping the format of xlxs files. So I'd recommend to try the next package.
  • openpyxl is more compatible with xlxs and does not have separate reader/writer classes and is simpler than xlutils to use. Keeping formatting and other issues with xlxs files are better supported here and ended up using this package.
As the title says, this is a very brief and most probably not too much accurate comparison of the two packages, but just wanted to share this short experience!