Excel.RangeHyperlink interface

Represents the necessary strings to get/set a hyperlink (XHL) object.

[ API set: ExcelApi 1.7 ]

Properties

address

Represents the url target for the hyperlink.

[ API set: ExcelApi 1.7 ]

documentReference

Represents the document reference target for the hyperlink.

[ API set: ExcelApi 1.7 ]

screenTip

Represents the string displayed when hovering over the hyperlink.

[ API set: ExcelApi 1.7 ]

textToDisplay

Represents the string that is displayed in the top left most cell in the range.

[ API set: ExcelApi 1.7 ]

Property Details

address

Represents the url target for the hyperlink.

[ API set: ExcelApi 1.7 ]

address?: string;

Property Value

string

Examples

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();
});

documentReference

Represents the document reference target for the hyperlink.

[ API set: ExcelApi 1.7 ]

documentReference?: string;

Property Value

string

Examples

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();
});

screenTip

Represents the string displayed when hovering over the hyperlink.

[ API set: ExcelApi 1.7 ]

screenTip?: string;

Property Value

string

Examples

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();
});

textToDisplay

Represents the string that is displayed in the top left most cell in the range.

[ API set: ExcelApi 1.7 ]

textToDisplay?: string;

Property Value

string

Examples

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();
});