0
点赞
收藏
分享

微信扫一扫

Python 技术篇-用xlwt库实现设置excel单元格背景颜色、给字体加粗实例演示,【附】xlwt库颜色对照表


xlwt.easyxf()​ 设置样式,​pattern​ 指的就是背景,​ice_blue​ 就是我设置的颜色。

font​ 就是设置字体,​bold on​ 是加粗。

样式可以合一起,之间用分号​​;​​分开。

# 设置颜色
style = xlwt.easyxf('pattern: pattern solid, fore_colour ice_blue')
# 字体加粗
style = xlwt.easyxf('font: bold on')
#样式合并
style = xlwt.easyxf('pattern: pattern solid, fore_colour ice_blue; font: bold on')

# 为指定单元格设置样式
sheets.write(0, 0, "hello girl", style)

运行效果图:

Python 技术篇-用xlwt库实现设置excel单元格背景颜色、给字体加粗实例演示,【附】xlwt库颜色对照表_3d

颜色表:


aqua 0x31
black 0x08
blue 0x0C
blue_gray 0x36
bright_green 0x0B
brown 0x3C
coral 0x1D
cyan_ega 0x0F
dark_blue 0x12
dark_blue_ega 0x12
dark_green 0x3A
dark_green_ega 0x11
dark_purple 0x1C
dark_red 0x10
dark_red_ega 0x10
dark_teal 0x38
dark_yellow 0x13
gold 0x33
gray_ega 0x17
gray25 0x16
gray40 0x37
gray50 0x17
gray80 0x3F
green 0x11
ice_blue 0x1F
indigo 0x3E
ivory 0x1A
lavender 0x2E
light_blue 0x30
light_green 0x2A
light_orange 0x34
light_turquoise 0x29
light_yellow 0x2B
lime 0x32
magenta_ega 0x0E
ocean_blue 0x1E
olive_ega 0x13
olive_green 0x3B
orange 0x35
pale_blue 0x2C
periwinkle 0x18
pink 0x0E
plum 0x3D
purple_ega 0x14
red 0x0A
rose 0x2D
sea_green 0x39
silver_ega 0x16
sky_blue 0x28
tan 0x2F
teal 0x15
teal_ega 0x15
turquoise 0x0F
violet 0x14
white 0x09
yellow 0x0D


喜欢的点个赞❤吧!



举报

相关推荐

0 条评论