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

ICommentThreaded

Interface ICommentThreaded


public interface ICommentThreaded
表示单元格的线程式批注。此对象可以表示顶级线程式批注或其回复。

使用此接口可以读取或修改线程式批注内容,在父线程式批注和回复线程式批注之间导航,并处理与顶级线程式批注关联的回复。线程式批注通常通过对单元格调用 IRange.addCommentThreaded(String,String) 创建,也可以从工作表的 ICommentsThreaded 集合访问。


 ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Review this value", "Alex");
 ICommentThreaded reply = comment.addReply("I updated the number.", "Jamie");
 ICommentThreaded parent = reply.getParent();
 ICommentsThreaded replies = comment.getReplies();
 
  • Method Details

    • addReply

      ICommentThreaded addReply(String text)
      向此线程式批注添加回复。

      如果此线程式批注是顶级线程式批注,则将回复添加到此线程式批注的回复集合。如果此线程式批注是回复,则将新回复添加到父线程式批注的回复集合。

      此重载使用空作者字符串转发到 addReply(String,String)。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       ICommentThreaded reply = comment.addReply("I updated the total.");
       String replyText = reply.getText();
       
      Parameters:
      text - 回复的内容。不得为 null。如果此值为空或仅包含空白字符,则不会添加回复,并返回 null。
      Returns:
      新添加的回复。如果 text 为空或仅包含空白字符,则返回 null。
      Throws:
      IllegalStateException - 如果此线程式批注已解决,或此线程式批注是回复且其父线程式批注已解决,导致无法回复。
      NullPointerException - 如果 text 为 null。
    • addReply

      ICommentThreaded addReply(String text, String author)
      向此线程式批注添加回复。

      如果此线程式批注是顶级线程式批注,则将回复添加到此线程式批注的回复集合。如果此线程式批注本身是回复,则将新回复添加到父线程式批注的回复集合。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Review this value", "Alex");
       ICommentThreaded reply = comment.addReply("I updated the number.", "Jamie");
       String replyText = reply.getText();
       
      Parameters:
      text - 回复的内容。不得为 null。如果此值为空或仅包含空白字符,则不会添加回复,并返回 null。
      author - 回复的作者。
      Returns:
      新添加的回复。如果 text 为空或仅包含空白字符,则返回 null。
      Throws:
      IllegalStateException - 如果此线程式批注已解决,或此线程式批注是回复且其父线程式批注已解决,导致无法回复。
      NullPointerException - 如果 text 为 null。
    • delete

      void delete()
      删除指定的线程式批注以及与该线程式批注关联的所有回复。

      如果此线程式批注是回复,则只从父线程式批注的回复列表中删除它自身。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Review this value", "Alex");
       comment.addReply("I updated the number.", "Jamie");
       comment.delete();
       
    • setIsResolved

      void setIsResolved(boolean value)
      设置一个值,指示线程式批注是否已解决。
      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       comment.setIsResolved(true);
       
      Parameters:
      value - 如果线程式批注已解决,则为 true;否则为 false。
    • getIsResolved

      boolean getIsResolved()
      获取一个值,该值指示线程式批注是否已解决。

      已解决的线程式批注无法编辑或回复。使用 setIsResolved(boolean) 可以更改解决状态。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       comment.setIsResolved(true);
       boolean resolved = comment.getIsResolved();
       
      Returns:
      如果线程式批注已解决,则为 true;否则为 false。
    • getText

      String getText()
      获取线程式批注的文本。

      返回此线程式批注的文本内容,无论它是顶级线程式批注还是回复。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       String text = comment.getText();
       
      Returns:
      线程式批注的文本;如果未设置文本,则为 null。
    • setText

      void setText(String text)
      设置线程式批注的文本。

      设置此线程式批注的文本内容,无论它是顶级线程式批注还是回复。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       comment.setText("The total has been reviewed.");
       
      Parameters:
      text - 线程式批注的文本;可以为 null。
    • getReplies

      ICommentsThreaded getReplies()
      获取此线程式批注的回复。

      返回包含回复此线程式批注的 ICommentThreaded 对象的 ICommentsThreaded 集合。回复按时间戳排序。如果此线程式批注本身是回复,则此方法返回 null。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       comment.addReply("I updated the total.", "Jamie");
       comment.addReply("I verified the formula.", "Morgan");
       ICommentsThreaded replies = comment.getReplies();
       ICommentThreaded firstReply = replies.get(0);
       
      Returns:
      此线程式批注的回复集合,按时间戳排序。如果此线程式批注是回复,则返回 null。
    • getAuthor

      IAuthor getAuthor()
      获取线程式批注的作者对象。

      使用返回的 IAuthor 对象可以读取或更新与此线程式批注关联的作者名称。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Review this value", "Alex");
       IAuthor author = comment.getAuthor();
       String name = author.getName();
       
      Returns:
      与线程式批注关联的 IAuthor 对象。
    • getDate

      @Deprecated Date getDate()
      Deprecated.
      请改用 getLocalDateTime()。
      获取以本地时间添加线程式批注的日期和时间。

      此方法已过时。请改用 getLocalDateTime()。

      Returns:
      表示以本地时间添加线程式批注的日期和时间的 Date 对象。
    • getLocalDateTime

      LocalDateTime getLocalDateTime()
      获取以本地时间添加线程式批注的日期和时间。

      返回线程式批注在本地时区中的 LocalDateTime 值。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Review this value", "Alex");
       LocalDateTime localDateTime = comment.getLocalDateTime();
       
      Returns:
      表示以本地时间添加线程式批注的日期和时间的 LocalDateTime 值。如果线程式批注没有日期和时间值,则返回 null。
    • next

      返回表示下一个线程式批注的 ICommentThreaded 对象。

      对于顶级线程式批注,此方法返回工作表上的下一个线程式批注。对于回复线程式批注,此方法返回父线程式批注的回复集合中的下一个回复。

      
       ICommentThreaded first = worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       worksheet.getRange("A2").addCommentThreaded("Check the discount.", "Jamie");
       ICommentThreaded nextComment = first.next();
       String nextText = nextComment.getText();
       
      Returns:
      下一个 ICommentThreaded 对象。如果顶级线程式批注是工作表上的最后一个线程式批注,或回复线程式批注是线程式批注的回复中的最后一个回复,则返回 null。
    • previous

      ICommentThreaded previous()
      返回表示上一个线程式批注的 ICommentThreaded 对象。

      对于顶级线程式批注,此方法返回工作表上的上一个线程式批注。对于回复线程式批注,此方法返回父线程式批注的回复集合中的上一个回复。

      
       worksheet.getRange("A1").addCommentThreaded("Please review the total.", "Alex");
       ICommentThreaded comment = worksheet.getRange("A2").addCommentThreaded("Check the discount.", "Jamie");
       ICommentThreaded previousComment = comment.previous();
       String previousText = previousComment.getText();
       
      Returns:
      上一个 ICommentThreaded 对象。如果顶级线程式批注是工作表上的第一个线程式批注,或回复线程式批注是线程式批注的回复中的第一个回复,则返回 null。
    • getParent

      ICommentThreaded getParent()
      获取指定线程式批注的父对象。

      顶级线程式批注的父对象为 null。对于回复,此方法返回该回复所属的线程式批注。

      
       ICommentThreaded comment = worksheet.getRange("A1").addCommentThreaded("Review this value", "Alex");
       ICommentThreaded reply = comment.addReply("I updated the number.", "Jamie");
       ICommentThreaded parent = reply.getParent();
       
      Returns:
      父线程式批注。如果这是顶级线程式批注,则返回 null。