Class HyperlinkCollection

HyperlinkCollection class

Encapsulates a collection of Hyperlink objects.

public class HyperlinkCollection : CollectionBase<Hyperlink>

Properties

NameDescription
Capacity { get; set; }
Count { get; }
Item { get; }Gets the Hyperlink element at the specified index.
Item { get; set; }

Methods

NameDescription
Add(string, int, int, string)Adds a hyperlink to a specified cell or a range of cells.
Add(int, int, int, int, string)Adds a hyperlink to a specified cell or a range of cells.
Add(string, string, string, string, string)Adds a hyperlink to a specified cell or a range of cells.
BinarySearch(Hyperlink)
BinarySearch(Hyperlink, IComparer<Hyperlink>)
BinarySearch(int, int, Hyperlink, IComparer<Hyperlink>)
Clear()Clears all hyperlinks. (2 methods)
Contains(Hyperlink)
CopyTo(Hyperlink[])
CopyTo(Hyperlink[], int)
CopyTo(int, Hyperlink[], int, int)
Exists(Predicate<Hyperlink>)
Find(Predicate<Hyperlink>)
FindAll(Predicate<Hyperlink>)
FindIndex(Predicate<Hyperlink>)
FindIndex(int, Predicate<Hyperlink>)
FindIndex(int, int, Predicate<Hyperlink>)
FindLast(Predicate<Hyperlink>)
FindLastIndex(Predicate<Hyperlink>)
FindLastIndex(int, Predicate<Hyperlink>)
FindLastIndex(int, int, Predicate<Hyperlink>)
GetEnumerator()
IndexOf(Hyperlink)
IndexOf(Hyperlink, int)
IndexOf(Hyperlink, int, int)
LastIndexOf(Hyperlink)
LastIndexOf(Hyperlink, int)
LastIndexOf(Hyperlink, int, int)
RemoveAt(int)Remove the hyperlink at the specified index in this collection. (2 methods)

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using System;

    public class HyperlinkCollectionDemo
    {
        public static void HyperlinkCollectionExample()
        {
            // Instantiating a Workbook object
            Workbook workbook = new Workbook();

            // Obtaining the reference of the newly added worksheet by passing its sheet index
            Worksheet worksheet = workbook.Worksheets[0];

            // Get Hyperlinks Collection
            HyperlinkCollection hyperlinks = worksheet.Hyperlinks;

            // Adding a hyperlink to a URL at "A1" cell
            hyperlinks.Add("A1", 1, 1, "http://www.aspose.com");

            // Adding another hyperlink to a URL at "B1" cell
            hyperlinks.Add("B1", 1, 1, "http://www.example.com");

            // Adding a hyperlink with a range of cells
            hyperlinks.Add("C1", 1, 2, "http://www.test.com");

            // Adding a hyperlink with a specific text to display and screen tip
            hyperlinks.Add("D1", "D2", "http://www.display.com", "Click Here", "Go to Display");

            // Removing the first hyperlink
            hyperlinks.RemoveAt(0);

            // Clearing all hyperlinks
            hyperlinks.Clear();

            // Adding a hyperlink again to demonstrate saving
            hyperlinks.Add("A1", 1, 1, "http://www.aspose.com");

            // Saving the Excel file
            workbook.Save("HyperlinkCollectionExample.xlsx");
            workbook.Save("HyperlinkCollectionExample.pdf");
            return;
        }
    }
}

See Also