ThreadedComment Interface
A threaded comment.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Related API Members
The following members return ThreadedComment objects:
Remarks
Note
The Spreadsheet Document API does not print or export threaded comments to PDF format.
Create a Comment
If you pass a cell range as the method parameter, the comment is added to the top-left cell of this range.
Call the ThreadedCommentCollection.Add method to add a threaded comment to a specific cell. If you pass a cell range as the method parameter, the comment is added to the top-left cell of this range.
You can pass a string or a ThreadedCommentAuthor instance to specify a comment author. The ThreadedCommentAuthor
object allows you to specify login credentials that link the author to their identity provider (Windows Live ID, Office 365, and so on).
The code sample below adds a comment to the G16 cell:
var workbook = new Workbook();
workbook.LoadDocument(@"C:\Docs\Comments.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
var comments = worksheet.ThreadedComments;
ThreadedComment threadedComment =
comments.Add(worksheet["G16"], "Sales Department",
"The discount was approved by the Sales Director at the meeting on November 5th.");
threadedComment.Resolved = true;
workbook.SaveDocument(@"C:\Docs\Comments_upd.xlsx");
Reply to a Comment
Use the Reply method to add a reply. You can pass a string or a ThreadedCommentAuthor instance to specify the comment’s author.
Use the ThreadedComment.Replies property to access replies in a thread. You can edit or remove replies as your needs dictate.
The code sample below adds a reply to the first comment:
using DevExpress.Spreadsheet;
var workbook = new Workbook();
workbook.LoadDocument(@"C:\Docs\Comments.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
var comments = worksheet.ThreadedComments;
ThreadedComment threadedComment = comments[0];
threadedComment.Reply("Nancy Davolio", "Thanks for the hint");
workbook.SaveDocument(@"C:\Docs\Comments_upd.xlsx");
Remove a Comment
The following methods allow you to remove comments:
- ThreadedCommentCollection.Remove
- Removes the specified comments or a comment applied to a cell range.
- ThreadedCommentCollection.RemoveAt
- Removes a comment at the specified index in the collection.
The code sample below removes all comments with the specified author:
var workbook = new Workbook();
workbook.LoadDocument(@"C:\Docs\Comments.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
var comments = worksheet.ThreadedComments.Where(comment => comment.Author.Name == "Nancy Davolio");
if (comments!=null)
{
foreach (var comment in comments)
{
worksheet.ThreadedComments.Remove(comment);
}
}