xlsx files produced in some environments are incompatible/invalid
Created originally on Bitbucket by netnichols
I recently came across an issue where openpyxl on my dev machine was producing perfectly valid xlsx files, but the same code was producing incompatible xlsx files on my staging server.
I traced this down to my staging server having lxml installed while my dev machine did not. After installing lxml on my dev machine it started producing the same (seemingly) invalid xlsx files.
These xlsx files are completely rejected by Numbers. Libreoffice does open them. And according to a colleague Excel does open them but (sometimes) displays a warning. I don't think the testing code listed below produces warnings in Excel, but if necessary I could probably (in time) give more thorough testing code which does.
I diffed the xlsx packages produced with and without lxml, and from a cursory exploration it seems that the only difference is the way namespaces are handled, but I could easily be wrong about that.
Dev Env:
OS X 10.9.1, python 2.7.5, openpyxl 1.8.0, lxml 3.2.5
Staging Env:
Ubuntu 12.04.2, python 2.7.3, openpyxl 1.8.0, lxml 2.3.2
Testing Code:
https://gist.github.com/netnichols/da3f60b1fb3496b44088
Attachments: test-without-lxml.xlsxtest-with-lxml.xlsx