Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

Represents a hyperlink in an Area (which may contain only one cell) that points to an external URL.

Signature
C#
C#
 public sealed class Hyperlink
{signature}{signature:
}
Signature
vb.net
vb.net
Public NotInheritable Class Hyperlink
{signature}
{remarks}
To create a [Hyperlink|Hyperlink] object, call [Cell.CreateHyperlink|Cell.CreateHyperlink(String)] or [Area.CreateHyperlink|Area.CreateHyperlink(String)]. To get an existing {{Hyperlink}}, use [Worksheet.Hyperlinks].

A Hyperlink only represents a URL to an external resource such as a web site. To create a link to another location in the workbook, you will need to use Excel's Hyperlink formula. You will need to surround the destination cell in quotes and preface it with a pound sign. For example, a cell with formula =HYPERLINK("#DestinationWorksheet\!B3", "Link to B3") will contain the text "Link to B3", and if you click on that text it will bring you to cell B3 on the worksheet named DestinationWorksheet.
{remarks}
{example}{code:csharp|title=C#}
Remarks

To create a Hyperlink object, call Cell.CreateHyperlink or Area.CreateHyperlink. To get an existing Hyperlink, use Worksheet.Hyperlinks.

A Hyperlink only represents a URL to an external resource such as a web site. To create a link to another location in the workbook, you will need to use Excel's Hyperlink formula. You will need to surround the destination cell in quotes and preface it with a pound sign. For example, a cell with formula =HYPERLINK("#DestinationWorksheet!B3", "Link to B3") will contain the text "Link to B3", and if you click on that text it will bring you to cell B3 on the worksheet named DestinationWorksheet.

Example
Code Block
csharp
csharp
titleC#


          //--- Create a hyperlink
          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Create();
          Worksheet ws = wb.Worksheets[0];
          Cell cellA1 = ws.Cells["A1"];
          cellA1.Value = "SoftArtisans";
          Hyperlink link = cellA1.CreateHyperlink("http://www.softartisans.com");

          //--- Get an existing hyperlink
          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Open(@"C:\MySpreadsheet.xls");
          Worksheet ws = wb.Worksheets[0];
          Hyperlink firstLink = ws.Hyperlinks[0];

          //--- Create a link to another location within the workbook
          //--- (Note that this does NOT use the Hyperlink class)
          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Create();
          Worksheet ws = wb.Worksheets[0];
          ws.Cells["A1"].Formula = "=HYPERLINK(\"#DestinationSheet!B3\", \"Link to other sheet\")";
        
{code} {code:vbnet|title=
Code Block
vbnet
vbnet
titlevb.net
}


          '--- Create a hyperlink
          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Create()
          Dim ws As Worksheet = wb.Worksheets(0)
          Dim cellA1 As Cell = ws.Cells("A1")
          cellA1.Value = "SoftArtisans"
          Dim link As Hyperlink = cellA1.CreateHyperlink("http://www.softartisans.com")

          '--- Get an existing hyperlink
          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Create()
          Dim ws As Worksheet = wb.Worksheets(0)
          Hyperlink firstLink = ws.Hyperlinks(0)

          '--- Create a link to another location within the workbook
          '--- (Note that this does NOT use the Hyperlink class)
          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Create()
          Dim ws As Worksheet = wb.Worksheets(0)
          ws.Cells("A1").Formula = "=HYPERLINK(""#DestinationSheet!B3"", ""Link to other sheet"")"
        
{code} {example} {properties} || Name || Description || | [Area|Hyperlink.Area] | {excerpt-include:Hyperlink.Area|nopanel=true} | | [Href|Hyperlink.Href]\\ | {excerpt-include:Hyperlink.Href|nopanel=true} | | [Text|Hyperlink.Text]\\ | {excerpt-include:Hyperlink.Text|nopanel=true} |
Properties

Name

Description

Area

Excerpt Include
Hyperlink.Area
Hyperlink.Area
nopaneltrue

Href

Excerpt Include
Hyperlink.Href
Hyperlink.Href
nopaneltrue

Text

Excerpt Include
Hyperlink.Text
Hyperlink.Text
nopaneltrue