Is it possible to call an Office Addin's function when clicking on an Excel cell hyperlink? I checked the documentation, but couldn't find a way.
Anyone had a smart insight making hyperlink events work?
Thanks!
Scenario 1
I'd like to create a nice user experience where my App loads a table having a column with hyperlink cells in each rows with text Details
. Whe the user clicks on this hyperlink, the task pane show additional details for the clicked row - by calling a JS function.
Scenario 2
I'd like to create a navigation experience inside the worksheet, not in the App Pane. This could be accomplished with native hyperlinks, but in my case, I would need to pull additional data from a database and change the view of the App Pane - by calling a JS function.
Scenario 3
I'd like to display a popup when clicking on a hyperlink button inside a worksheet. I would just set a nice formatting to a hyperlink so it would look like a button and the call displayDialogAsync
.
Scenario 4
A given table is showing only the first 20 records from a query. By clicking in Next
or Previous
hyperlinks in the spreadsheet, the data updates with the paginated query.
I'll answer my question because I found a satisfactory workaround.
When creating an hyperlink, set the address
property to #
. This will create a hyperlink that has no action when clicked.
Then, register the event onSingleClicked
to know in which cell the user clicked on the worksheet. I suggest you to get the sample in ScriptLab to know how to register and use the event.
With that, you'll have a nice experience of clicking on hyperlilnks and assigning actions to them. The only drawback is if the user clicks the cell's background where the hyperlink is, the event will also fire, but that's good, just make a narrow space between hyperlink's content its cell's background.