[]
        
(Showing Draft Content)

Hyperlink Cell

You can use a hyperlink cell to contain text that functions as a single hyperlink. The hyperlink cell type lets you set the color of the hyperlink as well as the color after the link has been accessed. You can also display text in the cell that is different from the hyperlink and set a tooltip to show when the mouse pointer hovers over the hyperlink.


When you click the link, it opens a new page and navigates to the link URL.




The following code sample creates a hyperlink cell type.

var cellType = new GC.Spread.Sheets.CellTypes.HyperLink();
cellType.linkColor("blue");
cellType.visitedLinkColor("#FF2235");
cellType.text("GrapeCity");
cellType.linkToolTip("Company Web Site");
activeSheet.getCell(1, 1).cellType(cellType).value("https://www.grapecity.com/spread");
activeSheet.getRange(1, -1, 1, -1).height(30);

Handle Callback Action

You can execute callback actions on a hyperlink cell using the onClickAction method in the HyperLink class.


The following code sample sets a callback action to the hyperlink where it will be executed when the hyperlink is clicked by a user. The action changes the sheet name to "Hyperlink" and the sheet tab color to red.

var h = new GC.Spread.Sheets.CellTypes.HyperLink();
sheet.setCellType(3, 2, h, GC.Spread.Sheets.SheetArea.viewport);
h.text('Spread.Sheets Site');
h.linkColor('blue');
// Set a callback action to the hyperlink
h.onClickAction(function () {
   var setSheetTabColor = {
      canUndo: true,
      execute: function (context, options, isUndo) {
      sheet.name('Hyperlink');
      sheet.options.sheetTabColor = 'red';
      }
   };
   var commandManager = spread.commandManager();
   var commandName = 'setSheetTabStyle';
   
// code to register this callback to the commandManager
   commandManager.register(commandName, setSheetTabColor, null, false, false, false, false);
   commandManager.execute({cmd: commandName});
});

You can also control whether the active cell should be moved to the hyperlink cell when the hyperlink is clicked by a user using the activeOnClick method in the HyperLink class.


The following code can be used to get and set whether to move to the active cell when the hyperlink is clicked.

h.activeOnClick(true);