Skip to content
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

ENH: Implement _Openpyxl2Writer for pandas.io.excel #7565

Merged
merged 1 commit into from
Sep 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion doc/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,12 @@ files if `Xlsxwriter`_ is not available.
.. _xlwt: http://www.python-excel.org

To specify which writer you want to use, you can pass an engine keyword
argument to ``to_excel`` and to ``ExcelWriter``.
argument to ``to_excel`` and to ``ExcelWriter``. The built-in engines are:

- `'openpyxl`': This includes stable support for OpenPyxl 1.6.1 up to but
not including 2.0.0, and experimental support for OpenPyxl 2.0.0 and later.
- `'xlsxwriter'`
- `'xlwt'`

.. code-block:: python

Expand Down
6 changes: 6 additions & 0 deletions doc/source/v0.15.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,12 @@ Enhancements



- Added experimental compatibility with openpyxl v2. The ``DataFrame.to_excel``
method ``engine`` keyword now recognizes ``openpyxl1`` and ``openpyxl2``
which will explicitly require openpyxl v1 and v2 respectively, failing if
the requested version is not available. The ``openpyxl`` engine is a now a
meta-engine that automatically uses whichever version of openpyxl is
installed. (:issue:`7177`)



Expand Down
21 changes: 16 additions & 5 deletions pandas/compat/openpyxl_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@
stop_ver = '2.0.0'


def is_compat():
"""Detect whether the installed version of openpyxl is supported.
def is_compat(major_ver=1):
"""Detect whether the installed version of openpyxl is supported

Parameters
----------
ver : int
1 requests compatibility status among the 1.x.y series
2 requests compatibility status of 2.0.0 and later
Returns
-------
compat : bool
``True`` if openpyxl is installed and is between versions 1.6.1 and
2.0.0, ``False`` otherwise.
``True`` if openpyxl is installed and is a compatible version.
``False`` otherwise.
"""
import openpyxl
ver = LooseVersion(openpyxl.__version__)
return LooseVersion(start_ver) <= ver < LooseVersion(stop_ver)
if major_ver == 1:
return LooseVersion(start_ver) <= ver < LooseVersion(stop_ver)
elif major_ver == 2:
return LooseVersion(stop_ver) <= ver
else:
raise ValueError('cannot test for openpyxl compatibility with ver {0}'
.format(major_ver))
Loading