adding hyperlinks in some cells openpyxl adding hyperlinks in some cells openpyxl python python

adding hyperlinks in some cells openpyxl


If wanting to use Excel's built in hyperlink function directly, you can use the following to format as a link:

'=HYPERLINK("{}", "{}")'.format(link, "Link Name")

e.g. ws.cell(row=1, column=1).value = '=HYPERLINK("{}", "{}")'.format(link, "Link Name")


This works for me:

wbook.active['A8'].hyperlink = "http://www.espn.com"wbook.active['A8'].value = 'ESPN'wbook.active['A8'].style = "Hyperlink"


Try this :

sheet['A1'].hyperlink = "http://stackoverflow.com"sheet['A1'].value="StackOverflow"

In my try this does not add the formatting that Excel puts with a hyperlink but the cell contents are more like the Excel hyperlink cell than I get with the HYPERLINK tag.