-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Upgrade Excel I/O module to use OpenPyXL 2 #7177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
dupe of #7169 py3.4 build already has 2.02 (and so fails) |
Could you re-open this issue and reassign it to the 0.14.1 milestone? |
any thoughts on this? (getting it to work with >= 2.0) |
I've been spending my pandas time allocation on this. My thoughts, in case anybody else is driven to work on this before I can get to it, are as follows (caveat: I haven't thought about this for a couple weeks, so my recollection about some of these details may betray me). There appear to be two main pieces to this feature. One is simply the conversion of a style dict to a native openpyxl There are some differences in the structure of the The other main piece is the merge behavior. I've had more trouble wrapping my head around how this should work. The new-style
I think this is a fine set of semantics to adopt for the internal style merging behavior of pandas, because it keeps the padding between the user and the engine implementation thin. I'm not sure what that implies for the openpyxl v1 case. At the least, it may be convenient to model a compatibility shim as a backport of the |
It occurred to me belatedly to wonder, since I have never used The other thing I finally realized I didn't really know for sure, and need to, is whether the style dict those formatted cells carry around is required to be engine-agnostic, or if it can vary from engine to engine. I guessed that the intention was the former, and the uniformity of the usage examples --- the only internal user in If it were up to me, I think I would choose a very limited subset of all possible styling available in the underlying Excel, and call that the engine-agnostic, To accommodate users who do want to exert a great deal of control over cell styling, an additional, separable feature could be to teach A related question. Does pandas have some sort of policy, roadmap, or procedure for determining version support? That is, how will we know when we can drop support for the old version of openpyxl? I welcome discussion or even just direction. |
to your last points we try maintain support for as long as possible with dep libraries until it becomes too painful :) if it's easy enough then no biggie openpyxl 1.6 I think is the min version but only. 1 year old I think it's becoming pretty easy IMHO to upgrade individual deps easily so if their is a recommendation to drop support for something we can discuss note that pandas does still supports numpy 1.6.1 (and this is painful!) |
@jreback I'm not suggesting that we drop support for anything at the moment. I'm just trying to get a sense of how long the life of an openpyxl v1/v2 compatibility shim might be. |
one way to do this might be to make a openpyxl_v2 engine (and then depending on the installation choose one or the other) |
Yes, that's a good point. Splitting the implementation at the engine level would probably be better. I still think that we need a spec and documentation for the style dict, both of which would be informed by whether it is intended for internal use only, or is an external feature that we also use internally. |
The PR I just posted still has some rough edges (see, for example, I find that openpyxl is maddeningly full of corner cases and reasons why I can't do something simple and uniform. If anybody sees a missed opportunity to refactor and consolidate this code, I welcome suggestions or even alternative PRs. |
OpenPyXL v2.0 was released on May 13th, breaking backwards compatibility in some parts of its API, including those upon which pandas depends. Notably, v2 changes the style API and makes
Style
objects immutable. This incompatibility is evident at 0.14.0-rc1 inpandas.io.excel._OpenpyxlWriter._convert_to_style
and the associated test case,pandas.io.tests.test_excel.OpenyxlTests.test_to_excel_styleconverter
.In addition to teaching
pandas
how to use the new API, the project may wish to retain support for the OpenPyXL v1 API, necessitating the design and development of a compatibility shim.The text was updated successfully, but these errors were encountered: