如何使用 xlwt 设置文本颜色

问题描述:

我找不到有关如何设置文本颜色的文档.以下将如何在 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;')

这是有效的:

style = xlwt.easyxf('pattern: pattern solid, fore_colour light_blue;'
                              'font: colour white, bold True;')