Excel.RangeHyperlink interface
Represents the necessary strings to get/set a hyperlink (XHL) object.
address | Represents the URL target for the hyperlink. |
document |
Represents the document reference target for the hyperlink. |
screen |
Represents the string displayed when hovering over the hyperlink. |
text |
Represents the string that is displayed in the top left most cell in the range. |
Represents the URL target for the hyperlink.
address?: string;
Property Value
string
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Orders");
let productsRange = sheet.getRange("A3:A5");
productsRange.load("values");
await context.sync();
// Create a hyperlink to a URL
// for each product name in the first table.
for (let i = 0; i < productsRange.values.length; i++) {
let cellRange = productsRange.getCell(i, 0);
let cellText = productsRange.values[i][0];
let hyperlink = {
textToDisplay: cellText,
screenTip: "Search Bing for '" + cellText + "'",
address: "https://www.bing.com?q=" + cellText
}
cellRange.hyperlink = hyperlink;
}
await context.sync();
});
Represents the document reference target for the hyperlink.
documentReference?: string;
Property Value
string
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Orders");
let productsRange = sheet.getRange("A9:A11");
productsRange.load("values");
await context.sync();
// Create a hyperlink to a location within the workbook
// for each product name in the second table.
for (let i = 0; i < productsRange.values.length; i++) {
let cellRange = productsRange.getCell(i, 0);
let cellText = productsRange.values[i][0];
let hyperlink = {
textToDisplay: cellText,
screenTip: "Navigate to the '" + cellText + "' worksheet",
documentReference: cellText + "!A1"
}
cellRange.hyperlink = hyperlink;
}
await context.sync();
});
Represents the string displayed when hovering over the hyperlink.
screenTip?: string;
Property Value
string
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Orders");
let productsRange = sheet.getRange("A3:A5");
productsRange.load("values");
await context.sync();
// Create a hyperlink to a URL
// for each product name in the first table.
for (let i = 0; i < productsRange.values.length; i++) {
let cellRange = productsRange.getCell(i, 0);
let cellText = productsRange.values[i][0];
let hyperlink = {
textToDisplay: cellText,
screenTip: "Search Bing for '" + cellText + "'",
address: "https://www.bing.com?q=" + cellText
}
cellRange.hyperlink = hyperlink;
}
await context.sync();
});
Represents the string that is displayed in the top left most cell in the range.
textToDisplay?: string;
Property Value
string
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/range-hyperlink.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Orders");
let productsRange = sheet.getRange("A3:A5");
productsRange.load("values");
await context.sync();
// Create a hyperlink to a URL
// for each product name in the first table.
for (let i = 0; i < productsRange.values.length; i++) {
let cellRange = productsRange.getCell(i, 0);
let cellText = productsRange.values[i][0];
let hyperlink = {
textToDisplay: cellText,
screenTip: "Search Bing for '" + cellText + "'",
address: "https://www.bing.com?q=" + cellText
}
cellRange.hyperlink = hyperlink;
}
await context.sync();
});
Office Add-ins feedback
Office Add-ins is an open source project. Select a link to provide feedback: