IronXL How-Tos Hyperlink How to Create Hyperlink ByChaknith Bin June 22, 2023 Updated June 22, 2025 Share: 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. View the IronXL YouTube Playlist 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#. How to Create Hyperlink 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 Hyperlink property to create hyperlinks to open files and emails Get started with IronXL Start using IronXL in your project today with a free trial. First Step: Start for Free Create Link Hyperlink Example The Hyperlink property exists in the Cell class. The worksheet["A1"] code returns a Range object, you can use the First method to access the first cell in the range. Alternatively, you can directly access the cell using the GetCellAt method, allowing you to access the Hyperlink property directly. Let's explore an example of creating link hyperlinks. Both HTTP and HTTPS protocols are supported. Before proceedingUsing the 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.cs // Import the IronXL library for Excel functionality. using IronXL; // Create a new workbook with the Excel file format specified as XLSX. // The 'WorkBook.Create' method initializes a new instance of a workbook. WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX); // Access the default worksheet in the newly created workbook. // The default worksheet is a starting point to enter and modify data. WorkSheet workSheet = workBook.DefaultWorkSheet; // Set the value of cell A1 to a description or text. // The text here serves as an anchor for the hyperlink. workSheet["A1"].Value = "Link to ironpdf.com"; // Set a hyperlink on cell A1 to direct to the URL "https://ironpdf.com/". // Hyperlinks in Excel link the text in a cell to an external web page. workSheet.GetCellAt("A1").Hyperlink = new Hyperlink("https://ironpdf.com/"); // Save the workbook with the specified file name. // This writes the data to the file system, making sure your Excel file is saved. workBook.SaveAs("setLinkHyperlink.xlsx"); ' Import the IronXL library for Excel functionality. Imports IronXL ' Create a new workbook with the Excel file format specified as XLSX. ' The 'WorkBook.Create' method initializes a new instance of a workbook. Private workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX) ' Access the default worksheet in the newly created workbook. ' The default worksheet is a starting point to enter and modify data. Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Set the value of cell A1 to a description or text. ' The text here serves as an anchor for the hyperlink. Private workSheet("A1").Value = "Link to ironpdf.com" ' Set a hyperlink on cell A1 to direct to the URL "https://ironpdf.com/". ' Hyperlinks in Excel link the text in a cell to an external web page. workSheet.GetCellAt("A1").Hyperlink = New Hyperlink("https://ironpdf.com/") ' Save the workbook with the specified file name. ' This writes the data to the file system, making sure your Excel file is saved. workBook.SaveAs("setLinkHyperlink.xlsx") $vbLabelText $csharpLabel Demonstration Create Hyperlink Across Worksheet Example To create a hyperlink to a cell within the same worksheet, simply use the cell's address, such as Z20. However, to create a hyperlink across worksheets, you can use the address convention "worksheetName!address". For example, "Sheet2!A1". Define name cells can have either workbook(global) or worksheet scope. If you want to create a hyperlink to a defined name within the same worksheet or a defined name with workbook scope, you can 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". :path=/static-assets/excel/content-code-examples/how-to/hyperlinks-set-hyperlink-across-worksheet.cs using IronXL; using System.Linq; // Create a new workbook using the IronXL library WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX); // Add two worksheets to the workbook WorkSheet workSheet1 = workBook.CreateWorkSheet("Sheet1"); WorkSheet workSheet2 = workBook.CreateWorkSheet("Sheet2"); // Create a global define name "Iron" at cell D5 in Sheet1. // The `true` parameter specifies that the name is global. workSheet1["D5"].SaveAsNamedRange("Iron", true); // Create a worksheet-specific defined name "Hello" at cell D10 in Sheet2. // The `false` parameter specifies that the name is local to the sheet. workSheet2["D10"].SaveAsNamedRange("Hello", false); // --== Within the same worksheet ==-- // Set a hyperlink in cell A1 to cell Z20 within the same worksheet (Sheet1). workSheet1["A1"].Value = "Go to Z20"; workSheet1["A1"].Hyperlink = "Z20"; // Set a hyperlink in cell A2 to the defined name "Iron" within Sheet1. workSheet1["A2"].Value = "Go to Iron"; workSheet1["A2"].Hyperlink = "Iron"; // --== Across worksheets ==-- // Set a hyperlink in cell A3 to cell A1 of Sheet2 from Sheet1. workSheet1["A3"].Value = "Go to A1 of Sheet2"; workSheet1["A3"].Hyperlink = "Sheet2!A1"; // Set a hyperlink in cell A4 to the defined name "Hello" on Sheet2 from Sheet1. workSheet1["A4"].Value = "Go to Defined name Hello of Sheet2"; workSheet1["A4"].Hyperlink = "Sheet2!Hello"; // Save the workbook to a file named "setHyperlinkAcrossWorksheet.xlsx". workBook.SaveAs("setHyperlinkAcrossWorksheet.xlsx"); Imports IronXL Imports System.Linq ' Create a new workbook using the IronXL library Private workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX) ' Add two worksheets to the workbook Private workSheet1 As WorkSheet = workBook.CreateWorkSheet("Sheet1") Private workSheet2 As WorkSheet = workBook.CreateWorkSheet("Sheet2") ' Create a global define name "Iron" at cell D5 in Sheet1. ' The `true` parameter specifies that the name is global. workSheet1("D5").SaveAsNamedRange("Iron", True) ' Create a worksheet-specific defined name "Hello" at cell D10 in Sheet2. ' The `false` parameter specifies that the name is local to the sheet. workSheet2("D10").SaveAsNamedRange("Hello", False) ' --== Within the same worksheet ==-- ' Set a hyperlink in cell A1 to cell Z20 within the same worksheet (Sheet1). workSheet1("A1").Value = "Go to Z20" workSheet1("A1").Hyperlink = "Z20" ' Set a hyperlink in cell A2 to the defined name "Iron" within Sheet1. workSheet1("A2").Value = "Go to Iron" workSheet1("A2").Hyperlink = "Iron" ' --== Across worksheets ==-- ' Set a hyperlink in cell A3 to cell A1 of Sheet2 from Sheet1. workSheet1("A3").Value = "Go to A1 of Sheet2" workSheet1("A3").Hyperlink = "Sheet2!A1" ' Set a hyperlink in cell A4 to the defined name "Hello" on Sheet2 from Sheet1. workSheet1("A4").Value = "Go to Defined name Hello of Sheet2" workSheet1("A4").Hyperlink = "Sheet2!Hello" ' Save the workbook to a file named "setHyperlinkAcrossWorksheet.xlsx". workBook.SaveAs("setHyperlinkAcrossWorksheet.xlsx") $vbLabelText $csharpLabel Demonstration Create Other Types of Hyperlinks Example In addition to the hyperlink types mentioned earlier, IronXL also supports the creation of FTP, file, and email hyperlinks. FTP: Starting with ftp:// File: Specify an absolute path starting with file:/// Email: Starting with mailto: Please noteBoth FTP and File hyperlinks require the use of absolute paths. :path=/static-assets/excel/content-code-examples/how-to/hyperlinks-set-other-hyperlink.cs using IronXL; // Import IronXL to work with Excel files using System.Linq; // Import Linq for potential enumerable operations // Create a new workbook with an XLSX file format WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX); // Get the default worksheet from the workbook WorkSheet workSheet = workBook.DefaultWorkSheet; // Set a hyperlink in cell A1 to open a file named sample.xlsx using the FTP protocol workSheet["A1"].Value = "Open sample.xlsx via FTP"; workSheet["A1"].Hyperlink = "ftp://C:/Users/sample.xlsx"; // Set a hyperlink in cell A2 to open a file named sample.xlsx using the local file protocol workSheet["A2"].Value = "Open sample.xlsx from Local File"; workSheet["A2"].Hyperlink = "file:///C:/Users/sample.xlsx"; // Set a hyperlink in cell A3 to send an email to example@gmail.com workSheet["A3"].Value = "Email example@gmail.com"; workSheet["A3"].Hyperlink = "mailto:example@gmail.com"; // Save the workbook to a file named setOtherHyperlink.xlsx workBook.SaveAs("setOtherHyperlink.xlsx"); Imports IronXL ' Import IronXL to work with Excel files Imports System.Linq ' Import Linq for potential enumerable operations ' Create a new workbook with an XLSX file format Private workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX) ' Get the default worksheet from the workbook Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Set a hyperlink in cell A1 to open a file named sample.xlsx using the FTP protocol Private workSheet("A1").Value = "Open sample.xlsx via FTP" Private workSheet("A1").Hyperlink = "ftp://C:/Users/sample.xlsx" ' Set a hyperlink in cell A2 to open a file named sample.xlsx using the local file protocol Private workSheet("A2").Value = "Open sample.xlsx from Local File" Private workSheet("A2").Hyperlink = "file:///C:/Users/sample.xlsx" ' Set a hyperlink in cell A3 to send an email to example@gmail.com Private workSheet("A3").Value = "Email example@gmail.com" Private workSheet("A3").Hyperlink = "mailto:example@gmail.com" ' Save the workbook to a file named setOtherHyperlink.xlsx workBook.SaveAs("setOtherHyperlink.xlsx") $vbLabelText $csharpLabel Demonstration Remove Hyperlinks To remove a hyperlink, simply invoke the RemoveHyperlink method. This method can be accessed from the cell object. :path=/static-assets/excel/content-code-examples/how-to/hyperlinks-remove-hyperlink.cs using IronXL; // Import the IronXL namespace for spreadsheet manipulation // Load an existing workbook. // It's important that the file "setLinkHyperlink.xlsx" exists in the current working directory. WorkBook workBook = WorkBook.Load("setLinkHyperlink.xlsx"); // Access the default worksheet from the workbook. WorkSheet workSheet = workBook.DefaultWorkSheet; // Ensure we get a reference to cell A1 and remove any hyperlinks if present. // The IronXL API provides direct access to cells, so you can modify properties directly. workSheet["A1"].RemoveHyperlink(); // Save the workbook to a new file named "removeHyperlink.xlsx". // This operation will create and store the workbook with the changes made. workBook.SaveAs("removeHyperlink.xlsx"); Imports IronXL ' Import the IronXL namespace for spreadsheet manipulation ' Load an existing workbook. ' It's important that the file "setLinkHyperlink.xlsx" exists in the current working directory. Private workBook As WorkBook = WorkBook.Load("setLinkHyperlink.xlsx") ' Access the default worksheet from the workbook. Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Ensure we get a reference to cell A1 and remove any hyperlinks if present. ' The IronXL API provides direct access to cells, so you can modify properties directly. workSheet("A1").RemoveHyperlink() ' Save the workbook to a new file named "removeHyperlink.xlsx". ' This operation will create and store the workbook with the changes made. workBook.SaveAs("removeHyperlink.xlsx") $vbLabelText $csharpLabel Frequently Asked Questions What is the purpose of hyperlinks in Excel? Hyperlinks in Excel provide clickable references to locations within the workbook, different files, web pages, or email addresses, enhancing navigation and allowing quick access to related or external information. How can you create hyperlinks in Excel files using a .NET library? IronXL allows the creation of hyperlinks for URLs, opening external files from local and FTP file systems, email addresses, cell addresses, and defined name cells without using Interop in .NET C#. How do you create a hyperlink to a website URL using a .NET library? To create a hyperlink to a website URL in IronXL, you can set the Hyperlink property of a cell to a Uri object containing the URL, and then save the Excel file. Can you create hyperlinks across different worksheets in the same workbook? Yes, you can create hyperlinks across different worksheets by using the address format 'worksheetName!address'. What types of hyperlinks can be created using a .NET library? IronXL supports creating hyperlinks for HTTP and HTTPS URLs, FTP links, file paths, and email addresses. How do you remove a hyperlink from a cell using a .NET library? To remove a hyperlink from a cell in IronXL, you can use the RemoveHyperlink method on the cell object. What is the difference between using a cell address and a defined name cell for hyperlinks? Using a cell address specifies the exact location within a worksheet, while a defined name cell can reference a specific range, making it easier to manage and update links. Do FTP and file hyperlinks require specific formats when using a .NET library? Yes, FTP hyperlinks start with 'ftp://', and file hyperlinks require an absolute path starting with 'file:///'. Is it possible to set an email hyperlink using a .NET library? Yes, to set an email hyperlink in IronXL, use a Uri object with the 'mailto:' scheme. What is the advantage of using a .NET library for hyperlinks over Interop? Using IronXL for hyperlinks in Excel files eliminates the need for Excel Interop, allowing for easier and more efficient code execution within .NET applications. Chaknith Bin Chat with engineering team now Software Engineer Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking. Ready to Get Started? Free NuGet Download Total downloads: 1,487,488 View Licenses