Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xlsx Writer Critera If Blank

Given this format:

format0 = workbook.add_format({'bg_color': 'none'})

I'd like to apply it (no background color) if the cell is blank. Here's what I've tried so far:

worksheet.conditional_format('B2:B14', 
{'type':'cell', 
'criteria': '=isblank()=True', 
'format': format0
})

But I keep getting this error:

KeyError: 'value'

I'm pretty sure I'm not using a correct entry for 'criteria', but I'm not sure how to do it.

Thanks in advance!

like image 760
Dance Party Avatar asked Aug 25 '16 02:08

Dance Party


1 Answers

One solution:

It appears that setting the color to 'none' produces blue cells, for some reason. So instead, I opted to color blank cells white:

format0 = workbook.add_format({'bg_color': 'white'})

Then, by reading the documentation (what a great idea!):

worksheet.conditional_format('B2:B14', {'type':'blanks', 'format': format0})

I put this before other conditional formats for the same column.

like image 83
Dance Party Avatar answered Sep 20 '22 01:09

Dance Party