编程语言
首页 > 编程语言> > python向excel中写入超链接

python向excel中写入超链接

作者:互联网

# 向excel中写数据
book = xlwt.Workbook(encoding='utf-8')  # 创建Workbook,相当于创建Excel
# 创建sheet,Sheet1为表的名字,cell_overwrite_ok为是否覆盖单元格
sheet1 = book.add_sheet(u'Sheet1', cell_overwrite_ok=True)
for index, keya in enumerate(arr):
    con = keya["id"] + " " + keya["zh_title"] + " " + keya["time"]
    sheet1.write(index, 0, xlwt.Formula('HYPERLINK("{}", "{}"\r)'.format(keya["origin_url"], con)))
    book.save('test.xls')

 

标签:index,sheet,python,excel,book,sheet1,超链接,keya,overwrite
来源: https://www.cnblogs.com/lxz123/p/15873986.html