Class CommentCollection
Contents
[
Hide
]CommentCollection class
Encapsulates a collection of Comment objects.
public class CommentCollection : CollectionBase<Comment>
Properties
| Name | Description | 
|---|---|
| Capacity { get; set; } | |
| Count { get; } | |
| Item { get; } | Gets the Comment element at the specified index. (3 indexers) | 
| Item { get; set; } | 
Methods
| Name | Description | 
|---|---|
| Add(string) | Adds a comment to the collection. | 
| Add(int, int) | Adds a comment to the collection. | 
| AddThreadedComment(string, string, ThreadedCommentAuthor) | Adds a threaded comment. | 
| AddThreadedComment(int, int, string, ThreadedCommentAuthor) | Adds a threaded comment. | 
| BinarySearch(Comment) | |
| BinarySearch(Comment, IComparer<Comment>) | |
| BinarySearch(int, int, Comment, IComparer<Comment>) | |
| Clear() | Removes all comments; (2 methods) | 
| Contains(Comment) | |
| CopyTo(Comment[]) | |
| CopyTo(Comment[], int) | |
| CopyTo(int, Comment[], int, int) | |
| Exists(Predicate<Comment>) | |
| Find(Predicate<Comment>) | |
| FindAll(Predicate<Comment>) | |
| FindIndex(Predicate<Comment>) | |
| FindIndex(int, Predicate<Comment>) | |
| FindIndex(int, int, Predicate<Comment>) | |
| FindLast(Predicate<Comment>) | |
| FindLastIndex(Predicate<Comment>) | |
| FindLastIndex(int, Predicate<Comment>) | |
| FindLastIndex(int, int, Predicate<Comment>) | |
| GetEnumerator() | |
| GetThreadedComments(string) | Gets the threaded comments by cell name. | 
| GetThreadedComments(int, int) | Gets the threaded comments by row and column index. | 
| IndexOf(Comment) | |
| IndexOf(Comment, int) | |
| IndexOf(Comment, int, int) | |
| LastIndexOf(Comment) | |
| LastIndexOf(Comment, int) | |
| LastIndexOf(Comment, int, int) | |
| RemoveAt(int) | |
| RemoveAt(string) | Removes the comment of the specific cell. | 
| RemoveAt(int, int) | Removes the comment of the specific cell. | 
Examples
namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using System;
    public class CommentCollectionDemo
    {
        public static void CommentCollectionExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            // Access the comments collection of the worksheet
            CommentCollection comments = worksheet.Comments;
            // Add a comment to cell A1
            int commentIndex1 = comments.Add(0, 0);
            Comment comment1 = comments[commentIndex1];
            comment1.Note = "First note.";
            comment1.Author = "Author1";
            comment1.Font.Name = "Times New Roman";
            // Add a comment to cell B2
            comments.Add("B2");
            Comment comment2 = comments["B2"];
            comment2.Note = "Second note.";
            comment2.Author = "Author2";
            // Add a threaded comment to cell C3
            int authorIndex = workbook.Worksheets.ThreadedCommentAuthors.Add("Author3", "user3", "provider3");
            ThreadedCommentAuthor author = workbook.Worksheets.ThreadedCommentAuthors[authorIndex];
            comments.AddThreadedComment(2, 2, "This is a threaded comment.", author);
            // Retrieve threaded comments from cell C3
            var threadedComments = comments.GetThreadedComments(2, 2);
            foreach (var threadedComment in threadedComments)
            {
                Console.WriteLine(threadedComment.Notes);
            }
            // Remove the comment at cell A1
            comments.RemoveAt(0, 0);
            // Clear all comments
            comments.Clear();
            // Save the workbook
            workbook.Save("CommentCollectionExample.xlsx");
            workbook.Save("CommentCollectionExample.pdf");
        }
    }
}
See Also
- class CollectionBase<T>
 - class Comment
 - namespace Aspose.Cells
 - assembly Aspose.Cells