@@ -398,14 +398,14 @@ def get_range_of_cells(row_index=None, columns=None):
398398 try :
399399 style_to_apply = column .style .to_openpyxl_style ()
400400 except AttributeError :
401- style_to_apply = column .style
401+ style_to_apply = Styler .from_openpyxl_style (column .style , [],
402+ openpyxl_comment = column .style .comment ).to_openpyxl_style ()
402403 column_header_cell = sheet .cell (row = startrow + 1 , column = col_index + startcol + 1 )
403404 column_header_cell .style = style_to_apply
404405 if isinstance (column .style , Styler ):
405406 column_header_cell .comment = column .style .generate_comment ()
406407 else :
407- if hasattr (column .style , 'comment' ):
408- column .style .comment .parent = None
408+ if hasattr (column .style , 'comment' ) and column .style .comment is not None :
409409 column_header_cell .comment = column .style .comment
410410 for row_index , index in enumerate (self .data_df .index ):
411411 current_cell = sheet .cell (row = row_index + startrow + 2 , column = col_index + startcol + 1 )
@@ -421,13 +421,13 @@ def get_range_of_cells(row_index=None, columns=None):
421421 try :
422422 style_to_apply = data_df_style .to_openpyxl_style ()
423423 except AttributeError :
424- style_to_apply = data_df_style
424+ style_to_apply = Styler .from_openpyxl_style (data_df_style , [],
425+ openpyxl_comment = data_df_style .comment ).to_openpyxl_style ()
425426 current_cell .style = style_to_apply
426427 if isinstance (data_df_style , Styler ):
427428 current_cell .comment = data_df_style .generate_comment ()
428429 else :
429- if hasattr (data_df_style , 'comment' ):
430- data_df_style .comment .parent = None
430+ if hasattr (data_df_style , 'comment' ) and data_df_style .comment is not None :
431431 current_cell .comment = data_df_style .comment
432432 except AttributeError : # if the element in the dataframe is not Container creating a default style
433433 current_cell .style = Styler ().to_openpyxl_style ()
0 commit comments