Reputation: 49
I'm currently using openpyxl
to modify specific excel cells. I am able to modify font styles very easily, simply just:
ws['A1'].font = Font(color=colors.White)
But I am unable to change the fill of the specific cell. Anyone know any documentation about how to do this? I want to just change the color of one cell, so what other packages are required?
I tried exploring some other things like PatternFill
, but I haven't been able to accurately get what I'm looking for. All I need is to change the fill color of a single cell.
Upvotes: 4
Views: 9779
Reputation: 15953
What was the PatternFill code that you tried using? Is it something similar to this?
from openpyxl.styles import PatternFill
redFill = PatternFill(start_color='FFEE1111', end_color='FFEE1111', fill_type='solid')
Then to apply to a specific cell use:
ws['A1'].fill = redFill
Or for grading:
fill = PatternFill(fill_type=None, start_color='FFFFFFFF', end_color='FF000000')
Upvotes: 1