[]
An IHyperlink stores the link target and related display information for a hyperlink attached to a worksheet range or a shape. Use this interface to inspect or modify the hyperlink address, subaddress, screen tip, email subject, and display text.
IHyperlink hyperlink = worksheet.getHyperlinks().add(
worksheet.getRange("A1"),
"https://www.example.com",
null,
"Open the example website",
"Example");
hyperlink.setTextToDisplay("Visit example");
voiddelete()getName()getRange()IRange object that represents the range the specified hyperlink is attached to.getShape()IShape object that represents the shape attached to the specified hyperlink.voidsetAddress(String value) voidsetEmailSubject(String value) voidsetScreenTip(String value) voidsetSubAddress(String value) voidsetTextToDisplay(String value)
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
String name = hyperlink.getName();
IRange object that represents the range the specified hyperlink is attached to.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
IRange range = hyperlink.getRange();
IRange object that represents the range the specified hyperlink is attached to, or null if the hyperlink is attached to a shape.IShape object that represents the shape attached to the specified hyperlink.Use this method to access the shape anchor when the hyperlink is attached to a drawing object instead of a cell range.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 10, 10, 120, 60);
shape.getTextFrame().getTextRange().add("Example");
IHyperlink hyperlink = worksheet.getHyperlinks().add(shape, "https://www.example.com");
IShape attachedShape = hyperlink.getShape();
IShape object that represents the shape attached to the hyperlink, or null if the hyperlink is attached to a range.The address identifies the hyperlink target, such as a webpage, an external file, or an e-mail address. For hyperlinks that refer only to a location in the current document, use getSubAddress(), and this method returns null.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
String address = hyperlink.getAddress();
null if the hyperlink points to a location in the current document.The address identifies the hyperlink target, such as a webpage, an external file, or an e-mail address. For hyperlinks that refer only to a location in the current document, use setSubAddress(String), and set this value to null.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
hyperlink.setAddress("https://www.mescius.com");
value - The address of the target document, or null if the hyperlink points to a location in the current document.Use this method to retrieve the subject configured by setEmailSubject(String) for a mail hyperlink.
If the subject contains spaces or reserved URI characters, encode it as a URI component before assigning it to the hyperlink.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "mailto:us.sales@mescius.com");
hyperlink.setEmailSubject("Product%20Inquiry");
String subject = hyperlink.getEmailSubject();
Use this method to assign the subject for a mail hyperlink.
If the subject contains spaces or reserved URI characters, encode it as a URI component before calling this method.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "mailto:us.sales@mescius.com");
hyperlink.setEmailSubject("Product%20Inquiry");
value - The URI-encoded subject of the e-mail hyperlink.The ScreenTip is the text displayed when the pointer rests on the hyperlink.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com", null, "Open example website", "Example");
String screenTip = hyperlink.getScreenTip();
The ScreenTip is the text displayed when the pointer rests on the hyperlink.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com", null, "Open example website", "Example");
hyperlink.setScreenTip("Open the Mescius website");
value - The ScreenTip text for the specified hyperlink.This value identifies the document-internal target of the hyperlink, such as a worksheet range reference.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, null, "Sheet1!$C$3:$E$4", "Go to details", "Details");
String subAddress = hyperlink.getSubAddress();
null if no document-internal location is set.This value identifies the document-internal target of the hyperlink, such as a worksheet range reference.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, null, "Sheet1!$C$3:$E$4", "Go to details", "Details");
hyperlink.setSubAddress("Sheet1!$A$1");
value - The location within the document associated with the hyperlink, or null if no document-internal location is set.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
hyperlink.setTextToDisplay("Example");
String textToDisplay = hyperlink.getTextToDisplay();
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
hyperlink.setTextToDisplay("Visit example");
value - The text displayed for the hyperlink. By default, this is the address of the hyperlink.Use this method to remove a hyperlink that was added to a cell range or shape.
IRange cell = worksheet.getRange("A1");
IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
hyperlink.delete();