Excel cell 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 of Excel cell hyperlinks set with GemBox.Spreadsheet
Excel cell hyperlinks set with GemBox.Spreadsheet
using GemBox.Spreadsheet;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        var workbook = new ExcelFile();
        var worksheet = workbook.Worksheets.Add("Hyperlinks");

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

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

        cell = worksheet.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 = worksheet.Name + "!E1";

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

        cell = worksheet.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);

        workbook.Save("Hyperlinks.%OutputFileType%");
    }
}
Imports GemBox.Spreadsheet

Module Program

    Sub Main()

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

        Dim workbook = New ExcelFile
        Dim worksheet = workbook.Worksheets.Add("Hyperlinks")

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

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

        With worksheet.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 = worksheet.Name & "!E1"
        End With

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

        With worksheet.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

        workbook.Save("Hyperlinks.%OutputFileType%")
    End Sub
End Module

Check next example or download examples from GitHub.