How to Create Hyperlinks in Excel with C#
IronXL enables C# developers to create various hyperlinks in Excel cells including URLs, file paths, email addresses, and cell references without using Interop, simplifying the process of adding interactive navigation to spreadsheets.
Excel hyperlinks provide clickable references to locations within the workbook, different files, web pages, or email addresses. They enhance navigation, allowing quick access to related information and external resources. Hyperlinks create interactive and user-friendly spreadsheets, facilitating easy access to additional data or external content.
IronXL enables the creation of hyperlinks for URLs, opening external files from both local and FTP (File Transfer Protocol) file systems, email addresses, cell addresses, and defined name cells without the use of Interop in .NET C#. This functionality is essential when working with Excel files programmatically in business applications.
Quickstart: Add a Hyperlink with IronXL in Just a Few Steps
This example shows how easy it is to add a web hyperlink to an Excel cell using IronXL. In just a few lines—create the workbook, set the cell value, assign the hyperlink, and save—you'll have an interactive link in your spreadsheet. For more comprehensive Excel manipulation, explore our guide on editing Excel files in C#.
Get started making PDFs with NuGet now:
Install IronXL with NuGet Package Manager
Copy and run this code snippet.
IronXL.WorkBook workbook = IronXL.WorkBook.Create(IronXL.ExcelFileFormat.XLSX); workbook.DefaultWorkSheet.GetCellAt(0, 0).Value = "Visit IronXL Docs"; workbook.DefaultWorkSheet.GetCellAt(0, 0).Hyperlink = "https://ironsoftware.com"; workbook.SaveAs("hyperlink_quick.xlsx");Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download the C# library for creating hyperlinks
- Load an existing Excel file or create a new one
- Create a hyperlink to a website URL link
- Create a hyperlink to a cell or define name within the same worksheet or across worksheets
- Use the
Hyperlinkproperty to create hyperlinks to open files and emails
What Prerequisites Do I Need?
Before implementing hyperlinks, ensure you have IronXL installed in your .NET project. You'll also need a basic understanding of selecting ranges and managing worksheets in IronXL. The library supports .NET Framework 4.6.2+ and .NET Core/5/6/7/8+, making it compatible with most modern .NET applications.
How Do I Create URL Hyperlinks in Excel Cells?
The Hyperlink property exists in the Cell class. The worksheet["A1"] code returns a Range object; use the First method to access the first cell in the range.
Alternatively, directly access the cell using the GetCellAt method, allowing you to access the Hyperlink property directly. This approach is particularly useful when working with specific cell coordinates in your spreadsheets.
Let's explore an example of creating link hyperlinks. Both HTTP and HTTPS protocols are supported, enabling you to link to secure and non-secure web resources. When creating hyperlinks, consider combining them with cell formatting to make them visually distinct from regular text.
GetCellAt method to select an unmodified cell will throw System.NullReferenceException: 'Object reference not set to an instance of an object.':path=/static-assets/excel/content-code-examples/how-to/hyperlinks-set-link-hyperlink.csusing IronXL;
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Modify the cell's property
workSheet["A1"].Value = "Link to ironpdf.com";
// Set hyperlink at A1 to https://ironpdf.com/
workSheet.GetCellAt(0, 0).Hyperlink = "https://ironpdf.com/";
workBook.SaveAs("setLinkHyperlink.xlsx");What Happens When I Click the Created Hyperlink?
When you click a hyperlink created with IronXL, Excel prompts you to open the linked URL in your default web browser. The cell maintains its original value while adding the hyperlink functionality, allowing you to preserve descriptive text while enabling navigation. This behavior is consistent whether you're working with Excel files locally or deploying to cloud environments.

