如何使用x设置文本颜色

2024-05-19 02:25:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我还没有找到关于如何设置文本颜色的文档。在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
???

另一种方法是,我可以设置字体颜色,但不能设置背景颜色:

style = xlwt.easyxf('font: bold 1, color red;')

Tags: 文档文本truestyle颜色colorpatternbackground

热门问题