diff --git a/pandas/io/excel.py b/pandas/io/excel.py index 84f04188b7906..10d8e457b6dba 100644 --- a/pandas/io/excel.py +++ b/pandas/io/excel.py @@ -1029,20 +1029,20 @@ def _convert_to_alignment(cls, alignment_dict): @classmethod def _convert_to_number_format(cls, number_format_dict): """ - Convert ``number_format_dict`` to an openpyxl v2 NumberFormat object. + Convert ``number_format_dict`` to an openpyxl v2.1.0 number format + initializer. Parameters ---------- number_format_dict : dict A dict with zero or more of the following keys. - 'format_code' + 'format_code' : str Returns ------- - number_format : openpyxl.styles.NumberFormat + number_format : str """ - from openpyxl.styles import NumberFormat - - return NumberFormat(**number_format_dict) + # XXX: Only works with openpyxl-2.1.0 + return number_format_dict['format_code'] @classmethod diff --git a/pandas/io/tests/test_excel.py b/pandas/io/tests/test_excel.py index 17407e3a864e2..3d92242283f07 100644 --- a/pandas/io/tests/test_excel.py +++ b/pandas/io/tests/test_excel.py @@ -1238,7 +1238,7 @@ def test_to_excel_styleconverter(self): alignment = styles.Alignment(horizontal='center', vertical='top') fill_color = styles.Color(rgb='006666FF', tint=0.3) fill = styles.PatternFill(patternType='solid', fgColor=fill_color) - number_format = styles.NumberFormat(format_code='0.00') + number_format = '0.00' # XXX: Only works with openpyxl-2.1.0 protection = styles.Protection(locked=True, hidden=False) kw = _Openpyxl2Writer._convert_to_style_kwargs(hstyle)