ExcelScript.RangeHyperlink interface
表示获取/设置 XHL) 对象 (超链接所需的字符串。
注解
示例
/**
* This script puts a link to a webpage in a cell.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first cell in the current worksheet.
const cell = workbook.getActiveWorksheet().getCell(0,0);
// Create a link to a webpage.
const sampleHyperlink : ExcelScript.RangeHyperlink = {
address: "https://learn.microsoft.com/office/dev/scripts/resources/samples/table-of-contents",
screenTip: "Sample: Create a workbook table of contents",
textToDisplay: "Learn how to make a workbook table of contents"
}
// Put the link in the cell and format the width to fit.
cell.setHyperlink(sampleHyperlink);
cell.getFormat().autofitColumns();
}
属性
address | 表示超链接的 URL 目标。 |
document |
表示超链接的文档引用目标。 |
screen |
表示鼠标悬停在超链接上时显示的字符串。 |
text |
表示区域最左上方单元格中显示的字符串。 |
属性详细信息
address
表示超链接的 URL 目标。
address?: string;
属性值
string
documentReference
表示超链接的文档引用目标。
documentReference?: string;
属性值
string
示例
/**
* This script creates a hyperlink in the current cell to a table.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the selected cell.
const selectedCell = workbook.getActiveCell();
// Create a hyperlink from the current cell to a table named "Resources".
const link : ExcelScript.RangeHyperlink = {
documentReference: "Resources",
screenTip: "Resources table",
textToDisplay: "Go to table"
} ;
selectedCell.setHyperlink(link)
}
screenTip
表示鼠标悬停在超链接上时显示的字符串。
screenTip?: string;
属性值
string
textToDisplay
表示区域最左上方单元格中显示的字符串。
textToDisplay?: string;
属性值
string