赞
踩
import openpyxl as xcl def init_wb(): wb = xcl.Workbook() sheet = wb.active sheet.title = "CVE INFO" sheet["A1"] = "CVE NO." sheet["B1"] = "V2" sheet["C1"] = "V3" sheet["D1"] = "Summary" # 设置单元格式 # A1居右,B1, C1居中,D1长度为256 # end sheet.column_dimensions["A"].width = 18 sheet.column_dimensions["D"].width = 196 return wb, sheet def write_cveno_lst(src_file): wb, sheet = init_wb() with open(src_file, "r") as src: lst = src.readlines() i = 2 for cveno in lst: sheet["A%d" % i].value = cveno.replace("\n", "") i += 1 wb.save(src_file+".xlsx") if __name__ == "__main__": # l2 是一个文本,每一行是一个cve编号 write_cveno_lst("l2")
from urll
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。