def generate_xls(urls, keys, result,filename):
"""?????excel??"""
xls_file = xlwt.Workbook()
sheet = xls_file.add_sheet(unicode(filename), cell_overwrite_ok=True)
font0 = xlwt.Font()
font0.name = 'Times New Roman'
font0.colour_index = 2
font0.bold = True
style0 = xlwt.XFStyle()
style0.font = font0
row = 0
sheet.col(0).width = 256 * 20
sheet.col(1).width = 256 * 30
sheet.col(2).width = 256 * 20
sheet.write(0, 0, u"??", style0)
sheet.write(0, 1, u"???", style0)
sheet.write(0, 2, u"??", style0)
if urls != None and keys != None and result != None:
for url, key, res in zip(urls, keys, result):
row += 1
sheet.write(row, 0, url.decode("utf-8"))
sheet.write(row, 1, key.decode("utf-8"))
sheet.write(row, 2, res.decode("utf-8"))
fpath=os.path.join(os.path.dirname(sys.argv[0]),u"{}.xls".format(unicode(filename))) #??????
print u"[??]???????{}".format(fpath)
xls_file.save(fpath)
评论列表
文章目录