officefileapi-devexpress-dot-spreadsheet-dot-threadedcommentcollection-dot-add-x28-devexpress-dot-spreadsheet-dot-cellrange-system-dot-string-system-dot-string-x29.md
Creates a new threaded comment.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
ThreadedComment Add(
CellRange range,
string authorName,
string text
)
Function Add(
range As CellRange,
authorName As String,
text As String
) As ThreadedComment
| Name | Type | Description |
|---|---|---|
| range | CellRange |
A cell range to which a comment should be added. If you pass a cell range as the parameter, the comment is added to the top-left cell of this range.
| | authorName | String |
The name of the comment author.
| | text | String |
The text of the comment.
|
| Type | Description |
|---|---|
| ThreadedComment |
A threaded comment.
|
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")
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Add(CellRange, String, String) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-spreadsheetcontrol-api-part1/CS/SpreadsheetControl/SpreadsheetActions/CellActions.cs#L476
Cell commentedCell = worksheet.Cells["A2"];
ThreadedComment commentA2 = worksheet.ThreadedComments.Add(commentedCell, author, author + ": \r\n" + "This is a comment");
See Also
ThreadedCommentCollection Interface