EasyXLS

Hyperlinks

EasyXLS™ library allows you to export Excel files with hyperlinks. The hyperlink is placed on a cell range.

There are four types of hyperlinks:
- Hyperlink to an URL
- Hyperlink to a file
- Hyperlink to a UNC
- Hyperlink to a cell from a sheet

The hyperlink also includes description, text mark and tool tip. A text mark is a link inside the file.

The component also allows reading hyperlinks from Excel files.

Source code sample

The below example shows how to export an Excel file with hyperlinks on a cell or cell ranges.

C#.NET
VB.NET
C++
Java
PHP
ASP
VB6
VBS
Coldfusion
Python

// Create an instance of the class that exports Excel files, having two sheets
ExcelDocument workbook = new ExcelDocument(2);

// Set the sheet names
ExcelWorksheet xlsTab1 = (ExcelWorksheet) workbook.easy_getSheetAt(0);
ExcelWorksheet xlsTab2 = (ExcelWorksheet) workbook.easy_getSheetAt(1);
xlsTab1.setSheetName("First tab");
xlsTab2.setSheetName("Second tab");

// Create hyperlink to URL
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.URL, 
        "https://www.easyxls.com", "Link to URL", "B2:E2");
  
// Create hyperlink to file
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.FILE, 
        "c:\\myfile.xlsx", "Link to file", "B3");
  
// Create hyperlink to UNC
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.UNC, 
        "\\\\computerName\\Folder\\file.txt", "Link to UNC", "B4:D4");
  
// Create hyperlink to second sheet
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL, 
        "'Second tab'!D3", "Link to CELL", "B5");
  
// Create a name on the second sheet
xlsTab2.easy_addName("Name", "=Second tab!$A$1:$A$4");
  
// Create hyperlink to name
xlsTab1.easy_addHyperlink(EasyXLS.Constants.HyperlinkType.CELL, 
        "Name", "Link to a name", "B6");

// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\Excel hyperlinks.xlsx");

     Click here to see Continuous Code Listing

The screen shot provides an example of an Excel file with hyperlinks to URL, file, UNC, another sheet and name.

Read, export hyperlink to Excel

Export hyperlink to Excel file

EasyXLS allows you to export Excel files with hyperlinks using ExcelWorksheet.easy_addHyperlink method. The above code sample shows how to achieve this goal.

Read hyperlink from Excel file

EasyXLS allows you to read hyperlinks from Excel file using ExcelWorksheet.easy_getHyperlinkAt method. The Excel file must be imported first and after that the hyperlinks are available on each sheet.


 

Available for: Professional, Excel Writer, Excel Reader
Go to top

EasyXLS Excel libraries:

.NET
.NET Excel Library
full .NET version to import, export or convert Excel files
COM+ Excel Library
full COM+ version to import, export or convert Excel files
-
Java
Java Excel Library
full Java version to import, export or convert Excel files
Download EasyXLS™ Excel Library for .NET and Java

File formats:

Office 365
MS Excel 2021 - 2025
MS Excel 2007 - 2019
MS Excel 97 - 2003
XLSXXLSMXLSBXLS
XMLHTMLCSVTXT