码迷,mamicode.com
首页 > 其他好文 > 详细

2,自动化巡检_excel巡检模板

时间:2019-09-27 15:15:09      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:red   xls   状态   bottom   巡检   检查   style   条目   结果   

 

自动化巡检脚本 

创建两个巡检excel

import xlwt
workbook = xlwt.Workbook(encoding=utf-8)

#创建第一个巡检sheet
cisco = workbook.add_sheet(上海网络设备巡检)
style = xlwt.XFStyle()
pattern = xlwt.Pattern()
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = xlwt.Style.colour_map[red]
style.pattern = pattern
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style.borders = borders
al = xlwt.Alignment()
al.horz = 0x02
al.vert = 0x01
style.alignment = al
style1 = xlwt.XFStyle()
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1

style1.borders = borders
al = xlwt.Alignment()
al.horz = 0x02
al.vert = 0x01
style1.alignment = al

style3 = xlwt.XFStyle()
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style3.borders = borders
al = xlwt.Alignment()
al.horz = 0x02
al.vert = 0x01
style3.alignment = al

first_col = cisco.col(0)
sec_col = cisco.col(1)
thr_col = cisco.col(2)
for_col = cisco.col(3)
first_col.width = 200 * 25
sec_col.width = 120 * 25
thr_col.width = 120 * 25
for_col.width = 320 * 25


cisco.write(0, 0,设备名称,style)
cisco.write(0,1, 管理地址,style)
cisco.write(0,2, 检查项,style)
cisco.write(0,3, 检查结果,style)
cisco.write(1,2, 电源状态,style1)
cisco.write(2,2, cpu使用率,style1)
cisco.write(3,2, 运行时间,style1)
cisco.write(4,2, 内存使用率,style1)
cisco.write(5,2, 风扇状态,style1)
cisco.write(6,2, 日志条目,style1)

#上面是第一个sheet
cisco2 = workbook.add_sheet(昆山网络巡检表)
style = xlwt.XFStyle()
pattern = xlwt.Pattern()
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = xlwt.Style.colour_map[red]
style.pattern = pattern
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style.borders = borders
al = xlwt.Alignment()
al.horz = 0x02
al.vert = 0x01
style.alignment = al

style1 = xlwt.XFStyle()
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style1.borders = borders
al = xlwt.Alignment()
al.horz = 0x02
al.vert = 0x01
style1.alignment = al

style3 = xlwt.XFStyle()
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
style3.borders = borders
al = xlwt.Alignment()
al.horz = 0x02
al.vert = 0x01
style3.alignment = al

first_col = cisco2.col(0)
sec_col = cisco2.col(1)
thr_col = cisco2.col(2)
for_col = cisco2.col(3)
first_col.width = 200 * 25
sec_col.width = 120 * 25
thr_col.width = 120 * 25
for_col.width = 320 * 25


cisco2.write(0, 0,设备名称,style)
cisco2.write(0,1, 管理地址,style)
cisco2.write(0,2, 检查项,style)
cisco2.write(0,3, 检查结果,style)
cisco2.write(1,2, 电源状态,style1)
cisco2.write(2,2, cpu使用率,style1)
cisco2.write(3,2, 运行时间,style1)
cisco2.write(4,2, 内存使用率,style1)
cisco2.write(5,2, 风扇状态,style1)
cisco2.write(6,2, 日志条目,style1)

workbook.save(上海韵达分拨网络设备巡检1.xls)

 

2,自动化巡检_excel巡检模板

标签:red   xls   状态   bottom   巡检   检查   style   条目   结果   

原文地址:https://www.cnblogs.com/xiaomai-rhce/p/11597965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!