你可以通过如下代码,设置超链接为一个表单内的区域。
例如:
工作表位置链接必须以“ sjs://”前缀开头,以下部分应为有效的工作表位置。
window.onload = initFunction;
function initFunction() {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 2});
var sheet = spread.getSheet(0);
var detailsSheet = spread.getSheet(1);
spread.suspendPaint();
sheet.fromJSON(locationSheet1JsonData);
detailsSheet.fromJSON(locationSheet2JsonData);
sheet.setHyperlink(0, 2, { url: "sjs://Sheet2!A1:G1"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(1, 2, { url: "sjs://Sheet2!A2:G2"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(2, 2, { url: "sjs://Sheet2!A3:G3"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(3, 2, { url: "sjs://Sheet2!A4:G4"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(4, 2, { url: "sjs://Sheet2!A5:G5"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(5, 2, { url: "sjs://Sheet2!A6:G6"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(6, 2, { url: "sjs://Sheet2!A7:G7"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(7, 2, { url: "sjs://Sheet2!A8:G8"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(8, 2, { url: "sjs://Sheet2!A9:G9"}, GC.Spread.Sheets.SheetArea.viewport);
sheet.setHyperlink(9, 2, { url: "sjs://Sheet2!A10:G10"}, GC.Spread.Sheets.SheetArea.viewport);
spread.resumePaint();
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta name="spreadjs culture" content="zh-cn" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css"
href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js"
type="text/javascript"></script>
<script
src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.js"
type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/data/hyperlink-data.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.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;
}