[]
        
(Showing Draft Content)

IHyperlink

Interface IHyperlink


public interface IHyperlink
Represents a hyperlink.

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");
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes the hyperlink.
    Gets the address of the target document.
    Gets the subject of the specified e-mail hyperlink.
    Returns the name of the hyperlink.
    Returns the IRange object that represents the range the specified hyperlink is attached to.
    Gets the ScreenTip text for the specified hyperlink.
    Returns the IShape object that represents the shape attached to the specified hyperlink.
    Gets the location within the document associated with the hyperlink.
    Gets the text to be displayed for the specified hyperlink.
    void
    Sets the address of the target document.
    void
    Sets the subject of the specified e-mail hyperlink.
    void
    Sets the ScreenTip text for the specified hyperlink.
    void
    Sets the location within the document associated with the hyperlink.
    void
    Sets the text to be displayed for the specified hyperlink.
  • Method Details

    • getName

      String getName()
      Returns the name of the hyperlink.
      
       IRange cell = worksheet.getRange("A1");
       IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
       String name = hyperlink.getName();
       
      Returns:
      The name of the hyperlink.
    • getRange

      IRange getRange()
      Returns the 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();
       
      Returns:
      The IRange object that represents the range the specified hyperlink is attached to, or null if the hyperlink is attached to a shape.
    • getShape

      IShape getShape()
      Returns the 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();
       
      Returns:
      The IShape object that represents the shape attached to the hyperlink, or null if the hyperlink is attached to a range.
    • getAddress

      String getAddress()
      Gets the address of the target 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 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();
       
      Returns:
      The address of the target document, or null if the hyperlink points to a location in the current document.
    • setAddress

      void setAddress(String value)
      Sets the address of the target 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");
       
      Parameters:
      value - The address of the target document, or null if the hyperlink points to a location in the current document.
    • getEmailSubject

      String getEmailSubject()
      Gets the subject of the specified e-mail hyperlink.

      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();
       
      Returns:
      The subject of the e-mail hyperlink.
    • setEmailSubject

      void setEmailSubject(String value)
      Sets the subject of the specified e-mail hyperlink.

      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");
       
      Parameters:
      value - The URI-encoded subject of the e-mail hyperlink.
    • getScreenTip

      String getScreenTip()
      Gets the ScreenTip text for the specified 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();
       
      Returns:
      The ScreenTip text for the specified hyperlink.
    • setScreenTip

      void setScreenTip(String value)
      Sets the ScreenTip text for the specified 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");
       hyperlink.setScreenTip("Open the Mescius website");
       
      Parameters:
      value - The ScreenTip text for the specified hyperlink.
    • getSubAddress

      String getSubAddress()
      Gets the location within the document associated with the 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();
       
      Returns:
      The location within the document associated with the hyperlink, or null if no document-internal location is set.
    • setSubAddress

      void setSubAddress(String value)
      Sets the location within the document associated with the 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");
       hyperlink.setSubAddress("Sheet1!$A$1");
       
      Parameters:
      value - The location within the document associated with the hyperlink, or null if no document-internal location is set.
    • getTextToDisplay

      String getTextToDisplay()
      Gets the text to be displayed for the specified hyperlink. The default value is the address of the hyperlink.
      
       IRange cell = worksheet.getRange("A1");
       IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
       hyperlink.setTextToDisplay("Example");
       String textToDisplay = hyperlink.getTextToDisplay();
       
      Returns:
      The text displayed for the hyperlink. By default, this is the address of the hyperlink.
    • setTextToDisplay

      void setTextToDisplay(String value)
      Sets the text to be displayed for the specified hyperlink. The default value is the address of the hyperlink.
      
       IRange cell = worksheet.getRange("A1");
       IHyperlink hyperlink = cell.getHyperlinks().add(cell, "https://www.example.com");
       hyperlink.setTextToDisplay("Visit example");
       
      Parameters:
      value - The text displayed for the hyperlink. By default, this is the address of the hyperlink.
    • delete

      void delete()
      Deletes 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();