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 @@ -2009,7 +2009,12 @@ files if `Xlsxwriter`_ is not available.
2009
2009
.. _xlwt : http://www.python-excel.org
2010
2010
2011
2011
To specify which writer you want to use, you can pass an engine keyword
2012
- argument to ``to_excel `` and to ``ExcelWriter ``.
2012
+ argument to ``to_excel `` and to ``ExcelWriter ``. The built-in engines are:
2013
+
2014
+ - `'openpyxl `': This includes stable support for OpenPyxl 1.6.1 up to but
2015
+ not including 2.0.0, and experimental support for OpenPyxl 2.0.0 and later.
2016
+ - `'xlsxwriter' `
2017
+ - `'xlwt' `
2013
2018
2014
2019
.. code-block :: python
2015
2020
Original file line number Diff line number Diff line change @@ -673,6 +673,12 @@ Enhancements
673
673
674
674
675
675
676
+ - Added experimental compatibility with openpyxl v2. The ``DataFrame.to_excel``
677
+ method ``engine`` keyword now recognizes ``openpyxl1`` and ``openpyxl2``
678
+ which will explicitly require openpyxl v1 and v2 respectively, failing if
679
+ the requested version is not available. The ``openpyxl`` engine is a now a
680
+ meta-engine that automatically uses whichever version of openpyxl is
681
+ installed. (:issue:`7177`)
676
682
677
683
678
684
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