Version

Adding a Hyperlink to a Worksheet (Infragistics Excel Engine)

Topic Overview

Purpose

This topic provides procedural instructions on how to add a hyperlink to a worksheet using the Infragistics Excel Engine.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

In this section you will find information that will help you to better understand the object model and the functionalities of the Infragistics Excel Engine.

In order to get you up and running as quickly as possible with the Infragistics Excel Engine, this topic provides procedural instructions on how to create a workbook.

In this topic

This topic contains the following sections:

Adding a Hyperlink to a Worksheet

Introduction

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.

Preview

The following screenshot is a preview of the result:

ExcelEngine 05.png

Prerequisites

To complete the procedure, you need the following:

An initialized workbook with at least one worksheet named "ws".

Overview

Following is a conceptual overview of the process:

  1. Create a WorksheetHyperlink

  2. Configure hyperlink’s source

  3. Configure hyperlink’s target

  4. Configure hyperlink’s display text (optional)

  5. Configure hyperlink’s tooltip (optional)

  6. Add the WorksheetHyperlink object to the worksheet’s Hyperlink collection

Steps

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)

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to add a predefined shape to a worksheet.

This topic explains how to add an image to a Worksheet.