@@ -1258,6 +1258,43 @@ def test_to_excel_styleconverter(self):
12581258 self .assertEqual (kw ['protection' ], protection )
12591259
12601260
1261+ def test_write_cells_merge_styled (self ):
1262+ _skip_if_no_openpyxl ()
1263+ if not openpyxl_compat .is_compat (major_ver = 2 ):
1264+ raise nose .SkipTest ('incompatiable openpyxl version' )
1265+
1266+ from pandas .core .format import ExcelCell
1267+ from openpyxl import styles
1268+
1269+ sheet_name = 'merge_styled'
1270+
1271+ sty_b1 = {'font' : {'color' : '00FF0000' }}
1272+ sty_a2 = {'font' : {'color' : '0000FF00' }}
1273+
1274+ initial_cells = [
1275+ ExcelCell (col = 1 , row = 0 , val = 42 , style = sty_b1 ),
1276+ ExcelCell (col = 0 , row = 1 , val = 99 , style = sty_a2 ),
1277+ ]
1278+
1279+ sty_merged = {'font' : { 'color' : '000000FF' , 'bold' : True }}
1280+ sty_kwargs = _Openpyxl2Writer ._convert_to_style_kwargs (sty_merged )
1281+ openpyxl_sty_merged = styles .Style (** sty_kwargs )
1282+ merge_cells = [
1283+ ExcelCell (col = 0 , row = 0 , val = 'pandas' ,
1284+ mergestart = 1 , mergeend = 1 , style = sty_merged ),
1285+ ]
1286+
1287+ with ensure_clean ('.xlsx' ) as path :
1288+ writer = _Openpyxl2Writer (path )
1289+ writer .write_cells (initial_cells , sheet_name = sheet_name )
1290+ writer .write_cells (merge_cells , sheet_name = sheet_name )
1291+
1292+ wks = writer .sheets [sheet_name ]
1293+ xcell_b1 = wks .cell ('B1' )
1294+ xcell_a2 = wks .cell ('A2' )
1295+ self .assertEqual (xcell_b1 .style , openpyxl_sty_merged )
1296+ self .assertEqual (xcell_a2 .style , openpyxl_sty_merged )
1297+
12611298
12621299class XlwtTests (ExcelWriterBase , tm .TestCase ):
12631300 ext = '.xls'
0 commit comments