Search code examples
conditional-formattingxlsxwriter

Conditional formatting giving AttributeError: 'NoneType' object has no attribute 'group'


I am trying to run a conditional format for one of my column in excel using xlswriter. I want to have the blank rows in the column in a certain format. Below I have attached the code snippet. But it is giving me an AttributeError:'NoneType' object has no attribute 'group'.

format1 = workbook.add_format({'bg_color': '#FFC7CE',
                               'font_color': '#9C0006'})

worksheet.conditional_format('G:H', {'type': 'no_blanks','format':format1})

Can anyone help me on this?


Solution

  • The column notation 'G:H' isn't supported in this case. You will need to specify the full range like:

    worksheet.conditional_format('G1:H1048576',
                                 {'type': 'no_blanks','format':format1})
    

    Or with row-column notation:

    worksheet.conditional_format(0, 5, 1048575, 6,
                                 {'type': 'no_blanks','format':format1})