Good morning, I would like to fill some cells with a gray background, the code works and the color as well, in visual code in the preview of the excel file I see the colors correctly, are that when I open the file with excel the background is always black. any help?
def excel():
# Writing on a EXCEL FILE
filename = ("testexcelcolor.xlsx")
try:
wb = load_workbook(filename)
ws = wb.worksheets[0] # select first worksheet
except FileNotFoundError:
headers_row = ['Name SGV PN', 'IVU Nummer']
wb = Workbook()
ws = wb.active
ws.append(headers_row)
for cols in ws.iter_cols():
if cols[-1].value: # need to check the cells have values.
# otherwise colors the entire row.
cols[-1].fill = PatternFill(bgColor="FFFFFF", fill_type="solid")
wb.save(filename)
ws.append([ivunumber])
wb.save(filename)
wb.close()
excel()
Aucun commentaire:
Enregistrer un commentaire