[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

IHyperlinks

Interface IHyperlinks

All Superinterfaces:
Iterable<IHyperlink>

public interface IHyperlinks extends Iterable<IHyperlink>
表示工作表、区域或形状的超链接集合。

使用此接口管理附加到工作表、单元格、区域或形状的超链接。


 IHyperlinks hyperlinks = worksheet.getRange("A1:B2").getHyperlinks();
 hyperlinks.add(worksheet.getRange("A1"), "https://www.example.com/", null, "Open website", "Example");
 IHyperlink hyperlink = hyperlinks.get(0);
 
  • Method Details

    • get

      IHyperlink get(int index)
      按索引获取 IHyperlink。

      索引从 0 开始。

      
       IHyperlinks hyperlinks = worksheet.getHyperlinks();
       hyperlinks.add(worksheet.getRange("A1"), "https://www.example.com");
       IHyperlink hyperlink = hyperlinks.get(0);
       
      Parameters:
      index - 超链接的从 0 开始的索引。
      Returns:
      指定索引处的 IHyperlink;如果索引超出集合范围,则返回 null。
    • getCount

      int getCount()
      返回集合中的对象数量。

      对于 IHyperlinks 集合,此值指示工作表或区域中包含多少个IHyperlink 对象。

      
       IRange range = worksheet.getRange("A1:A2");
       range.getHyperlinks().add(worksheet.getRange("A1"), "https://www.example.com");
       int count = range.getHyperlinks().getCount();
       
      Returns:
      集合中 IHyperlink 对象的数量。
    • add

      IHyperlink add(IRange anchor, String address)
      向指定区域添加超链接( IHyperlink 对象)。

      使用此方法可以将超链接附加到指定的锚点区域。

      
       IHyperlinks hyperlinks = worksheet.getHyperlinks();
       worksheet.getRange("A1").setValue("Example");
       IHyperlink hyperlink = hyperlinks.add(worksheet.getRange("A1"), "https://www.example.com");
       
      Parameters:
      anchor - 作为超链接锚点的 IRange。不得为 null。
      address - 超链接地址。不得为 null。
      Returns:
      添加的 IHyperlink 对象。
    • add

      IHyperlink add(IRange anchor, String address, String subAddress, String screenTip, String textToDisplay)
      向指定区域添加超链接。
      
       IRange range = worksheet.getRange("A1:A2");
       IHyperlink hyperlink = range.getHyperlinks().add(
           worksheet.getRange("A1"),
           "https://www.example.com",
           null,
           "Open example",
           "Example");
       
      Parameters:
      anchor - 作为锚点的 IRange。
      address - 超链接地址。当 subAddress 指定目标时,此值可以为 null。
      subAddress - 目标文档内的位置。此值可以为 null。
      screenTip - 屏幕提示。此值可以为 null。
      textToDisplay - 显示文本。传入空字符串可使用默认显示文本。
      Returns:
      添加的 IHyperlink 对象。
    • add

      IHyperlink add(IShape shape, String address)
      向指定形状添加超链接( IHyperlink 对象)。

      使用此方法可以将超链接地址附加到工作表上的形状。

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Oval, 10, 10, 120, 60);
       shape.getTextFrame().getTextRange().add("Example");
       IHyperlink hyperlink = worksheet.getHyperlinks().add(shape, "https://www.example.com");
       
      Parameters:
      shape - 超链接的 IShape。
      address - 超链接的地址。
      Returns:
      创建的 IHyperlink 对象。
    • add

      IHyperlink add(IShape shape, String address, String subAddress, String screenTip, String textToDisplay)
      向指定形状添加超链接。
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Oval, 10, 10, 120, 40);
       IHyperlinks hyperlinks = worksheet.getHyperlinks();
       IHyperlink hyperlink = hyperlinks.add(
           shape, "https://www.example.com", null, "Open example", "Example");
       
      Parameters:
      shape - 超链接的形状。
      address - 超链接地址。当 subAddress 指定目标时,此值可以为 null。
      subAddress - 目标文档内的位置。此值可以为 null。
      screenTip - 屏幕提示。此值可以为 null。
      textToDisplay - 显示文本。传入空字符串可使用默认显示文本。
      Returns:
      添加的 IHyperlink 对象。
    • delete

      void delete()
      删除此集合中的超链接。

      当此集合属于工作表时,此方法会删除工作表中的所有超链接。当它属于区域时,此方法会删除该区域中的超链接。

      
       IRange range = worksheet.getRange("A1:A2");
       range.getHyperlinks().add(worksheet.getRange("A1"), "https://www.example.com", null, "Open example", "Example");
       range.getHyperlinks().delete();