Comment
Inheritance: java.lang.Object
public class Comment
Encapsulates the object that represents a cell comment.
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");
Methods
Method | Description |
---|---|
characters(int startIndex, int length) | Returns a Characters object that represents a range of characters within the comment text. |
equals(Object arg0) | |
formatCharacters(int startIndex, int length, Font font, StyleFlag flag) | Format some characters with the font setting. |
getAuthor() | Gets Name of the original comment author |
getAutoSize() | Indicates if size of comment is adjusted automatically according to its content. |
getCharacters() | Returns all Characters objects that represents a range of characters within the comment text. |
getClass() | |
getColumn() | Gets the column index of the comment. |
getCommentShape() | Get a Shape object that represents the shape attached to the specified comment. |
getFont() | Gets the font of comment. |
getHeight() | Represents the Height of the comment, in unit of pixels. |
getHeightCM() | Represents the height of the comment, in unit of centimeters. |
getHeightInch() | Represents the height of the comment, in unit of inches. |
getHtmlNote() | Gets the html string which contains data and some formats in this comment. |
getNote() | Represents the content of comment. |
getRichFormattings() | Returns all Characters objects that represents a range of characters within the comment text. |
getRow() | Gets the row index of the comment. |
getTextHorizontalAlignment() | Gets the text horizontal alignment type of the comment. |
getTextOrientationType() | Gets the text orientation type of the comment. |
getTextVerticalAlignment() | Gets the text vertical alignment type of the comment. |
getThreadedComments() | Gets the list of threaded comments; |
getWidth() | Represents the width of the comment, in unit of pixels. |
getWidthCM() | Represents the width of the comment, in unit of centimeters. |
getWidthInch() | Represents the width of the comment, in unit of inches. |
hashCode() | |
isThreadedComment() | Indicates whether this comment is a threaded comment. |
isVisible() | Represents if the comment is visible or not. |
notify() | |
notifyAll() | |
setAuthor(String value) | Sets Name of the original comment author |
setAutoSize(boolean value) | Indicates if size of comment is adjusted automatically according to its content. |
setHeight(int value) | Represents the Height of the comment, in unit of pixels. |
setHeightCM(double value) | Represents the height of the comment, in unit of centimeters. |
setHeightInch(double value) | Represents the height of the comment, in unit of inches. |
setHtmlNote(String value) | Sets the html string which contains data and some formats in this comment. |
setNote(String value) | Represents the content of comment. |
setTextHorizontalAlignment(int value) | Sets the text horizontal alignment type of the comment. |
setTextOrientationType(int value) | Sets the text orientation type of the comment. |
setTextVerticalAlignment(int value) | Sets the text vertical alignment type of the comment. |
setVisible(boolean value) | Represents if the comment is visible or not. |
setWidth(int value) | Represents the width of the comment, in unit of pixels. |
setWidthCM(double value) | Represents the width of the comment, in unit of centimeters. |
setWidthInch(double value) | Represents the width of the comment, in unit of inches. |
toString() | |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
characters(int startIndex, int length)
public FontSetting characters(int startIndex, int length)
Returns a Characters object that represents a range of characters within the comment text.
Example
FontSetting fontSetting = comment1.characters(0, 4);
Parameters:
Parameter | Type | Description |
---|---|---|
startIndex | int | The index of the start of the character. |
length | int | The number of characters. |
Returns: FontSetting - Characters object.
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
formatCharacters(int startIndex, int length, Font font, StyleFlag flag)
public void formatCharacters(int startIndex, int length, Font font, StyleFlag flag)
Format some characters with the font setting.
Parameters:
Parameter | Type | Description |
---|---|---|
startIndex | int | The start index. |
length | int | The length. |
font | Font | The font setting. |
flag | StyleFlag | The flag of the font setting. |
getAuthor()
public String getAuthor()
Gets Name of the original comment author
Example
comment1.setAuthor("Carl.Yang");
Returns: java.lang.String
getAutoSize()
public boolean getAutoSize()
Indicates if size of comment is adjusted automatically according to its content.
Example
if(!comment1.getAutoSize())
{
//The size of the comment varies with the content
comment1.setAutoSize(true);
}
Returns: boolean
getCharacters()
public ArrayList getCharacters()
Returns all Characters objects that represents a range of characters within the comment text.
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);
Returns: java.util.ArrayList - All Characters objects
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getColumn()
public int getColumn()
Gets the column index of the comment.
Example
int column = comment1.getColumn();
Returns: int
getCommentShape()
public CommentShape getCommentShape()
Get a Shape object that represents the shape attached to the specified comment.
Example
CommentShape shape = comment1.getCommentShape();
int w = shape.getWidth();
int h = shape.getHeight();
Returns: CommentShape
getFont()
public Font getFont()
Gets the font of comment.
Example
Font font = comment1.getFont();
font.setSize(12);
Returns: Font
getHeight()
public int getHeight()
Represents the Height of the comment, in unit of pixels.
Example
comment1.setHeight(10);
Returns: int
getHeightCM()
public double getHeightCM()
Represents the height of the comment, in unit of centimeters.
Example
comment1.setHeightCM(1.0);
Returns: double
getHeightInch()
public double getHeightInch()
Represents the height of the comment, in unit of inches.
Example
comment1.setHeightInch(1.0);
Returns: double
getHtmlNote()
public String getHtmlNote()
Gets the html string which contains data and some formats in this comment.
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>");
Returns: java.lang.String
getNote()
public String getNote()
Represents the content of comment.
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.");
Returns: java.lang.String
getRichFormattings()
public FontSetting[] getRichFormattings()
Returns all Characters objects that represents a range of characters within the comment text.
Example
FontSetting[] list = comment1.getRichFormattings();
Returns: com.aspose.cells.FontSetting[] - All Characters objects
getRow()
public int getRow()
Gets the row index of the comment.
Example
int row = comment1.getRow();
Returns: int
getTextHorizontalAlignment()
public int getTextHorizontalAlignment()
Gets the text horizontal alignment type of the comment.
See TextAlignmentType.
Example
if (comment1.getTextHorizontalAlignment() == TextAlignmentType.FILL)
{
comment1.setTextHorizontalAlignment(TextAlignmentType.CENTER);
}
Returns: int
getTextOrientationType()
public int getTextOrientationType()
Gets the text orientation type of the comment.
See TextOrientationType.
Example
if(comment1.getTextOrientationType() == TextOrientationType.NO_ROTATION)
{
comment1.setTextOrientationType(TextOrientationType.TOP_TO_BOTTOM);
}
Returns: int
getTextVerticalAlignment()
public int getTextVerticalAlignment()
Gets the text vertical alignment type of the comment.
See TextAlignmentType.
Example
if (comment1.getTextVerticalAlignment() == TextAlignmentType.FILL)
{
comment1.setTextVerticalAlignment(TextAlignmentType.CENTER);
}
Returns: int
getThreadedComments()
public ThreadedCommentCollection getThreadedComments()
Gets the list of threaded comments;
Example
ThreadedCommentCollection threadedComments = comment1.getThreadedComments();
for (int i = 0; i <threadedComments.getCount(); ++i)
{
ThreadedComment tc = threadedComments.get(i);
String note = tc.getNotes();
}
Returns: ThreadedCommentCollection
getWidth()
public int getWidth()
Represents the width of the comment, in unit of pixels.
Example
comment1.setWidth(10);
Returns: int
getWidthCM()
public double getWidthCM()
Represents the width of the comment, in unit of centimeters.
Example
comment1.setWidthCM(1.0);
Returns: double
getWidthInch()
public double getWidthInch()
Represents the width of the comment, in unit of inches.
Example
comment1.setWidthInch(1.0);
Returns: double
hashCode()
public native int hashCode()
Returns: int
isThreadedComment()
public boolean isThreadedComment()
Indicates whether this comment is a threaded comment.
Example
if(comment1.isThreadedComment())
{
//This comment is a threaded comment.
}
Returns: boolean
isVisible()
public boolean isVisible()
Represents if the comment is visible or not.
Example
if(comment1.isVisible())
{
//The comment is visible
}
Returns: boolean
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
setAuthor(String value)
public void setAuthor(String value)
Sets Name of the original comment author
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setAutoSize(boolean value)
public void setAutoSize(boolean value)
Indicates if size of comment is adjusted automatically according to its content.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setHeight(int value)
public void setHeight(int value)
Represents the Height of the comment, in unit of pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setHeightCM(double value)
public void setHeightCM(double value)
Represents the height of the comment, in unit of centimeters.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
setHeightInch(double value)
public void setHeightInch(double value)
Represents the height of the comment, in unit of inches.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
setHtmlNote(String value)
public void setHtmlNote(String value)
Sets the html string which contains data and some formats in this comment.
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setNote(String value)
public void setNote(String value)
Represents the content of comment.
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setTextHorizontalAlignment(int value)
public void setTextHorizontalAlignment(int value)
Sets the text horizontal alignment type of the comment.
See TextAlignmentType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setTextOrientationType(int value)
public void setTextOrientationType(int value)
Sets the text orientation type of the comment.
See TextOrientationType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setTextVerticalAlignment(int value)
public void setTextVerticalAlignment(int value)
Sets the text vertical alignment type of the comment.
See TextAlignmentType.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setVisible(boolean value)
public void setVisible(boolean value)
Represents if the comment is visible or not.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setWidth(int value)
public void setWidth(int value)
Represents the width of the comment, in unit of pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setWidthCM(double value)
public void setWidthCM(double value)
Represents the width of the comment, in unit of centimeters.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
setWidthInch(double value)
public void setWidthInch(double value)
Represents the width of the comment, in unit of inches.
Parameters:
Parameter | Type | Description |
---|---|---|
value | double |
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |