python xlwt set custom background color of the cell

I use python 2.7 and carry out excel export module xlwt

I want to know I can use to set the cell background color

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

But I want to set a custom color smth. For example, # 8a8eef or is likely to color palette, because blue does not work :)

Thank you


solution


If you do not use easyxf()but XFStylegradually build an object, which is another way of using user-friendly color names:

import xlwt

style = xlwt.XFStyle() pattern = xlwt.Pattern() pattern.pattern = xlwt.Pattern.SOLID_PATTERN pattern.pattern_fore_colour = xlwt.Style.colour_map['dark_purple'] style.pattern = pattern

This article first appeared in Python black hole net , blog sync with the new park

Guess you like

Origin www.cnblogs.com/pythonzhichan/p/11440009.html