officefileapi-devexpress-dot-spreadsheet-8faa3457.md
A threaded comment.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface ThreadedComment
Public Interface ThreadedComment
The following members return ThreadedComment objects:
Note
The Spreadsheet Document API does not print or export threaded comments to PDF format.
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");
Dim workbook As New Workbook()
workbook.LoadDocument("C:\Docs\Comments.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim comments = worksheet.ThreadedComments
Dim threadedComment As 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")
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");
Imports DevExpress.Spreadsheet
Private workbook = New Workbook()
workbook.LoadDocument("C:\Docs\Comments.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim comments = worksheet.ThreadedComments
Dim threadedComment As ThreadedComment = comments(0)
threadedComment.Reply("Nancy Davolio", "Thanks for the hint")
workbook.SaveDocument("C:\Docs\Comments_upd.xlsx")
The following methods allow you to remove comments:
ThreadedCommentCollection.RemoveRemoves the specified comments or a comment applied to a cell range.ThreadedCommentCollection.RemoveAtRemoves 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);
}
}
Dim workbook As New Workbook()
workbook.LoadDocument("C:\Docs\Comments.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim comments = worksheet.ThreadedComments.Where(Function(comment) comment.Author.Name = "Nancy Davolio")
If comments IsNot Nothing Then
For Each comment In comments
worksheet.ThreadedComments.Remove(comment)
Next comment
End If
See Also