How Do I Create Hyperlinks Across Different Worksheets?
To create a hyperlink to a cell within the same worksheet, use the cell’s address, such as Z20. To create a hyperlink across worksheets, use the address convention worksheetName!address. For example, Sheet2!A1. This cross-worksheet linking capability is essential when building complex Excel reports with multiple data sheets.
Defined name cells can have either workbook (global) or worksheet scope. To create a hyperlink to a defined name within the same worksheet or a defined name with workbook scope, specify the name directly. To create a hyperlink for a defined name with worksheet scope on a different worksheet, specify the worksheet name as mentioned above. For example, Sheet2!Iron. Learn more about working with named ranges for advanced Excel automation.
:path=/static-assets/excel/content-code-examples/how-to/hyperlinks-set-hyperlink-across-worksheet.csusing IronXL;
using System.Linq;
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet workSheet1 = workBook.CreateWorkSheet("Sheet1");
WorkSheet workSheet2 = workBook.CreateWorkSheet("Sheet2");
// Create workbook(global) define name
workSheet1["D5"].SaveAsNamedRange("Iron", true);
// Create worksheet define name
workSheet2["D10"].SaveAsNamedRange("Hello", false);
// --== Within the same worksheet ==--
// Set hyperlink to cell Z20
workSheet1["A1"].Value = "Z20";
workSheet1["A1"].First().Hyperlink = "Z20";
// Set hyperlink to define name "Iron"
workSheet1["A2"].Value = "Iron";
workSheet1["A2"].First().Hyperlink = "Iron";
// --== Across worksheet ==--
// Set hyperlink to cell A1 of Sheet2
workSheet1["A3"].Value = "A1 of Sheet2";
workSheet1["A3"].First().Hyperlink = "Sheet2!A1";
// Set hyperlink to define name "Hello" of Sheet2
workSheet1["A4"].Value = "Define name Hello of Sheet2";
workSheet1["A4"].First().Hyperlink = "Sheet2!Hello";
workBook.SaveAs("setHyperlinkAcrossWorksheet.xlsx");Why Use Named Ranges for Hyperlinks?
Named ranges provide more maintainable hyperlinks that survive worksheet restructuring. When you rename or move cells, hyperlinks pointing to named ranges automatically update, reducing broken links in your Excel applications. This approach is particularly valuable in dynamic reports where data positions may change.

