python openpyxl模块使用

import openpyxl

wbk = openpyxl.Workbook()
sd_sheet = wbk.active
sd_sheet.title = 'sd'
sd_sheet2 = wbk.create_sheet('sd2')
sd_sheet.cell(1,1,"设备编号")
sd_sheet.cell(1,2,"类型")
sd_sheet.cell(1,3,"名称")
sd_sheet.cell(1,4,"IP地址")
sd_sheet.cell(1,5,"用途")
for j in rang(1,10)
    sd_sheet.cell(j,1,host_sn)
    sd_sheet.cell(j,2,host_type)
    sd_sheet.cell(j,3,host_name)
    sd_sheet.cell(j,4,host_ip)
    sd_sheet.cell(j,5,host_used)
    #sd_sheet.cell(j,4,(",".join(need_list)))
    j += 1

sd_sheet2.cell(1,1,"ldap授权用户")
sd_sheet2.cell(1,2,"系统授权用户")
sd_sheet2.cell(1,3,"other")
#sd_sheet2.cell(0,3,"sum用户")

猜你喜欢

转载自www.cnblogs.com/tengfei520/p/10856357.html