0
    ws.cell(row=greenBegin+1, column=3).style.fill.fill_type = 'solid'

    ws.cell(row=greenBegin+1, column=3).style.fill.start_color.index = '0000FF'

    ws.cell(row=greenBegin+1, column=3).style.fill.end_color.index = '0000FF'

I'm attempting to set the fill of a cell to solid green using this code, but I always get "AttributeError: can't set attribute" when I run the code. I've tried different styling methods, but there isn't a whole lot of information on this library AFAIK which is bothersome to say the least as I'm using it for a work project.

Matt Ellen
  • 11,268
  • 4
  • 68
  • 90
Luke Faez
  • 13
  • 4

1 Answers1

-1

This is covered in the documentation. Styles are immutable and therefore cannot be edited in place. They must be reassigned.

http://openpyxl.readthedocs.org/en/2.3.0-b1/styles.html

ws.cell(…).fill = Fill(…)

Charlie Clark
  • 18,477
  • 4
  • 49
  • 55