[Python] Openpyxl: set background color to a row and column Attribute Error

Discussão em 'Python' iniciado por Stack, Junho 23, 2025.

  1. Stack

    Stack Membro Participativo

    having looked at a few examples over here I tried to set background color to an entire row and column. I have done

    import openpyxl
    from openpyxl.styles import PatternFill
    wb = openpyxl.load_workbook(self.inputfile)
    ws = wb.active
    ws['A1'].fill = PatternFill(bgColor="FFC7CE", fill_type = "solid")`


    I get an Attribute error if I do `ws[1].fill =PatternFill(bgColor="FFC7CE", fill_type = "solid")

    The above code fills a single cell(A1). But how do I go forward if I want to fill an entire row(1), and an entire column(A).

    Continue reading...

Compartilhe esta Página