Hyperlink Interface
A hyperlink contained in a cell or cell range.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Related API Members
The following members return Hyperlink objects:
Remarks
A Hyperlink object specifies a link associated with a cell or cell range that navigates to a certain location on the Internet, to a file, to a place in a workbook, or sends an email. Hyperlinks contained in a worksheet are stored in the Worksheet.Hyperlinks collection. The HyperlinkCollection.Add method creates, appends to the collection and returns a Hyperlink object that specifies a new hyperlink. An existing hyperlink can be accessed from the collection by its index. To get hyperlinks contained in the specified cell range, use the HyperlinkCollection.GetHyperlinks method. For an example on how to remove hyperlinks from cells, see the How to: Clear Cells of Content, Formatting, Hyperlinks and Comments document.
The Hyperlink object’s members allow you to change different hyperlink parameters. For example, you can specify the hyperlink destination (HyperlinkBase.Uri, Hyperlink.SetUri), the cell range where the hyperlink should be inserted (Hyperlink.Range), hyperlink text (Hyperlink.DisplayText) and tooltip text (HyperlinkBase.TooltipText).
You can also associate a hyperlink with a picture (Shape.InsertHyperlink). Such hyperlinks are represented by the ShapeHyperlink objects.
Example
This example demonstrates how to create a hyperlink to a web page or cell range in a workbook. To do this, use the HyperlinkCollection.Add method with the cell or cell range into which a hyperlink should be inserted, the target web page, or the workbook location passed along with other parameters.
Important
The maximum number of hyperlinks in a worksheet is 65,530.
All hyperlinks created in a worksheet are contained in the HyperlinkCollection collection returned by the Worksheet.Hyperlinks property. To adjust an existing hyperlink, use properties of the Hyperlink
object, which can be accessed by the hyperlink index from the HyperlinkCollection collection. To get all hyperlinks contained in the specified cell range, use the HyperlinkCollection.GetHyperlinks method.
To remove hyperlinks, use the HyperlinkCollection.Remove, HyperlinkCollection.RemoveAt or HyperlinkCollection.Clear method. The Worksheet.ClearHyperlinks method deletes all hyperlinks from the specified range of cells.
// Create a hyperlink to a web page.
Cell cell = worksheet.Cells["A1"];
worksheet.Hyperlinks.Add(cell, "https://www.devexpress.com/", true, "DevExpress");
// Create a hyperlink to a cell range in a workbook.
CellRange range = worksheet.Range["C3:D4"];
Hyperlink cellHyperlink = worksheet.Hyperlinks.Add(range, "Sheet2!B2:E7", false, "Select Range");
cellHyperlink.TooltipText = "Click Me";