zoukankan      html  css  js  c++  java
  • 2,自动化巡检_excel巡检模板

    自动化巡检脚本 

    创建两个巡检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')
  • 相关阅读:
    分享一款颜色神器ColorSchemer Studio
    只要你用atom修改后保存代码文件的时候,你在chrome上的页面就会自动刷新。
    十六进制颜色代码
    WordPress窗体化侧边栏
    QQ输入法中英文标点符号快速切换
    Android ListView的item背景色设置以及item点击无响应等相关问题
    Android内存优化(使用SparseArray和ArrayMap代替HashMap)
    [Fatal Error] :3:13: Open quote is expected for attribute "{1}" associated with an element type "id".
    java模式—装饰者模式
    Java模式—适配器模式
  • 原文地址:https://www.cnblogs.com/xiaomai-rhce/p/11597965.html
Copyright © 2011-2022 走看看