HyperlinkBase.Uri Property
Returns the hyperlink destination.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Property Value
Type | Description |
---|---|
String | A String value that specifies the destination to which a hyperlink refers. |
Remarks
When an end-user clicks a cell range, the associated hyperlink navigates to the location returned by the Uri property. Pass the hyperlink destination to the HyperlinkCollection.Add method as a parameter when adding a hyperlink to a cell range, or change it using the Hyperlink.SetUri method. To create a hyperlink for a picture, use the Shape.InsertHyperlink method with the passed hyperlink destination. To change the location to which the hyperlink associated with the shape refers, use the HyperlinkBase.SetUri method of the ShapeHyperlink object.
The following table lists possible locations to which hyperlinks can refer. A hyperlink can be external or internal depending on its target location.
Hyperlink Destination | Description | Hyperlink Type | Example |
---|---|---|---|
Web Page | A hyperlink opens the specified web page in the default browser. | External | “https://www.devexpress.com/“ |
Existing File or Directory | A hyperlink opens a file or directory. Uri is a path to a file and file name, or a path to a directory. A path can be absolute or relative to the directory where the current workbook is located. | External | “C:\Temp\MyDocument.xlsx” “..\..\..\MyBook.xlsx” “D:\“ |
E-Mail Address | A hyperlink opens the default mail client for the specified e-mail address. Uri is an e-mail address preceded by the “mailto:” prefix. | External | “mailto:support@devexpress.com” |
Cell Range | A hyperlink refers to a cell or cell range within the current workbook. Uri is a cell reference or defined name preceded by the worksheet name. | Internal | “Sheet2!A1:C3” “Sheet2!range_name” |
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";