public class Comment
extends java.lang.Object
Example
Workbook workbook = new Workbook();
CommentCollection comments = workbook.getWorksheets().get(0).getComments();
//Add comment to cell A1
int commentIndex1 = comments.add(0, 0);
Comment comment1 = comments.get(commentIndex1);
comment1.setNote("First note.");
comment1.getFont().setName("Times New Roman");
//Add comment to cell B2
comments.add("B2");
Comment comment2 = comments.get("B2");
comment2.setNote("Second note.");
//do your business
//Save the excel file.
workbook.save("exmaple.xlsx");
| Modifier and Type | Method and Description |
|---|---|
FontSetting |
characters(int startIndex,
int length)
Returns a Characters object that represents a range of characters within the comment text.
|
void |
formatCharacters(int startIndex,
int length,
Font font,
StyleFlag flag)
Format some characters with the font setting.
|
java.lang.String |
getAuthor()
Gets Name of the original comment author
|
boolean |
getAutoSize()
Indicates if size of comment is adjusted automatically according to its content.
|
java.util.ArrayList |
getCharacters()
Deprecated.
Use Comment.GetRichFormattings() instead.
|
int |
getColumn()
Gets the column index of the comment.
|
CommentShape |
getCommentShape()
Get a Shape object that represents the shape attached to the specified comment.
|
Font |
getFont()
Gets the font of comment.
|
int |
getHeight()
Represents the Height of the comment, in unit of pixels.
|
double |
getHeightCM()
Represents the height of the comment, in unit of centimeters.
|
double |
getHeightInch()
Represents the height of the comment, in unit of inches.
|
java.lang.String |
getHtmlNote()
Gets the html string which contains data and some formats in this comment.
|
java.lang.String |
getNote()
Represents the content of comment.
|
FontSetting[] |
getRichFormattings()
Returns all Characters objects
that represents a range of characters within the comment text.
|
int |
getRow()
Gets the row index of the comment.
|
int |
getTextHorizontalAlignment()
Gets the text horizontal alignment type of the comment.
|
int |
getTextOrientationType()
Gets the text orientation type of the comment.
|
int |
getTextVerticalAlignment()
Gets the text vertical alignment type of the comment.
|
ThreadedCommentCollection |
getThreadedComments()
Gets the list of threaded comments;
|
int |
getWidth()
Represents the width of the comment, in unit of pixels.
|
double |
getWidthCM()
Represents the width of the comment, in unit of centimeters.
|
double |
getWidthInch()
Represents the width of the comment, in unit of inches.
|
boolean |
isThreadedComment()
Indicates whether this comment is a threaded comment.
|
boolean |
isVisible()
Represents if the comment is visible or not.
|
void |
setAuthor(java.lang.String value)
Sets Name of the original comment author
|
void |
setAutoSize(boolean value)
Indicates if size of comment is adjusted automatically according to its content.
|
void |
setHeight(int value)
Represents the Height of the comment, in unit of pixels.
|
void |
setHeightCM(double value)
Represents the height of the comment, in unit of centimeters.
|
void |
setHeightInch(double value)
Represents the height of the comment, in unit of inches.
|
void |
setHtmlNote(java.lang.String value)
Sets the html string which contains data and some formats in this comment.
|
void |
setNote(java.lang.String value)
Represents the content of comment.
|
void |
setTextHorizontalAlignment(int value)
Sets the text horizontal alignment type of the comment.
|
void |
setTextOrientationType(int value)
Sets the text orientation type of the comment.
|
void |
setTextVerticalAlignment(int value)
Sets the text vertical alignment type of the comment.
|
void |
setVisible(boolean value)
Represents if the comment is visible or not.
|
void |
setWidth(int value)
Represents the width of the comment, in unit of pixels.
|
void |
setWidthCM(double value)
Represents the width of the comment, in unit of centimeters.
|
void |
setWidthInch(double value)
Represents the width of the comment, in unit of inches.
|
public java.lang.String getAuthor()
Example
comment1.setAuthor("Carl.Yang");
public void setAuthor(java.lang.String value)
public CommentShape getCommentShape()
Example
CommentShape shape = comment1.getCommentShape();
int w = shape.getWidth();
int h = shape.getHeight();
public int getRow()
Example
int row = comment1.getRow();
public int getColumn()
Example
int column = comment1.getColumn();
public boolean isThreadedComment()
Example
if(comment1.isThreadedComment())
{
//This comment is a threaded comment.
}
public ThreadedCommentCollection getThreadedComments()
Example
ThreadedCommentCollection threadedComments = comment1.getThreadedComments();
for (int i = 0; i <threadedComments.getCount(); ++i)
{
ThreadedComment tc = threadedComments.get(i);
String note = tc.getNotes();
}
public java.lang.String getNote()
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.Example
comment1.setNote("First note.");
public void setNote(java.lang.String value)
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.public java.lang.String getHtmlNote()
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.Example
comment1.setHtmlNote("<Font Style='FONT-FAMILY: Calibri;FONT-SIZE: 11pt;COLOR: #0000ff;TEXT-ALIGN: left;'>This is a <b>test</b>.</Font>");
public void setHtmlNote(java.lang.String value)
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.public Font getFont()
Example
Font font = comment1.getFont();
font.setSize(12);
public void formatCharacters(int startIndex,
int length,
Font font,
StyleFlag flag)
startIndex - The start index.length - The length.font - The font setting.flag - The flag of the font setting.public FontSetting characters(int startIndex, int length)
Example
FontSetting fontSetting = comment1.characters(0, 4);
startIndex - The index of the start of the character.length - The number of characters.public java.util.ArrayList getCharacters()
Remarks
NOTE: This method is now obsolete. Instead, please use Comment.GetRichFormattings() method. This method will be removed 12 months later since November 2023. Aspose apologizes for any inconvenience you may have experienced.Example
FontSetting fontSetting = comment1.characters(0, 4);
public FontSetting[] getRichFormattings()
Example
FontSetting[] list = comment1.getRichFormattings();
public boolean isVisible()
Example
if(comment1.isVisible())
{
//The comment is visible
}
public void setVisible(boolean value)
public int getTextOrientationType()
See TextOrientationType.
Example
if(comment1.getTextOrientationType() == TextOrientationType.NO_ROTATION)
{
comment1.setTextOrientationType(TextOrientationType.TOP_TO_BOTTOM);
}
public void setTextOrientationType(int value)
See TextOrientationType.
public int getTextHorizontalAlignment()
See TextAlignmentType.
Example
if (comment1.getTextHorizontalAlignment() == TextAlignmentType.FILL)
{
comment1.setTextHorizontalAlignment(TextAlignmentType.CENTER);
}
public void setTextHorizontalAlignment(int value)
See TextAlignmentType.
public int getTextVerticalAlignment()
See TextAlignmentType.
Example
if (comment1.getTextVerticalAlignment() == TextAlignmentType.FILL)
{
comment1.setTextVerticalAlignment(TextAlignmentType.CENTER);
}
public void setTextVerticalAlignment(int value)
See TextAlignmentType.
public boolean getAutoSize()
Example
if(!comment1.getAutoSize())
{
//The size of the comment varies with the content
comment1.setAutoSize(true);
}
public void setAutoSize(boolean value)
public double getHeightCM()
Example
comment1.setHeightCM(1.0);
public void setHeightCM(double value)
public double getWidthCM()
Example
comment1.setWidthCM(1.0);
public void setWidthCM(double value)
public int getWidth()
Example
comment1.setWidth(10);
public void setWidth(int value)
public int getHeight()
Example
comment1.setHeight(10);
public void setHeight(int value)
public double getWidthInch()
Example
comment1.setWidthInch(1.0);
public void setWidthInch(double value)
public double getHeightInch()
Example
comment1.setHeightInch(1.0);
public void setHeightInch(double value)
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.