Building on the approach by @guillaume-jacquenot we can use apply to apply this to an entire Series.

df = pd.DataFrame({'Year': [2000, 2001, 2002 , 2003]})

For cleanliness, I wrote a helper method.

def make_hyperlink(value):
    url = "https://custom.url/{}"
    return '=HYPERLINK("%s", "%s")' % (url.format(value), value)

Then, apply it to the Series:

df['hyperlink'] = df['Year'].apply(make_hyperlink)
    Year    hyperlink
0   2000    =HYPERLINK("https://custom.url/2000", "2000")
1   2001    =HYPERLINK("https://custom.url/2001", "2001")
2   2002    =HYPERLINK("https://custom.url/2002", "2002")
3   2003    =HYPERLINK("https://custom.url/2003", "2003")
Answer from Dannid on Stack Overflow
🌐
XlsxWriter
xlsxwriter.readthedocs.io › example_hyperlink.html
Example: Adding hyperlinks — XlsxWriter
############################################################################### # # Example of how to use the XlsxWriter module to write hyperlinks # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2013-2025, John McNamara, jmcnamara@cpan.org # import xlsxwriter # Create a new workbook and add a worksheet workbook = xlsxwriter.Workbook("hyperlink.xlsx") worksheet = workbook.add_worksheet("Hyperlinks") # Format the first column worksheet.set_column("A:A", 30) # Add a sample alternative link format.
🌐
GitHub
github.com › pandas-dev › pandas › issues › 13439
Feature request: read_excel to support hyperlinks split into label and hyperlink · Issue #13439 · pandas-dev/pandas
June 14, 2016 - (see screenshot) Add an argument for example named hyperlinkparser to read_excel() that offers options: "label", "hyperlink", "both" label ... just the label (this is how it is handled now) hyperlink ...
Author: pandas-dev
🌐
YouTube
youtube.com › watch
Data Science with Python! Creating a Spreadsheet with Hyperlinks - YouTube
Tutorial on creating an Excel spreadsheet with hyperlinks.The notebook can be found in the "Data Science with Python" folder within the below repo. GitHub Re...
Published: March 20, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-create-a-table-with-clickable-hyperlink-to-a-local-file-in-pandas
How to create a table with clickable hyperlink to a local file in Pandas? - GeeksforGeeks
If you are familiar with Data Science or Machine Learning field then we can definitely say that we are going to learn something new from this article, So let's begin. Here in this article, we will learn how to create a clickable hyperlink of the local file path using pandas.
Published: March 15, 2021
🌐
Python Forum
python-forum.io › thread-20041.html
How to add hyperlink to existing Excel file
Hi, I have below the main table (both table are (csv): grp1 grp2 grp Date grp1_1 grp1_2 Date grp2_1 grp2_2 grp2_3 AHJ 20191/7/1 1/3 2/5 20191/7/1 2/5 3/3 2/6 AKL ...
Find elsewhere
🌐
Blogger
rbucodejk1.blogspot.com › 2015 › 05 › python-add-hyperlink-to-excel-sheet.html
python - add hyperlink to excel sheet created by pandas dataframe to_excel method -
December 9, 2017 - now, want add hyperlinks values in 1 column. in other words, when customer sees excel sheet, able click on cell , bring webpage (depending on value in cell). ... import pandas pd df = pd.dataframe({'link':['=hyperlink("http://www.someurl.com", "some website")']}) df.to_excel('test.xlsx')
🌐
EasyXLS
easyxls.com › manual › tutorials › python › excel-hyperlink-cell-file-sheet-url.html
Excel hyperlink to cell, file, sheet and URL in Python | EasyXLS Guide
Code sample Python: Create Excel file with hyperlink to cell, hyperlink to file, hyperlink to sheet or URL using EasyXLS library. XLSX, XLSM, XLSB, XLS file
🌐
Pylenin
pylenin.com › blogs › adding-hyperlink-openpyxl
Openpyxl - Adding hyperlinks to cells in Excel with Python
June 20, 2022 - You can directly use the HYPERLINK built-in function in Excel. ws.cell(row=1, column=1).value = '=HYPERLINK("{}", "{}")'.format(link, "Link Name") link - The url link to point Link Name - The string to display ... from openpyxl import Workbook ...
Top answer
1 of 5
19

This can be done with openpyxl, I'm not sure its possible with Pandas at all. Here's how I've done it:

import openpyxl

wb = openpyxl.load_workbook('yourfile.xlsm')
sheets = wb.sheetnames
ws = wb[sheets[0]]
# Deprecation warning
# ws = wb.get_sheet_by_name('Sheet1')
print(ws.cell(row=2, column=1).hyperlink.target)

You can also use iPython, and set a variable equal to the hyperlink object:

t = ws.cell(row=2, column=1).hyperlink

then do t. and press tab to see all the options for what you can do with or access from the object.

2 of 5
4

Quick monkey patching, without converters or anything like this, if you would like to treat ALL cells with hyperlinks as hyperlinks, more sophisticated way, I suppose, at least be able to choose, what columns treat as hyperlinked or gather data, or save somehow both data and hyperlink in same cell at dataframe. And using converters, dunno. (BTW I played also with data_only, keep_links, did not helped, only changing read_only resulted ok, I suppose it can slow down your code speed).

P.S.: Works only with xlsx, i.e., engine is openpyxl

P.P.S.: If you reading this comment in the future and issue https://github.com/pandas-dev/pandas/issues/13439 still Open, don't forget to see changes in _convert_cell and load_workbook at pandas.io.excel._openpyxl and update them accordingly.

import pandas
from pandas.io.excel._openpyxl import OpenpyxlReader
import numpy as np
from pandas._typing import FilePathOrBuffer, Scalar


def _convert_cell(self, cell, convert_float: bool) -> Scalar:
    from openpyxl.cell.cell import TYPE_BOOL, TYPE_ERROR, TYPE_NUMERIC
    # here we adding this hyperlink support:
    if cell.hyperlink and cell.hyperlink.target:
        return cell.hyperlink.target
        # just for example, you able to return both value and hyperlink,
        # comment return above and uncomment return below
        # btw this may hurt you on parsing values, if symbols "|||" in value or hyperlink.
        # return f'{cell.value}|||{cell.hyperlink.target}'
    # here starts original code, except for "if" became "elif"
    elif cell.is_date:
        return cell.value
    elif cell.data_type == TYPE_ERROR:
        return np.nan
    elif cell.data_type == TYPE_BOOL:
        return bool(cell.value)
    elif cell.value is None:
        return ""  # compat with xlrd
    elif cell.data_type == TYPE_NUMERIC:
        # GH5394
        if convert_float:
            val = int(cell.value)
            if val == cell.value:
                return val
        else:
            return float(cell.value)

    return cell.value


def load_workbook(self, filepath_or_buffer: FilePathOrBuffer):
    from openpyxl import load_workbook
    # had to change read_only to False:
    return load_workbook(
        filepath_or_buffer, read_only=False, data_only=True, keep_links=False
    )


OpenpyxlReader._convert_cell = _convert_cell
OpenpyxlReader.load_workbook = load_workbook

And after adding this above in your python file, you will be able to call df = pandas.read_excel(input_file)

After writing all this stuff it came to me, that maybe it would be easier and cleaner just use openpyxl by itself ^_^

Top answer
1 of 1
4

Here is one way to do it using xlsxwriter as the Excel engine:

import pandas as pd

df = pd.DataFrame({'ID': [1, 2],
                   'link':['=HYPERLINK("http://www.python.org", "some website")',
                           '=HYPERLINK("http://www.python.org", "some website")']})

# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('test.xlsx', engine='xlsxwriter')

# Convert the dataframe to an XlsxWriter Excel object.
df.to_excel(writer, sheet_name='Sheet1')


# Get the xlsxwriter objects from the dataframe writer object.
workbook  = writer.book
worksheet = writer.sheets['Sheet1']

# Get the default URL format.
url_format = workbook.get_default_url_format()

# Apply it to the appropriate column, and widen the column.
worksheet.set_column(2, 2, 40, url_format)

# Close the Pandas Excel writer and output the Excel file.
writer.close()

Output, note that the second link has been clicked and is a different color:

Note, it would be preferable to use the xlsxwriter worksheet.write_url() method since that will look like a native Excel url to the end user and also doesn't need the above trick of getting and applying the url format. However, that method can't be used directly from a pandas dataframe (unlike the formula) so you would need to iterate through the link column of the dataframe and overwrite the formulas programatically with actual links.

Something like this:

import pandas as pd

df = pd.DataFrame({'ID': [1, 2],
                   'link':['=HYPERLINK("http://www.python.org", "some website")',
                           '=HYPERLINK("http://www.python.org", "some website")']})

# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('test2.xlsx', engine='xlsxwriter')

# Convert the dataframe to an XlsxWriter Excel object.
df.to_excel(writer, sheet_name='Sheet1')

# Get the worksheet handle.
worksheet = writer.sheets['Sheet1']

# Widen the colum for clarity
worksheet.set_column(2, 2, 40)

# Overwrite the urls
worksheet.write_url(1, 2, "http://www.python.org", None, "some website")
worksheet.write_url(2, 2, "http://www.python.org", None, "some website")

# Close the Pandas Excel writer and output the Excel file.
writer.save()

Output:

🌐
knanne
knanne.github.io › notebooks › pandas_dataframes_to_excel_with_toc.html
Pandas DataFrames to Excel with TOC - knanne -
March 17, 2018 - # instantiate an Excel writer xls_writer = pd.ExcelWriter('data/pandas_dataframes_to_excel_with_toc.xlsx') # save toc data as dictionary with first entry as TOC xls_toc = {'0': 'Table of Contents'} # create toc placeholder as first sheet in Excel df = pd.DataFrame() df.to_excel(xls_writer, '0') # iterate database, write DataFrames, and save toc data for i,(title,df) in enumerate(database.items()): # save DataFrame title and sheet link in TOC dictionary sheet_name = title sheet_num = i+1 xls_toc[sheet_num] = '=HYPERLINK("#{}!A1","{}")'.format(str(sheet_num),sheet_name) # add header level to Dat
🌐
DataScientYst
datascientyst.com › create-clickable-link-pandas-dataframe-jupyterlab
How to Create a Clickable Link(s) in Pandas DataFrame and JupyterLab
June 21, 2022 - Here are few different approaches to create a hyperlink in Pandas DataFrame and JupyterLab: (1) Pandas method: to_html and parameter render_links=True:
🌐
GeeksforGeeks
geeksforgeeks.org › python › saving-long-urls-with-pandas-and-xlsxwriter
Saving Long URLs with Pandas and XlsxWriter - GeeksforGeeks
July 23, 2025 - This article dives into handling URLs in Excel using Python, specifically with the `pandas` library and the `XlsxWriter` engine. By the end, we'll learn how to efficiently save and format long URLs in Excel files and ensure they remain user-friendly. Excel is a powerful tool for managing and analyzing data, but working with URLs can be tricky. Long URLs often break when displayed in cells, causing formatting issues or making the spreadsheet difficult to read. Moreover, Excel might not automatically treat text as hyperlinks, requiring extra steps to keep your URLs clickable.