我想在Excel单元格中的文本下方添加一个URL链接,以便用户可以访问该网站。我尝试了但没有成功,请帮忙。
base = xlwt.Workbook()
for k,v in MainDict.items():
base.add_sheet(k)
xlwt.add_palette_colour("custom_colour", 0x21)
base.set_colour_RGB(0x21, 251, 228, 228)
style = xlwt.easyxf('pattern: pattern solid, fore_colour custom_colour;font : bold on')
style1 = xlwt.easyxf('font : underline single')
index = MainDict.keys().index(k)
ws = base.get_sheet(index)
col=0
for sk in MainDict[k].keys():
ws.write(0,col,sk.upper(),style)
col+=1
row =1
for mk in MainDict[k][sk].keys():
for lk,lv in MainDict[k][sk][mk].items():
for items in lv:
ws.write(row,col-1,(items + str(Formula('HYPERLINK("%s")'%mk))))
row+=1
base.save('project2.xls')