[]
        
(Showing Draft Content)

IComment

Interface IComment


public interface IComment
Represents a cell comment.

An IComment is attached to a worksheet cell and provides access to the comment content, author, anchor cell, visibility, and the underlying shape used to display the comment.


 IComment comment = worksheet.getRange("B2").addComment("Review this value.");
 String text = comment.getText();
 IRange anchorCell = comment.getAnchorCell();
 comment.setVisible(true);
 
  • Method Details

    • getText

      String getText()
      Gets the comment text.
      
       worksheet.getRange("D5").setValue("Review");
       IComment comment = worksheet.getRange("D5").addComment("Check this value.");
       String text = comment.getText();
       
      Returns:
      The comment text.
    • setText

      void setText(String value)
      Sets the comment text.
      
       worksheet.getRange("D5").setValue("Review");
       IComment comment = worksheet.getRange("D5").addComment("Check this value.");
       comment.setText("Reviewed and approved.");
       
      Parameters:
      value - The comment text.
    • getAuthor

      String getAuthor()
      Gets the author of the comment.

      Returns the author information associated with the comment.

      
       workbook.setAuthor("Author");
       IComment comment = worksheet.getRange("C3").addComment("Review this value.");
       String author = comment.getAuthor();
       
      Returns:
      The author of the comment.
    • getAnchorCell

      IRange getAnchorCell()
      Gets the anchor cell of the comment.

      Returns the IRange that the comment is attached to.

      
       worksheet.getRange("D5").setValue("Review");
       IComment comment = worksheet.getRange("D5").addComment("Check this value.");
       IRange cell = comment.getAnchorCell();
       
      Returns:
      The IRange object to which this comment is attached.
    • delete

      void delete()
      Deletes this comment from its cell.

      Use this method to remove a single cell comment. To remove comments from multiple cells in a range, use IRange.clearComments().

      
       worksheet.getRange("D5").setValue("Review");
       IComment comment = worksheet.getRange("D5").addComment("Check this value.");
       comment.delete();
       
    • next

      IComment next()
      Returns the IComment object that represents the next comment.

      Returns null if the current comment is the last comment on the worksheet.

      
       worksheet.getRange("C3").addComment("First note.");
       IComment comment = worksheet.getRange("D5").addComment("Second note.");
       worksheet.getRange("F7").addComment("Third note.");
       IComment nextComment = comment.next();
       
      Returns:
      The next comment after the current comment, or null if the current comment is the last comment on the worksheet.
    • previous

      IComment previous()
      Returns the IComment object that represents the previous comment.

      Returns null if the current comment is the first comment on the worksheet.

      
       worksheet.getRange("B2").addComment("First note.");
       IComment comment = worksheet.getRange("D5").addComment("Second note.");
       IComment previousComment = comment.previous();
       
      Returns:
      The previous comment before the current comment, or null if the current comment is the first comment on the worksheet.
    • getVisible

      boolean getVisible()
      Gets whether the comment is visible.

      Use this method to check whether the comment is visible.

      
       IComment comment = worksheet.getRange("C3").addComment("Review this value.");
       comment.setVisible(true);
       boolean visible = comment.getVisible();
       
      Returns:
      true if the comment is visible; otherwise, false.
    • setVisible

      void setVisible(boolean value)
      Sets whether the comment is visible.

      Use this method to show or hide the comment.

      
       IComment comment = worksheet.getRange("C3").addComment("Review this value.");
       comment.setVisible(true);
       
      Parameters:
      value - true if the comment is visible; otherwise, false.
    • getShape

      IShape getShape()
      Returns the IShape object that represents the shape attached to this comment.

      Use the returned shape to configure the comment's layout, such as its size, line, fill, and text formatting.

      
       worksheet.getRange("D5").setValue("Review");
       IComment comment = worksheet.getRange("D5").addComment("Check this value.");
       IShape shape = comment.getShape();
       shape.setWidth(220);
       
      Returns:
      The IShape object attached to the comment.
    • fromJson

      void fromJson(String json)
      Generates the comment from the specified JSON string.

      Use this method to apply serialized comment information to the current comment. The JSON content is typically generated by toJson().

      
       IComment sourceComment = worksheet.getRange("A1").addComment("Review this value.");
       sourceComment.getShape().setWidth(220);
       String json = sourceComment.toJson();
       IComment targetComment = worksheet.getRange("C3").addComment("Draft");
       targetComment.fromJson(json);
       
      Parameters:
      json - The JSON string that contains comment information.
    • toJson

      String toJson()
      Generates a json string from the comment.

      The returned string contains the comment information and can be used with fromJson(String) to recreate or update a comment.

      
       worksheet.getRange("D5").setValue("Review");
       IComment comment = worksheet.getRange("D5").addComment("Check this value.");
       String json = comment.toJson();
       
      Returns:
      The json string that contains comment info.