[Root] / Xceed.Workbooks.NET Assembly / Xceed.Workbooks.NET Namespace / HyperlinkCollection Class
Example


In This Topic
    HyperlinkCollection Class
    In This Topic
    Represents a collection of Hyperlinks in a Worksheet.
    Object Model
    HyperlinkCollection ClassHyperlink Class
    Syntax
    'Declaration
     
    
    <DefaultMemberAttribute("Item")>
    Public Class HyperlinkCollection 
       Inherits WorksheetElement
    'Usage
     
    
    Dim instance As HyperlinkCollection
    [DefaultMember("Item")]
    public class HyperlinkCollection : WorksheetElement 
    Example
    using ( var workbook = Workbook.Create( "test.xlsx" ) )
      {
        // Get the first worksheet. A workbook contains at least 1 worksheet.
        var worksheet = workbook.Worksheets[ 0 ];
    
        // Add an hyperlink for a cell reference(z1) in the same worksheet.
        // Position the hyperlink in cell B6 and extend the hyperlink on 2 columns.
        worksheet.Cells[ "B5" ].Value = "Add an hyperlink to a cell reference in same worksheet:";
        worksheet.Hyperlinks.Add( "z1", "B6", 1, 2, "Link to another cell.", "A cell reference." );
    
        // Add a new worksheet and fill cells.
        workbook.Worksheets.Add();
        workbook.Worksheets[ 1 ].Cells[ "D4" ].Value = "The other worksheet.";
    
        // Add an hyperlink for a cell reference in another worksheet (sheet2, cell B1).
        // Position the hyperlink in 8th row and 2nd column and extend the hyperlink on 3 columns.
        worksheet.Cells[ "B8" ].Value = "Add an hyperlink to a cell reference in another worksheet:";
        worksheet.Hyperlinks.Add( "Sheet2!B1", 8, 1, 1, 3, "Link to another worksheet's cell.", "Another worksheet cell reference." );
    
        // Add an hyperlink to an external document.
        // Position the hyperlink in cell B12 and extend the hyperlink to cell D12.
        worksheet.Cells[ "B11" ].Value = "Add an hyperlink to an external document:";
        worksheet.Hyperlinks.Add( "../abc.xlsx", "B12", "D12", "Link to another document.", "An external document link." );
    
        // Add an hyperlink to an email address.
        // Position the hyperlink in cell B15 and extend the hyperlink for 2 rows and 2 columns.
        worksheet.Cells[ "B14" ].Value = "Add an hyperlink to an email address:";
        worksheet.Hyperlinks.Add( "sales@xceed.com", "B15", 2, 2, null, "An email link." );
    
        // Add an hyperlink to a web site.
        // Position the hyperlink in cell B18.
        worksheet.Cells[ "B17" ].Value = "Add an hyperlink to a web site:";
        worksheet.Hyperlinks.Add( "www.xceed.com", "B18", 1, 1, "Xceed", "A web site link." );
    
        // Save the workbook to disk.
        workbook.Save();
      }
    Inheritance Hierarchy

    System.Object
       Xceed.Workbooks.NET.WorkbookElement
          Xceed.Workbooks.NET.WorksheetElement
             Xceed.Workbooks.NET.HyperlinkCollection

    Public Properties
     NameDescription
    Public PropertyGets the number of Hyperlinks in the HyperlinkCollection.  
    Public PropertyGets a specific Hyperlink in the HyperlinkCollection.  
    Top
    Public Methods
     NameDescription
    Public MethodOverloaded. Adds a new Hyperlink in the Worksheet.  
    Public Method  
    Public MethodOverloaded. Removes a Hyperlink from the HyperlinkCollection.  
    Public MethodRemoves a Hyperlink from the HyperlinkCollection by using an index to locate it.  
    Top
    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also