Python Forum
after using openpyxl to add colors to script, black shows up white online in excel - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: after using openpyxl to add colors to script, black shows up white online in excel (/thread-18977.html)



after using openpyxl to add colors to script, black shows up white online in excel - Soundtechscott - Jun-08-2019

hi, I'm scott
I'm reasonably new to python.. but learning as I go

long story as short as I can make it
I have a script that takes some excel data, uses pandas to sort it
then a use openpyxl to add some colors and formatting to several things

the script uses this function
datecolV = '000000'



##### Colors Between Dates function Black
black_fill = openpyxl.styles.fills.PatternFill(patternType='solid', fgColor=(datecolV))
rownumber = 1
for row in sheet.iter_rows(min_row=2, max_row= sheet.max_row, min_col=8, max_col=8, values_only=True):
  rownumber += 1
  for cell in row:
    if cell == None:
      if rownumber > 2 and sheet[str('H' + str(rownumber-1))].value is not None and sheet[str('H' + str(rownumber+1))].value is not None and len(sheet[str('H' + str(rownumber-1))].value) > 9 and  len(sheet[str('H' + str(rownumber+1))].value) > 9:
        ### line below for debugging
        #print(sheet[str('H' + str(rownumber-1))].value[0:9] + ' ' + sheet[str('H' + str(rownumber+1))].value[0:9])
        if sheet[str('H' + str(rownumber-1))].value[0:9] != sheet[str('H' + str(rownumber+1))].value[0:9] and rownumber >2:
          for row2 in sheet.iter_rows (min_row=rownumber, max_row=rownumber):
            for cell2 in row2:
              cell2.fill = black_fill
on the PC.. it returns as black.. works perfect

when I upload the file to the web to send to other co-workers, the blank spaces that were colored black... dont show up... they are just white?

anybody have any ideas or has anybody run across this problem before


I can manually color the cells black in excel, and they show up fine when uploaded
only has issues if I use openpyxl to color them


[Image: Capture.png]


RE: after using openpyxl to add colors to script, black shows up white online in excel - Soundtechscott - Jun-08-2019

FYI....

Changing the Colro from '000000' to '0C0C0C'.... seems to work
doesnt solve the problem, but it is a work around for now