Please download the EPPlus .NET library from the link - http://epplus.codeplex.com/ First of all, if we create a Hyperlink, using function, first we need to know the formula.
What is an Excel formula ?
- A formula is an expression, which calculates the value of the cell. A formula performs the other action on the data in your worksheet. A formula always starts with an equal sign(=), which can be followed by the numbers, mathematical operators (like a '+' or '-' sign for addition or subtraction) and some built-in Excel functions, which can really expand the power of a formula.
What is an Excel function ?
- A function is predefined in formulas and are already available in Excel or spreadsheets like SUM(), COUNT(), HYPERLINK() etc. These built-in functions are used for the specific purpose.
What is HYPERLINK() Function ?

HYPERLINK() is a predefined Excel function & it takes two parameters. First is link location & second is friendly name or display name. When we are clicking it, it will redirect to the link location.
Hyperlink function uses Formula property of ExcelRange class given below.

Hyperlink function uses Formula property of ExcelRange class given below.
- ExcelRange Rng = wsSheet1.Cells["B19"];
- String SiteLink = "https://www.google.com";
- String DisTxt = "Go to GOOGLE";
- Rng.Formula = "=HYPERLINK(\"" + SiteLink + "\", \"" + DisTxt + "\")";
In the above example, we can see formula property. By using formula property, we can set cell formula in an Excel sheet. It accepts a string as a formula. In Part 4 of this tutorial, we know that EPPlus don't have formula calculation engine, so if you type a wrong Excel formula in the code, the compiler does not show any compilation error but generated Excel sheet will show an error.
Hyperlink function works on
To any local file,

Hyperlink function works on
- To another cell of an existing sheet.
- To different sheet within same Excel file.
- To any local file.
- To any remote Server file.
- To link with an E-mail address.
To another cell of an existing sheet
- ExcelRange Rng = wsSheet1.Cells["B20"];
- String Sht1_B10 = "#'Sheet1'!B2";
- String B10 = "Go to Cell B2";
- Rng.Formula = "=HYPERLINK(\"" + Sht1_B10 + "\", \"" + B10 +"\")";
Another sheet within same Excel file,
- ExcelRange Rng = wsSheet1.Cells["B21"];
- String Sht2_B1= "#'Sheet2'!B2";
- String B1 = "Go to Cell B1 in Sheet2";
- Rng.Formula = "=HYPERLINK(\"" + Sht2_B1 + "\", \"" + B1 +"\")";
- ExcelRange Rng = wsSheet1.Cells["B22"];
- String Local_File = @"D:\Sample.xlsx";
- String File = "D:\\Sample.xlsx";
- Rng.Formula = "=HYPERLINK(\"" + Local_File + "\", \"" + File + "\")";
- ExcelRange Rng = wsSheet1.Cells["B23"];
- String AbsoLnk = "https://goo.gl/gOa0wm";
- Rng.Formula = "=HYPERLINK(\"" + AbsoLnk+ "\", \"" + AbsoLnk + "\")";
- ExcelRange Rng = wsSheet1.Cells["B24"];
- String MailLnk = "mailto:[email protected]";
- String MailID = "[email protected]";
- Rng.Formula = "=HYPERLINK(\"" + MailLnk + "\", \"" + MailID + "\")";

Source code

Former memberPosted May 26, 2017, 5:38 AM
Source code file link is broken again.