Skip to content

Commit 836f39e

Browse files
committed
Revert changes to xlwt
1 parent de53808 commit 836f39e

File tree

2 files changed

+6
-41
lines changed

2 files changed

+6
-41
lines changed

pandas/io/excel.py

+2-36
Original file line numberDiff line numberDiff line change
@@ -1468,37 +1468,6 @@ def write_cells(self, cells, sheet_name=None, startrow=0, startcol=0,
14681468
startcol + cell.col,
14691469
val, style)
14701470

1471-
@classmethod
1472-
def _tweak_style(cls, item):
1473-
item = item.copy()
1474-
for k in ['top', 'right', 'bottom', 'left']:
1475-
if k not in item:
1476-
continue
1477-
side = item[k]
1478-
if not hasattr(side, 'items'):
1479-
continue
1480-
color = side.get('color') or side.get('colour')
1481-
if color is not None:
1482-
item[k + '_color'] = color
1483-
if side.get('style'):
1484-
item[k] = side['style']
1485-
if 'fill' in item and 'pattern' not in item:
1486-
fill = item.pop('fill')
1487-
item['pattern'] = {}
1488-
for k in ['patternType', 'patterntype', 'fill_type']:
1489-
if k in fill:
1490-
item['pattern']['pattern'] = fill[k]
1491-
break
1492-
for k in ['fgColor', 'fgcolor', 'start_color']:
1493-
if k in fill:
1494-
item['pattern']['fore_color'] = fill[k]
1495-
break
1496-
for k in ['bgColor', 'bgcolor', 'end_color']:
1497-
if k in fill:
1498-
item['pattern']['back_color'] = fill[k]
1499-
break
1500-
return item
1501-
15021471
@classmethod
15031472
def _style_to_xlwt(cls, item, firstlevel=True, field_sep=',',
15041473
line_sep=';'):
@@ -1507,19 +1476,16 @@ def _style_to_xlwt(cls, item, firstlevel=True, field_sep=',',
15071476
15081477
hstyle = {"font": {"bold": True},
15091478
"border": {"top": "thin",
1510-
"right": {"style": "thin", "color": "red"},
1479+
"right": "thin",
15111480
"bottom": "thin",
15121481
"left": "thin"},
15131482
"align": {"horiz": "center"}}
15141483
will be converted to
15151484
font: bold on; \
1516-
border: top thin, right thin, right_color red, \
1517-
bottom thin, left thin; \
1485+
border: top thin, right thin, bottom thin, left thin; \
15181486
align: horiz center;
15191487
"""
15201488
if hasattr(item, 'items'):
1521-
item = cls._tweak_style(item)
1522-
15231489
if firstlevel:
15241490
it = ["%s: %s" % (key, cls._style_to_xlwt(value, False))
15251491
for key, value in item.items()]

pandas/tests/io/test_excel.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -2355,22 +2355,21 @@ def check_called(func):
23552355

23562356

23572357
@pytest.mark.parametrize('engine', [
2358-
'xlwt',
2358+
pytest.mark.xfail('xlwt', reason='xlwt does not support '
2359+
'openpyxl-compatible style dicts'),
23592360
'xlsxwriter',
23602361
'openpyxl',
23612362
])
23622363
def test_styler_to_excel(engine):
23632364
def style(df):
23642365
# XXX: RGB colors not supported in xlwt
23652366
return DataFrame([['font-weight: bold', '', ''],
2366-
(['', '', ''] if engine == 'xlwt'
2367-
else ['', 'color: blue', '']),
2367+
['', 'color: blue', ''],
23682368
['', '', 'text-decoration: underline'],
23692369
['border-style: solid', '', ''],
23702370
['', 'font-style: italic', ''],
23712371
['', '', 'text-align: right'],
2372-
(['', '', ''] if engine == 'xlwt'
2373-
else ['background-color: red', '', '']),
2372+
['background-color: red', '', ''],
23742373
['', '', ''],
23752374
['', '', ''],
23762375
['', '', '']],

0 commit comments

Comments
 (0)