I want to color cell in an xlsx doc in terms of value
Here's an example
1
I want to color all the "Alexandre"
For that, I created this:
path_to_excel="doc.xlsx"
exemple=openpyxl.load_workbook(path_to_excel)
ws = exemple['Sheet1'] #Name of the working sheet
from openpyxl.styles import PatternFill
#on définie la couleur de coloriage en hexa
Ok_couleur = PatternFill(patternType='solid',
fgColor='94e0de')
for column in ws['B']:
if column.value == "Alexandre":
ws['B3'].fill = Ok_couleur
I only coloured one cell, but I want to colour all of them with Alexandre.
I tried to change the B3 with B in this line, but I was unsuccessful.
for column in ws['B']:
if column.value == "Alexandre":
ws['B3'].fill = Ok_couleur`