copy cell style openpyxl

Solutions on MaxInterview for copy cell style openpyxl by the best coders in the world

showing results for - "copy cell style openpyxl"
Line
16 Feb 2017
1def copy_last_cell_Style(new_cell, cell):
2
3    if cell.has_style:
4        print("Cell has style")
5        new_cell.font = copy(cell.font)
6        new_cell.border = copy(cell.border)
7        new_cell.fill = copy(cell.fill)
8        new_cell.number_format = copy(cell.number_format)
9        new_cell.protection = copy(cell.protection)
10        new_cell.alignment = copy(cell.alignment)
11    return new_cell
12  
13 copy_last_cell_Style(WS[f"a{WS.max_row}"],
14                                 WS[f"a{WS.max_row - 1}"])