【Python学习】python操作excel超链接

= HYPERLINK(“{}”,“{}”)’.format(链接,“链接名称”)

 

import xlwt

wb = xlwt.Workbook()
ws = wb.add_sheet('test')

# 链接
style = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
al = xlwt.Alignment()
al.horz = 0x02 # 设置水平居中
al.vert = 0x01 # 设置垂直居中
style.alignment = al

# 链接
# write_table_of_sheet0.write(11, 2, u"=HYPERLINK(\"#详情!a1\", \"详情\")\r", hyper_style)
# write_table_of_sheet0.write(13, 2, u"=HYPERLINK(\"#链接!a1\", \"链接\")\r", hyper_style)
write_table_of_sheet0.write(11, 2, xlwt.Formula(u"HYPERLINK(\"#详情!a1\", \"详情\")\r"), hyper_style)
write_table_of_sheet0.write(13, 2, xlwt.Formula(u"HYPERLINK(\"#链接!a1\", \"链接\")\r"), hyper_style)

 

 

posted @ 2020-04-22 13:04  gtea  阅读(7139)  评论(0编辑  收藏  举报