python xlwt set custom background colour of a cell

前端 未结 5 1424
迷失自我
迷失自我 2020-12-08 21:04

I am using python 2.7 and xlwt module for excel export

I would like to set backgroung colour of a cell i know i can use

style1 = xlwt.easyxf(\'patter         


        
5条回答
  •  感情败类
    2020-12-08 21:27

    If you are not using easyxf() and instead are building XFStyle object step by step, here 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
    

提交回复
热议问题