Adding Hyperlink to Image(Picture)

Hello,
I would like to add Hyperlink to a picture object? How to do this.

There is no way to specifiy Picture object when adding Hyperlink. All I can specifiy
is only row number and column number.

I am aligning this picture with a Cell. I tried to add Hyperlink to that cell.
But Hyperlink is not working.

Thanks,
Raj

Please try the following sample code:

Worksheet worksheet = excel.Worksheets[0];
worksheet.Hyperlinks.AddInternalLink("A1", 1, 1, "Sheet2!B2");

A1 is the cell which contains the hyperlink. B2 of Sheet2 is the cell which contains the picture.

Hi Laurence,
Thanks for your reply.

I think you have misunderstood my question. I don’t want to give a hyperlink
to the image in the worksheet, instead I want to add a hyperlink to the Image object, so that when user clicks the image object, the link has to be opened( just like adding hyperlink in the Cell) in the browser.

Right now I have placed this image over a cell and I have added hyperlink
object to that cell. But when user moves mouse over this image “Cross Hair” is displayed rather Hyperlink symbol. But in MS Excel, I can right click on the Image object and add hyperlink to it. I don’t see any corresponding API in your library
to do the same.

Thanks,
Raj

Hi Raj,

Currently a hyperlink on an image object is not supported yet. I will check this feature.

@raju_krishnappa,
Aspose.Cells has replaced Aspose.Excel that is discontinued and no more actively developed. This new product supports all the latest features in different versions of MS Excel. You can work with text hyperlinks as well as image hyperlinks. Here is an example that demonstrates the image hyperlink feature.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
string dataDir = "";

// Instantiate a new workbook
Workbook workbook = new Workbook();

// Get the first worksheet
Worksheet worksheet = workbook.Worksheets[0];

// Insert a string value to a cell
worksheet.Cells["C2"].PutValue("Image Hyperlink");

// Set the 4th row height
worksheet.Cells.SetRowHeight(3, 100);

// Set the C column width
worksheet.Cells.SetColumnWidth(2, 21);

// Add a picture to the C4 cell
int index = worksheet.Pictures.Add(3, 2, 4, 3, dataDir + "AsposeIcon.png");

// Get the picture object
Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[index];

// Set the placement type
pic.Placement = PlacementType.FreeFloating;

// Add an image hyperlink
Aspose.Cells.Hyperlink hlink = pic.AddHyperlink("http://www.aspose.com/");

// Specify the screen tip
hlink.ScreenTip = "Click to go to Aspose site";
dataDir = dataDir + "ImageHyperlink.out.xlsx";
// Save the Excel file
workbook.Save(dataDir);

For more details about working with image hyperlinks refer to the following article:
Add Image Hyperlinks

Give a try to this new product by downloading the latest free trial version here:
Aspose.Cells for .NET(Latest version)

A runnable solution is available here that can be used to test the new product without writing any code.