File tree 5 files changed +558
-37
lines changed
5 files changed +558
-37
lines changed Original file line number Diff line number Diff line change @@ -2058,7 +2058,12 @@ files if `Xlsxwriter`_ is not available.
2058
2058
.. _xlwt : http://www.python-excel.org
2059
2059
2060
2060
To specify which writer you want to use, you can pass an engine keyword
2061
- argument to ``to_excel `` and to ``ExcelWriter ``.
2061
+ argument to ``to_excel `` and to ``ExcelWriter ``. The built-in engines are:
2062
+
2063
+ - `'openpyxl `': This includes stable support for OpenPyxl 1.6.1 up to but
2064
+ not including 2.0.0, and experimental support for OpenPyxl 2.0.0 and later.
2065
+ - `'xlsxwriter' `
2066
+ - `'xlwt' `
2062
2067
2063
2068
.. code-block :: python
2064
2069
Original file line number Diff line number Diff line change @@ -738,6 +738,12 @@ Enhancements
738
738
739
739
740
740
741
+ - Added experimental compatibility with openpyxl v2. The ``DataFrame.to_excel``
742
+ method ``engine`` keyword now recognizes ``openpyxl1`` and ``openpyxl2``
743
+ which will explicitly require openpyxl v1 and v2 respectively, failing if
744
+ the requested version is not available. The ``openpyxl`` engine is a now a
745
+ meta-engine that automatically uses whichever version of openpyxl is
746
+ installed. (:issue:`7177`)
741
747
742
748
743
749
Original file line number Diff line number Diff line change 10
10
stop_ver = '2.0.0'
11
11
12
12
13
- def is_compat ():
14
- """Detect whether the installed version of openpyxl is supported.
13
+ def is_compat (major_ver = 1 ):
14
+ """Detect whether the installed version of openpyxl is supported
15
15
16
+ Parameters
17
+ ----------
18
+ ver : int
19
+ 1 requests compatibility status among the 1.x.y series
20
+ 2 requests compatibility status of 2.0.0 and later
16
21
Returns
17
22
-------
18
23
compat : bool
19
- ``True`` if openpyxl is installed and is between versions 1.6.1 and
20
- 2.0.0, ``False`` otherwise.
24
+ ``True`` if openpyxl is installed and is a compatible version.
25
+ ``False`` otherwise.
21
26
"""
22
27
import openpyxl
23
28
ver = LooseVersion (openpyxl .__version__ )
24
- return LooseVersion (start_ver ) <= ver < LooseVersion (stop_ver )
29
+ if major_ver == 1 :
30
+ return LooseVersion (start_ver ) <= ver < LooseVersion (stop_ver )
31
+ elif major_ver == 2 :
32
+ return LooseVersion (stop_ver ) <= ver
33
+ else :
34
+ raise ValueError ('cannot test for openpyxl compatibility with ver {0}'
35
+ .format (major_ver ))
You can’t perform that action at this time.
0 commit comments