How to Remove Hyperlinks in Excel Using Python (Single or All)

Casie LiuCasie Liu
4 min read

Hyperlinks in Excel make it easy to access websites, files, or email addresses directly from your spreadsheet. However, Excel often turns plain text into clickable links by default—especially URLs and emails—which can clutter your data and disrupt analysis. If you’re looking to clean up your workbook, this guide shows you how to remove hyperlinks in Excel using Python. Whether you want to delete a single hyperlink or remove all at once, Python offers a quick and efficient solution.

If you only need to disable a specific hyperlink in an Excel sheet, the key steps are locating the hyperlink and then removing it. In the following step-by-step guide, I’ll walk you through how to do this using free Spire.XLS for Python—a lightweight and user-friendly library for handling Excel files with Python. Let’s dive in and see how it works.

Steps to remove a hyperlink in Excel files:

  • Create an object of the Workbook class.

  • Load an Excel file using the Workbook.LoadFromFile() method.

  • Get a worksheet from the Excel workbook through the Workbook.Worksheets.get_Item() method.

  • Delete a hyperlink in the worksheet with the HyperLinks.RemoveAt() method.

  • Save the modified Excel spreadsheet using the Workbook.SaveToFile() method.

The code example here shows how to remove the first hyperlink in the first worksheet:

from spire.xls import *
from spire.xls.common import *


# Create a Workbook object
workbook = Workbook()
# Load an Excel file
workbook.LoadFromFile("/sample.xlsx")

# Get the first worksheet of the file
sheet = workbook.Worksheets.get_Item(0)

# Remove the first hyperlink and keep its display text
sheet.HyperLinks.RemoveAt(0)

# Save the resulting file
workbook.SaveToFile("/RemoveHyperlink.xlsx", ExcelVersion.Version2016)
workbook.Dispose()

Remove a Hyperlink in Excel Using Python

After learning how to remove a single hyperlink, let’s take it a step further and explore how to delete all hyperlinks in an Excel file. While you can still use the HyperLinks.RemoveAt() method, removing multiple items requires reverse iteration to avoid index shifting. In this section, I’ll show you a simpler and more efficient approach that allows you to remove hyperlinks directly once and for all.

Steps to disable all hyperlinks in Excel files:

  • Create an instance of the Workbook class.

  • Read an Excel workbook from files through the Workbook.LoadFromFile() method.

  • Retrieve a certain worksheet with the Workbook.Worksheets.get_Item() method.

  • Undo all hyperlinks in the worksheet using the Worksheet.HyperLinks.Clear() method.

  • Save the updated Excel file.

The code example below demonstrates how to remove all hyperlinks in the first Worksheet:

from spire.xls import *
from spire.xls.common import *

# Create a Workbook object
workbook = Workbook()
# Load an Excel file
workbook.LoadFromFile("/sample.xlsx")

# Get the first worksheet of the file
sheet = workbook.Worksheets.get_Item(0)

# Clear all hyperlinks in the worksheet
sheet.HyperLinks.Clear()

# Save the resulting file
workbook.SaveToFile("/RemoveallHyperlinks.xlsx", ExcelVersion.Version2016)

workbook.Dispose()
💡
In case you need it, here is a sample code that uses reverse iteration:
# Loop through all hyperlinks in the worksheet
for i in range(sheet.HyperLinks.Count - 1, -1, -1):
    # Remove the first hyperlink and keep its display text
    sheet.HyperLinks.RemoveAt(i)

Remove All Hyperlinks in Excel with Python

The Bottom Line

In this tutorial, we explored how to remove hyperlinks in Excel using Python — whether it's deleting a single hyperlink or clearing all hyperlinks in a worksheet. With the help of free Spire.XLS for Python, the process becomes simple and efficient. Now, you can keep your Excel files clean and better organized without the hassle of manual edits.

Q1: How do I take off a hyperlink in Excel?

To remove a hyperlink in Excel, right-click on the link and select “Remove Hyperlink” from the context menu. The hyperlink will be removed, but the text will remain. This is a quick way to take off a hyperlink in Excel.

Q2: How do I change a hyperlink to normal text in Excel?

In Microsoft Excel, removing a hyperlink automatically keeps the original text. So, if you want to change a hyperlink to normal text, simply remove the hyperlink — the data stays intact.

Q3: How do you remove all hyperlinks?

To remove all hyperlinks in Excel, select the range containing the links, right-click, and choose “Remove Hyperlinks.” This removes all links while keeping the text.

If you're looking for a faster and automated solution — especially when working with large files — try using Free Spire.XLS for Python to remove all hyperlinks in just one click.

0
Subscribe to my newsletter

Read articles from Casie Liu directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Casie Liu
Casie Liu