Back to Devexpress

How to: Add a Hyperlink to a Picture

officefileapi-120747-spreadsheet-document-api-examples-pictures-how-to-add-a-hyperlink-to-a-picture.md

latest1.9 KB
Original Source

How to: Add a Hyperlink to a Picture

  • Feb 12, 2025

This example describes how to associate a hyperlink with a picture using the following API.

MemberDescription
PictureCollection.AddPictureInserts a picture from a file or a SpreadsheetImageSource object to fit in the specified range.
Shape.InsertHyperlinkCreates a new ShapeHyperlink object with the passed hyperlink destination. The hyperlink can refer to a web page, existing file or directory, e-mail address or cell range.
HyperlinkBase.TooltipTextSpecifies the hyperlink’s tooltip.This text is displayed when the cursor hovers over the picture.

The following code snippet inserts a picture and attaches a hyperlink to it:

csharp
Workbook workbook = new Workbook();
Picture picture = workbook.Worksheets[0].Pictures.AddPicture("DevExpress.png", workbook.Worksheets[0].Cells["A1"]);
ShapeHyperlink shapeHyperlink = picture.InsertHyperlink("https://community.devexpress.com/blogs/", true);
shapeHyperlink.TooltipText = "Check the recent DevExpress blogs";
vb
Dim workbook As Workbook = New Workbook()
Dim picture As Picture = workbook.Worksheets(0).Pictures.AddPicture("DevExpress.png", workbook.Worksheets(0).Cells("A1"))
Dim shapeHyperlink As ShapeHyperlink = picture.InsertHyperlink("https://community.devexpress.com/blogs/", True)
shapeHyperlink.TooltipText = "Check the recent DevExpress blogs"