首页 技术 正文
技术 2022年11月10日
0 收藏 482 点赞 3,183 浏览 1380 个字
#-*- coding:utf-8 -*-
#首先注意一个问题 pycharm 中路径符号和Linux 系统一样向左
import xlwtdef add_color():
#实例化对象 增加sheet 创建模式 绿色三行 红色三行
workbook = xlwt.Workbook(encoding='utf-8')
worksheet = workbook.add_sheet('我的 Sheet1')
pattern1 = xlwt.Pattern() # Create the Pattern 模式
pattern1.pattern = xlwt.Pattern.SOLID_PATTERN # May be: NO_PATTERN, SOLID_PATTERN, or 0x00 through 0x12
pattern1.pattern_fore_colour = 3 # May be: 8 through 63. 0 = Black, 1 = White, 2 = Red, 3 = Green, 4 = Blue, 5 = Yellow, 6 = Magenta, 7 = Cyan, 16 = Maroon, 17 = Dark Green, 18 = Dark Blue, 19 = Dark Yellow , almost brown), 20 = Dark Magenta, 21 = Teal, 22 = Light Gray, 23 = Dark Gray, the list goes on...
style1 = xlwt.XFStyle() # Create the Pattern 样式
style1.pattern = pattern1 # Add Pattern to Style
worksheet.write(0, 0, '第一行第一列', style1)
worksheet.write(1, 0, '第二行第一列', style1)
worksheet.write(2, 0, '第三行第一列', style1) pattern2 = xlwt.Pattern() # Create the Pattern 模式
pattern2.pattern = xlwt.Pattern.SOLID_PATTERN # May be: NO_PATTERN, SOLID_PATTERN, or 0x00 through 0x12
pattern2.pattern_fore_colour = 5 # May be: 8 through 63. 0 = Black, 1 = White, 2 = Red, 3 = Green, 4 = Blue, 5 = Yellow, 6 = Magenta, 7 = Cyan, 16 = Maroon, 17 = Dark Green, 18 = Dark Blue, 19 = Dark Yellow , almost brown), 20 = Dark Magenta, 21 = Teal, 22 = Light Gray, 23 = Dark Gray, the list goes on...
style2 = xlwt.XFStyle() # Create the Pattern 样式 style2.pattern = pattern2 # Add Pattern to Style
worksheet.write(0, 1, '第一行第二列', style2)
worksheet.write(1, 1, '第二行第二列', style2)
worksheet.write(2, 1, '第三行第二列', style2) workbook.save('C:/Users/WY/Desktop/aaa.xls')if __name__ == "__main__":
add_color()

18-10-08 对Excel 表格添加颜色


    					
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,557
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898