SoFunction
Updated on 2024-10-29

How python xlwt sets a custom background color for a cell

concern

I use python 2.7 and the xlwt module for excel exporting

I want to set the background color of cells that I know I can use

style1 = ('pattern: pattern solid, fore_colour red;')

But I want to set custom color smth. like #8a8eef or if there is a palette of possible colors because light blue doesn't work :)

prescription

If you are not using easyxf() but XFStyle to build the object step-by-step, this is another way to use user-friendly color names:

import xlwt
style = ()
pattern = ()
 = .SOLID_PATTERN
pattern.pattern_fore_colour = .colour_map['dark_purple']
 = pattern

This is the whole content of this article.