GemBox.Spreadsheet is a .NET component that enables you to read, write, edit, convert, and print spreadsheet files from your .NET applications using one simple API.

ExcelCell Hyperlinks

GemBox.Spreadsheet can read and write hyperlinks, but the level of support depends on the Excel file format:

  • In XLS, only HYPERLINK formula is supported.
  • In XLSX, both Hyperlink property and HYPERLINK formula are supported.
  • In PDF, ODS and HTML, only Hyperlink property is supported.

You can set hyperlink to URL or to some location in the workbook.

Screenshot
ExcelCell Hyperlinks Screenshot

See the full code below, use Run Example to execute.

using GemBox.Spreadsheet;
using System;
using System.IO;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        ExcelFile ef = new ExcelFile();
        ExcelWorksheet ws = ef.Worksheets.Add("Hyperlinks");

        ws.Cells["A1"].Value = "Hyperlink examples:";

        ExcelCell cell = ws.Cells["B3"];
        cell.Value = "GemBoxSoftware";
        cell.Style.Font.UnderlineStyle = UnderlineStyle.Single;
        cell.Style.Font.Color = SpreadsheetColor.FromName(ColorName.Blue);
        cell.Hyperlink.Location = "http://www.gemboxsoftware.com";
        cell.Hyperlink.IsExternal = true;

        cell = ws.Cells["B5"];
        cell.Value = "Jump";
        cell.Style.Font.UnderlineStyle = UnderlineStyle.Single;
        cell.Style.Font.Color = SpreadsheetColor.FromName(ColorName.Blue);
        cell.Hyperlink.ToolTip = "This is tool tip! This hyperlink jumps to E1.";
        cell.Hyperlink.Location = ws.Name + "!E1";

        ws.Cells["E1"].Value = "Destination";

        cell = ws.Cells["B8"];
        cell.Formula = "=HYPERLINK(\"https://www.gemboxsoftware.com/spreadsheet/examples/excel-cell-hyperlinks/207\", \"Example of HYPERLINK formula\")";
        cell.Style.Font.UnderlineStyle = UnderlineStyle.Single;
        cell.Style.Font.Color = SpreadsheetColor.FromName(ColorName.Blue);

        ef.Save("Hyperlinks.xlsx");
    }
}
Imports GemBox.Spreadsheet
Imports System.IO

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")

        Dim ef As ExcelFile = New ExcelFile
        Dim ws As ExcelWorksheet = ef.Worksheets.Add("Hyperlinks")

        ws.Cells("A1").Value = "Hyperlink examples:"

        With ws.Cells.Item("B3")
            .Value = "GemboxSoftware"
            .Style.Font.UnderlineStyle = UnderlineStyle.Single
            .Style.Font.Color = SpreadsheetColor.FromName(ColorName.Blue)
            .Hyperlink.Location = "http://www.gemboxsoftware.com"
            .Hyperlink.IsExternal = True
        End With

        With ws.Cells.Item("B5")
            .Value = "Jump"
            .Style.Font.UnderlineStyle = UnderlineStyle.Single
            .Style.Font.Color = SpreadsheetColor.FromName(ColorName.Blue)
            .Hyperlink.ToolTip = "This is tool tip! This hyperlink jumps to E1!"
            .Hyperlink.Location = (ws.Name & "!E1")
        End With

        ws.Cells("E1").Value = "Destination"

        With ws.Cells.Item("B8")
            .Formula = "=HYPERLINK(""https://www.gemboxsoftware.com/spreadsheet/examples/excel-cell-hyperlinks/207"", ""Example of HYPERLINK formula"")"
            .Style.Font.UnderlineStyle = UnderlineStyle.Single
            .Style.Font.Color = SpreadsheetColor.FromName(ColorName.Blue)
        End With

        ef.Save("Hyperlinks.xlsx")

    End Sub

End Module

Check next sample.