Class Comment
Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)
Encapsulates the object that represents a cell comment.
public class Comment
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
Workbook workbook = new Workbook();
CommentCollection comments = workbook.Worksheets[0].Comments;
//Add comment to cell A1
int commentIndex1 = comments.Add(0, 0);
Comment comment1 = comments[commentIndex1];
comment1.Note = "First note.";
comment1.Font.Name = "Times New Roman";
//Add comment to cell B2
comments.Add("B2");
Comment comment2 = comments["B2"];
comment2.Note = "Second note.";
//do your business
//Save the excel file.
workbook.Save("exmaple.xlsx");
Dim workbook as Workbook = new Workbook()
Dim comments as CommentCollection = workbook.Worksheets(0).Comments
'Add comment to cell A1
Dim commentIndex1 as Integer = comments.Add(0, 0)
Dim comment1 as Comment = comments(commentIndex1)
comment1.Note = "First note."
comment1.Font.Name = "Times New Roman"
'Add comment to cell B2
comments.Add("B2")
Dim comment2 As Comment = comments("B2")
comment2.Note = "Second note."
Properties
Author
Gets and sets Name of the original comment author
public string Author { get; set; }
Property Value
Examples
csharp
[C#]
comment1.Author = "Carl.Yang";
AutoSize
Indicates if size of comment is adjusted automatically according to its content.
public bool AutoSize { get; set; }
Property Value
Examples
csharp
[C#]
if(!comment1.AutoSize)
{
//The size of the comment varies with the content
comment1.AutoSize = true;
}
Column
Gets the column index of the comment.
public int Column { get; }
Property Value
Examples
csharp
[C#]
int column = comment1.Column;
CommentShape
Get a Shape object that represents the shape attached to the specified comment.
public CommentShape CommentShape { get; }
Property Value
Examples
csharp
[C#]
CommentShape shape = comment1.CommentShape;
int w = shape.Width;
int h = shape.Height;
Font
Gets the font of comment.
public Font Font { get; }
Property Value
Examples
csharp
[C#]
Aspose.Cells.Font font = comment1.Font;
font.Size = 12;
Height
Represents the Height of the comment, in unit of pixels.
public int Height { get; set; }
Property Value
Examples
csharp
[C#]
comment1.Height = 10;
HeightCM
Represents the height of the comment, in unit of centimeters.
public double HeightCM { get; set; }
Property Value
Examples
csharp
[C#]
comment1.HeightCM = 1.0;
HeightInch
Represents the height of the comment, in unit of inches.
public double HeightInch { get; set; }
Property Value
Examples
csharp
[C#]
comment1.HeightInch = 1.0;
HtmlNote
Gets and sets the html string which contains data and some formats in this comment.
public string HtmlNote { get; set; }
Property Value
Examples
csharp
[C#]
comment1.HtmlNote = "<Font Style='FONT-FAMILY: Calibri;FONT-SIZE: 11pt;COLOR: #0000ff;TEXT-ALIGN: left;'>This is a <b>test</b>.</Font>";
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.
IsThreadedComment
Indicates whether this comment is a threaded comment.
public bool IsThreadedComment { get; }
Property Value
Examples
csharp
[C#]
if(comment1.IsThreadedComment)
{
//This comment is a threaded comment.
}
IsVisible
Represents if the comment is visible or not.
public bool IsVisible { get; set; }
Property Value
Examples
csharp
[C#]
if(comment1.IsVisible)
{
//The comment is visible
}
Note
Represents the content of comment.
public string Note { get; set; }
Property Value
Examples
csharp
[C#]
comment1.Note = "First note.";
Remarks
If this is a threaded comment, the note could not be changed, otherwise MS Excel could not process it as a threaded comment.
Row
Gets the row index of the comment.
public int Row { get; }
Property Value
Examples
csharp
[C#]
int row = comment1.Row;
TextHorizontalAlignment
Gets and sets the text horizontal alignment type of the comment.
public TextAlignmentType TextHorizontalAlignment { get; set; }
Property Value
Examples
csharp
[C#]
if (comment1.TextHorizontalAlignment == TextAlignmentType.Fill)
{
comment1.TextHorizontalAlignment = TextAlignmentType.Center;
}
TextOrientationType
Gets and sets the text orientation type of the comment.
public TextOrientationType TextOrientationType { get; set; }
Property Value
Examples
csharp
[C#]
if(comment1.TextOrientationType == TextOrientationType.NoRotation)
{
comment1.TextOrientationType = TextOrientationType.TopToBottom;
}
TextVerticalAlignment
Gets and sets the text vertical alignment type of the comment.
public TextAlignmentType TextVerticalAlignment { get; set; }
Property Value
Examples
csharp
[C#]
if (comment1.TextVerticalAlignment == TextAlignmentType.Fill)
{
comment1.TextVerticalAlignment = TextAlignmentType.Center;
}
ThreadedComments
Gets the list of threaded comments;
public ThreadedCommentCollection ThreadedComments { get; }
Property Value
Examples
csharp
[C#]
ThreadedCommentCollection threadedComments = comment1.ThreadedComments;
for (int i = 0; i < threadedComments.Count; ++i)
{
ThreadedComment tc = threadedComments[i];
string note = tc.Notes;
}
Width
Represents the width of the comment, in unit of pixels.
public int Width { get; set; }
Property Value
Examples
csharp
[C#]
comment1.Width = 10;
WidthCM
Represents the width of the comment, in unit of centimeters.
public double WidthCM { get; set; }
Property Value
Examples
csharp
[C#]
comment1.WidthCM = 1.0;
WidthInch
Represents the width of the comment, in unit of inches.
public double WidthInch { get; set; }
Property Value
Examples
csharp
[C#]
comment1.WidthInch = 1.0;
Methods
Characters(int, int)
Returns a Characters object that represents a range of characters within the comment text.
public FontSetting Characters(int startIndex, int length)
Parameters
startIndex
int
The index of the start of the character.
length
int
The number of characters.
Returns
Characters object.
Examples
csharp
[C#]
Aspose.Cells.FontSetting fontSetting = comment1.Characters(0, 4);
FormatCharacters(int, int, Font, StyleFlag)
Format some characters with the font setting.
public void FormatCharacters(int startIndex, int length, Font font, StyleFlag flag)
Parameters
startIndex
int
The start index.
length
int
The length.
font
Font
The font setting.
flag
StyleFlag
The flag of the font setting.
GetRichFormattings()
Returns all Characters objects that represents a range of characters within the comment text.
public FontSetting[] GetRichFormattings()
Returns
All Characters objects
Examples
csharp
[C#]
FontSetting[] list = comment1.GetRichFormattings();