@@ -71,7 +71,7 @@ def read_excel(io, sheetname=0, **kwds):
71
71
72
72
Parameters
73
73
----------
74
- io : string, file-like object, or xlrd workbook.
74
+ io : string, file-like object, or xlrd workbook.
75
75
The string could be a URL. Valid URL schemes include http, ftp, s3,
76
76
and file. For file URLs, a host is expected. For instance, a local
77
77
file could be file://localhost/path/to/workbook.xlsx
@@ -166,7 +166,7 @@ def __init__(self, io, **kwds):
166
166
self .book = io
167
167
elif not isinstance (io , xlrd .Book ) and hasattr (io , "read" ):
168
168
# N.B. xlrd.Book has a read attribute too
169
- data = io .read ()
169
+ data = io .read ()
170
170
self .book = xlrd .open_workbook (file_contents = data )
171
171
else :
172
172
raise ValueError ('Must explicitly set engine if not passing in'
@@ -1029,21 +1029,24 @@ def _convert_to_alignment(cls, alignment_dict):
1029
1029
@classmethod
1030
1030
def _convert_to_number_format (cls , number_format_dict ):
1031
1031
"""
1032
- Convert ``number_format_dict`` to an openpyxl v2 NumberFormat object.
1032
+ Convert ``number_format_dict`` to an openpyxl v2.1.0 number format
1033
+ initializer.
1033
1034
Parameters
1034
1035
----------
1035
1036
number_format_dict : dict
1036
1037
A dict with zero or more of the following keys.
1037
- 'format_code'
1038
+ 'format_code' : str
1038
1039
Returns
1039
1040
-------
1040
- number_format : openpyxl.styles.NumberFormat
1041
+ number_format : str
1041
1042
"""
1042
-
1043
- from openpyxl .styles import NumberFormat
1044
-
1045
- return NumberFormat (** number_format_dict )
1046
-
1043
+ try :
1044
+ # >= 2.0.0 < 2.1.0
1045
+ from openpyxl .styles import NumberFormat
1046
+ return NumberFormat (** number_format_dict )
1047
+ except :
1048
+ # >= 2.1.0
1049
+ return number_format_dict ['format_code' ]
1047
1050
1048
1051
@classmethod
1049
1052
def _convert_to_protection (cls , protection_dict ):
0 commit comments