This topic provides procedural instructions on how to add a hyperlink to a worksheet using the Infragistics Excel Engine.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
This procedure demonstrates how to add a hyperlink to a worksheet. Hyperlinks are represented by the WorksheetHyperlink class and are added in the worksheet’s Hyperlinks collection.
The following screenshot is a preview of the result:
To complete the procedure, you need the following:
An initialized workbook with at least one worksheet named "ws".
Following is a conceptual overview of the process:
Create a WorksheetHyperlink
Configure hyperlink’s source
Configure hyperlink’s target
Configure hyperlink’s display text (optional)
Configure hyperlink’s tooltip (optional)
Add the WorksheetHyperlink object to the worksheet’s Hyperlink collection
The following steps demonstrate how to add a hyperlink to a worksheet.
Create a WorksheetHyperlink
object and provide the required arguments. The next steps provide more information about the arguments.
The WorksheetHyperlink
's source is the location occupied by the hyperlink. It can be a single cell or multiple cells. You can provide the source as string: "B2", "B2:C5" or by providing a WorksheetCell or WorksheetRegion.
The WorksheetHyperlink
's target can be one of the following: WorksheetCell
, WorksheetRegion
, NamedReference or a string value. The string type value allows you to specify targets like e-mail addresses, internet addresses and worksheet’s cells and named references. See the Target property description for more information.
The WorksheetHyperlink
's display text is the text that will be displayed in the worksheet cell. If you do not specify this optional argument the target text will be shown.
The WorksheetHyperlink
's tooltip will be shown when hovering over the source cell or region. This is an optional argument.
To make the hyperlink visible add it to the Hyperlinks collection of the respective Worksheet
.
Following is the code that implements this example:
In C#:
WorksheetHyperlink link = new WorksheetHyperlink(
"B2",
"http://www.infragistics.com",
"Infragistics",
"Visit the Infragistics website");
this.ws.Hyperlinks.Add(link);
In Visual Basic:
Dim link As New WorksheetHyperlink( _
"B2", _
"http://www.infragistics.com", _
"Infragistics", _
"Visit the Infragistics website")
Me.ws.Hyperlinks.Add(link)
The following topics provide additional information related to this topic.