facebooktwittermenuarrow-up

GemBox Support Forum

Hyperlink, update real-time

I found a snippet of code to create a hyperlink. My question has to do with, how to set:
cell.Hyperlink.Location in real-time mode.

I will read a worksheet cell then do a search of the worksheet for a matching cell to create a hyperlink of new cell row and column.

The snippet of code shows that is uses “A2” (string) method.

How can I take result from: worksheet.Cells.FindText(searchText, false, false, out objectRow, out objectColumn);

To set the “cell.Hyperlink.Location” in a none (string) method?

Hi Herb,

So if I understood you correctly, you want to set the cell.Hyperlink.Location to point to the result of worksheet.Cells.FindText(searchText, false, false, out objectRow, out objectColumn);.
In that case, try this:

var workbook = new ExcelFile();
var worksheet = workbook.Worksheets.Add("Sheet1");

var cell = worksheet.Cells["A1"];
cell.Value = "Link Cell";

string searchText = "Search Cell";
worksheet.Cells["A2"].Value = searchText;

int objectRow, objectColumn;
worksheet.Cells.FindText(searchText, false, false, out objectRow, out objectColumn);

cell.Hyperlink.Location = CellRange.RowColumnToPosition(objectRow, objectColumn);
cell.Hyperlink.IsExternal = false;

workbook.Save("output.xlsx");

Does this solve your issue?

Regards,
Mario

Thank you works as you presented.