Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set color of text using xlwt

Tags:

python

xlrd

xlwt

I haven't been able to find documentation on how to set the color of text. How would the following be done in xlwt?

style = xlwt.XFStyle()

# bold
font = xlwt.Font()
font.bold = True
style.font = font

# background color
pattern = xlwt.Pattern()
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = xlwt.Style.colour_map['pale_blue']
style.pattern = pattern

# color of text
???

Another way I have tried, where I've been able to set the font color but not the background color is:

style = xlwt.easyxf('font: bold 1, color red;')
like image 362
David542 Avatar asked Mar 26 '13 23:03

David542


1 Answers

This is what worked:

style = xlwt.easyxf('pattern: pattern solid, fore_colour light_blue;'
                              'font: colour white, bold True;')
like image 120
David542 Avatar answered Oct 20 '22 03:10

David542