HYPERLINK Function

This sample shows how to use the built-in 'HYPERLINK' formula in SpreadJS to set hyperlinks within cells in the workbook.

<p>You can use <code>HYPERLINK</code> formula to set a hyperlink.</p> <p>For example:</p> <pre><code class="hljs javascript language-javascript"> sheet.setValue(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-string">"www.google.com"</span>) sheet.setValue(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-string">"Google"</span>) sheet.setFormula(<span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-string">"=HYPERLINK(A1, B1"</span>); </code></pre> <p>The second parameter is optional and it represent the friendly name.</p>
window.onload = initFunction; function initFunction() { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 1}); var sheet = spread.getActiveSheet(); spread.suspendPaint(); sheet.fromJSON(formulaJsonData); sheet.setFormula(0, 2, "=HYPERLINK(B1, A1"); sheet.setFormula(1, 2, "=HYPERLINK(B2, A2"); sheet.setFormula(2, 2, "=HYPERLINK(B3, A3"); sheet.setFormula(3, 2, "=HYPERLINK(B4, A4"); sheet.setFormula(4, 2, "=HYPERLINK(B5, A5"); sheet.setFormula(5, 2, "=HYPERLINK(B6, A6"); sheet.setFormula(6, 2, "=HYPERLINK(B7, A7"); sheet.setFormula(7, 2, "=HYPERLINK(B8, A8"); sheet.setFormula(8, 2, "=HYPERLINK(B9, A9"); sheet.setFormula(9, 2, "=HYPERLINK(B10, A10"); spread.resumePaint(); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/purejs/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/en/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/data/hyperlink-data.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div id="ss" class="sample-spreadsheets"></div> </div></body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: 100%; height: 100%; overflow: hidden; float: left; } .options-container { float: right; padding: 12px; height: 100%; width: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } .option-row { font-size: 14px; padding: 5px; } input { display:block; width: 100%; margin: 8px 0; box-sizing: border-box; } label, input { padding: 4px 6px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #drawUnderline { display: inline-block; width: 30px; } #drawUnderlineLabel { display: inline-block; } #allowAutoCreateHyperlink { display: inline-block; width: 30px; }