vendredi 7 août 2020

How do I use IF statement to find a specific value in column 3 and then fgColor it accordingly? Here is my code

I am using print(i, j) to see a list of tuples of all that meet the condition. This is working, but I don't know how to use the results to put those into the final line. Please help

col_town = PatternFill(fgColor='bd291e', bgColor='FFFFFF', fill_type='solid')

  # copying the cell values from source excel file to destination excel file
  for i in range(1, max_rows + 1):
      for j in range(1, max_columns + 1):
          # reading cell value from source excel file
          c = sheet.cell(row=i, column=j)

          # writing the read value to destination excel file
          new_sheet.cell(row=i, column=j).value = c.value

          if new_sheet.cell(row=i, column=j).value == 'Town':
              print(i, j)
              new_sheet['C13'].fill = col_town

Aucun commentaire:

Enregistrer un commentaire