Comment

Comment class

Encapsulates the object that represents a cell comment.

class Comment;

Example

const { Workbook } = AsposeCells;

var workbook = new Workbook();
var comments = workbook.worksheets.get(0).comments;

//Add comment to cell A1
var commentIndex = comments.add(0, 0);
var comment = comments.get(commentIndex);
comment.note = "First note.";
comment.font.setName("Times New Roman");

//Add comment to cell B2
comments.add("B2");
comment = comments.get("B2");
comment.note = "Second note.";

Properties

PropertyTypeDescription
authorstringGets and sets Name of the original comment author
commentShapeCommentShapeReadonly. Get a Shape object that represents the shape attached to the specified comment.
rownumberReadonly. Gets the row index of the comment.
columnnumberReadonly. Gets the column index of the comment.
isThreadedCommentbooleanReadonly. Indicates whether this comment is a threaded comment.
threadedCommentsThreadedCommentCollectionReadonly. Gets the list of threaded comments;
notestringRepresents the content of comment.
htmlNotestringGets and sets the html string which contains data and some formats in this comment.
fontFontReadonly. Gets the font of comment.
isVisiblebooleanRepresents if the comment is visible or not.
textOrientationTypeTextOrientationTypeGets and sets the text orientation type of the comment.
textHorizontalAlignmentTextAlignmentTypeGets and sets the text horizontal alignment type of the comment.
textVerticalAlignmentTextAlignmentTypeGets and sets the text vertical alignment type of the comment.
autoSizebooleanIndicates if size of comment is adjusted automatically according to its content. Note: In some special cases (such as Mac environment), this setting may not take effect. If this setting does not take effect, please replace it with FitToTextSize().
heightCMnumberRepresents the height of the comment, in unit of centimeters.
widthCMnumberRepresents the width of the comment, in unit of centimeters.
widthnumberRepresents the width of the comment, in unit of pixels.
heightnumberRepresents the Height of the comment, in unit of pixels.
widthInchnumberRepresents the width of the comment, in unit of inches.
heightInchnumberRepresents the height of the comment, in unit of inches.

Methods

MethodDescription
formatCharacters(number, number, Font, StyleFlag)Format some characters with the font setting.
characters(number, number)Returns a Characters object that represents a range of characters within the comment text.
getRichFormattings()Returns all Characters objects that represents a range of characters within the comment text.

author

Gets and sets Name of the original comment author

author : string;

commentShape

Readonly. Get a Shape object that represents the shape attached to the specified comment.

commentShape : CommentShape;

row

Readonly. Gets the row index of the comment.

row : number;

column

Readonly. Gets the column index of the comment.

column : number;

isThreadedComment

Readonly. Indicates whether this comment is a threaded comment.

isThreadedComment : boolean;

threadedComments

Readonly. Gets the list of threaded comments;

threadedComments : ThreadedCommentCollection;

note

Represents the content of comment.

note : string;

Remarks

If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.

htmlNote

Gets and sets the html string which contains data and some formats in this comment.

htmlNote : string;

Remarks

If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.

font

Readonly. Gets the font of comment.

font : Font;

isVisible

Represents if the comment is visible or not.

isVisible : boolean;

textOrientationType

Gets and sets the text orientation type of the comment.

textOrientationType : TextOrientationType;

textHorizontalAlignment

Gets and sets the text horizontal alignment type of the comment.

textHorizontalAlignment : TextAlignmentType;

textVerticalAlignment

Gets and sets the text vertical alignment type of the comment.

textVerticalAlignment : TextAlignmentType;

autoSize

Indicates if size of comment is adjusted automatically according to its content. Note: In some special cases (such as Mac environment), this setting may not take effect. If this setting does not take effect, please replace it with FitToTextSize().

autoSize : boolean;

heightCM

Represents the height of the comment, in unit of centimeters.

heightCM : number;

widthCM

Represents the width of the comment, in unit of centimeters.

widthCM : number;

width

Represents the width of the comment, in unit of pixels.

width : number;

height

Represents the Height of the comment, in unit of pixels.

height : number;

widthInch

Represents the width of the comment, in unit of inches.

widthInch : number;

heightInch

Represents the height of the comment, in unit of inches.

heightInch : number;

formatCharacters(number, number, Font, StyleFlag)

Format some characters with the font setting.

formatCharacters(startIndex: number, length: number, font: Font, flag: StyleFlag) : void;

Parameters:

ParameterTypeDescription
startIndexnumberThe start index.
lengthnumberThe length.
fontFontThe font setting.
flagStyleFlagThe flag of the font setting.

characters(number, number)

Returns a Characters object that represents a range of characters within the comment text.

characters(startIndex: number, length: number) : FontSetting;

Parameters:

ParameterTypeDescription
startIndexnumberThe index of the start of the character.
lengthnumberThe number of characters.

Returns

Characters object.

getRichFormattings()

Returns all Characters objects that represents a range of characters within the comment text.

getRichFormattings() : FontSetting[];

Returns

All Characters objects