What’s the Difference Between Workbook and Worksheet Scope?
Workbook scope (global) named ranges are accessible from any worksheet within the workbook, while worksheet scope names are only accessible within their specific worksheet. When creating hyperlinks to named ranges, workbook scope names provide more flexibility, but worksheet scope names offer better encapsulation for sheet-specific data. This distinction becomes crucial when managing multiple worksheets in complex Excel applications.
How Do I Create File, FTP, and Email Hyperlinks?
In addition to the hyperlink types mentioned earlier, IronXL also supports the creation of FTP, file, and email hyperlinks. These specialized hyperlink types expand your Excel automation capabilities beyond simple web links.
- FTP: Starting with
ftp://- Links to files on FTP servers - File: Specify an absolute path starting with
file:///- Links to local or network files - Email: Starting with
mailto:- Creates clickable email addresses
:path=/static-assets/excel/content-code-examples/how-to/hyperlinks-set-other-hyperlink.csusing IronXL;
using System.Linq;
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Set hyperlink to open file sample.xlsx
workSheet["A1"].Value = "Open sample.xslx";
workSheet["A1"].First().Hyperlink = "ftp://C:/Users/sample.xlsx";
// Set hyperlink to open file sample.xlsx
workSheet["A2"].Value = "Open sample.xslx";
workSheet["A2"].First().Hyperlink = "file:///C:/Users/sample.xlsx";
// Set hyperlink to email example@gmail.com
workSheet["A3"].Value = "example@gmail.com";
workSheet["A3"].First().Hyperlink = "mailto:example@gmail.com";
workBook.SaveAs("setOtherHyperlink.xlsx");When Should I Use File vs FTP Hyperlinks?
Use file hyperlinks (file:///) for local files or network shares accessible through the Windows file system. FTP hyperlinks (ftp://) are ideal for linking to files on FTP servers, particularly in enterprise environments where documents are stored on dedicated file servers. Consider security implications when using FTP links, as they may transmit credentials in plain text.

What Email Client Opens When Clicking Mailto Links?
When users click mailto links in Excel, their default email client opens with a new message pre-addressed to the specified email. This works with Outlook, Thunderbird, and web-based email clients configured as system defaults. You can enhance mailto links with subject lines and body text using standard mailto syntax: code>mailto:example@gmail.com?subject=Hello&body=Message.
How Do I Remove Hyperlinks from Excel Cells?
To remove a hyperlink, invoke the RemoveHyperlink method. This method can be accessed from the cell object. Removing hyperlinks is useful when cleaning data or converting linked reports to static documents.
:path=/static-assets/excel/content-code-examples/how-to/hyperlinks-remove-hyperlink.csusing IronXL;
using System.Linq;
WorkBook workBook = WorkBook.Load("setLinkHyperlink.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Remove hyperlink
workSheet["A1"].First().RemoveHyperlink();
workBook.SaveAs("removeHyperlink.xlsx");Does Removing a Hyperlink Delete the Cell Content?
No, removing a hyperlink preserves the cell’s value and formatting. Only the hyperlink functionality is removed, leaving the display text intact. This makes it safe to remove hyperlinks without data loss, which is particularly important when converting spreadsheet file types or preparing documents for archival.
How Do I Remove Multiple Hyperlinks at Once?
To remove multiple hyperlinks efficiently, iterate through a range of cells or use LINQ to process cells containing hyperlinks:
// Remove all hyperlinks in column A
for (int i = 1; i <= 10; i++)
{
var cell = workSheet.GetCellAt(i, 0);
if (cell != null && !string.IsNullOrEmpty(cell.Hyperlink))
{
cell.RemoveHyperlink();
}
}// Remove all hyperlinks in column A
for (int i = 1; i <= 10; i++)
{
var cell = workSheet.GetCellAt(i, 0);
if (cell != null && !string.IsNullOrEmpty(cell.Hyperlink))
{
cell.RemoveHyperlink();
}
}This approach is particularly useful when cleaning imported data or preparing spreadsheets for distribution where hyperlinks might not be appropriate. For more advanced cell manipulation techniques, explore our guide on selecting and working with ranges.
Frequently Asked Questions
How do I create a hyperlink in Excel using C#?
You can easily create hyperlinks in Excel using IronXL by accessing a cell and setting its Hyperlink property. Simply load or create a workbook, get the desired cell using GetCellAt() or worksheet indexer, then assign a URL string to the cell's Hyperlink property. IronXL handles all the complex Excel formatting automatically without requiring Microsoft Interop.
What types of hyperlinks can be created in Excel cells?
IronXL supports creating various types of hyperlinks including: web URLs for external websites, file paths to open local or FTP files, email addresses with mailto links, cell references within the same worksheet, and references to defined name cells. All these hyperlink types can be implemented using the same Hyperlink property in IronXL.
Do I need Microsoft Office installed to add hyperlinks to Excel files?
No, IronXL operates independently without requiring Microsoft Office or Interop assemblies. The library includes all necessary components to create, read, and modify Excel files with hyperlinks directly in your .NET application, making it ideal for server environments where Office installation isn't feasible.
What .NET frameworks are supported for creating Excel hyperlinks?
IronXL supports a wide range of .NET frameworks including .NET Framework 4.6.2 and higher, as well as .NET Core, .NET 5, 6, 7, and 8+. This broad compatibility ensures you can integrate IronXL's hyperlink functionality into both legacy applications and modern .NET projects.
Can I add hyperlinks to existing Excel files or only new ones?
IronXL allows you to add hyperlinks to both new and existing Excel files. You can load an existing workbook using WorkBook.Load(), access any cell or range, and add hyperlinks without affecting other content or formatting in the spreadsheet. The library preserves existing data while adding new interactive elements.
How do I access a specific cell to add a hyperlink?
IronXL provides multiple ways to access cells for adding hyperlinks. You can use GetCellAt() with row and column indices, or use the worksheet indexer with cell addresses like worksheet["A1"]. For ranges, use the First method to get the first cell. The library also supports selecting ranges for batch hyperlink operations.






