import openpyxl as xl
from openpyxl.styles import Font, colors
wb = xl.load_workbook('schedule.xlsx')
sheet = wb['Schedule']
for row in range(2, sheet.max_row + 1):
for column in range(1, 7):
cell = sheet.cell(column, row)
word = str(cell.value)
if '-' in word:
index = word.index('-')
part = word[index:]
print(part)
# ???????
cell.font = Font(color=colors.RED)
wb.save('new_schedule.xlsx')
Hello, I want this program to pick cells that contain '-'. Then it should colour only the part after '-' with red colour. Code I made makes whole cell red, I haven't found anything useful in documentation of this package.
Would really appreciate some suggestions