Telerik blogs
DotNetT2 Light_1200x303

Take a look at how to implement comments in your RadSpreadProcessing worksheet.

In R2 2022 we have introduced support for comments in RadSpreadProcessing. This functionality allows you to add a personalized comment on any cell. The comment has a specific author and can have replies from other people as well. Our API provides you with the ability to easily interact with the comments in the code behind.

You can add, remove or edit the comments via the Comments collection of the Worksheet. The collection exposes several methods that allow the execution of the above operations. Here is an example that shows how you can create a new Workbook, add a comment, and export the file. Some data is added to the cells as well. 

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets.Add();

CellIndex c3Index = new CellIndex(2, 2);
worksheet.Cells[c3Index].SetValue("Example here");

string author = "John Doe"; 
string commentText = "Some Data Changed by the author.";

worksheet.Comments.Add(c3Index, author, commentText, DateTime.Now);

You can see the result when the workbook is exported:

comment showing John Doe, timestamp, and 'Some data changed by author'

How about if you want to open an existing workbook, search through the comments and post a reply? This is possible as well and is demonstrated in the next example.

XlsxFormatProvider provider = new XlsxFormatProvider();
string pathToFile = @"..\..\..\FileWithCommnets.xlsx";
Workbook workbook = provider.Import(File.ReadAllBytes(pathToFile));
Worksheet worksheet = workbook.Worksheets[0];

foreach (var comment in worksheet.Comments)
    if (comment.Author == "John Doe" && comment.CreationDate > DateTime.Now.AddDays(-20))
        comment.AddReply("Editor", "Changes after today will not take effect as the final version is now released", DateTime.Now);

File.WriteAllBytes(@"..\..\..\modified.xlsx", provider.Export(workbook));

We can see the reply in the modified file:

Comment reply shows Editor responding to John Doe, timestamp and message 'Changes after today will not take effect as the final version is now released'


In addition, you can mark the conversation as resolved. This way no more replies can be added from the UI until the conversation is reopened. 

comment.IsResolved = true;

comment thread resolved - grayed out with options to reopen or delete thread

The SpreadsheetComment instance contains a Replies collection which allows you to manipulate the replies (Clear, Remove, even Copy specific replies). For example, you can access a specific reply and change its contents. 

var comment = worksheet.Comments.First();
var reply = comment.Replies.First();
reply.Text = "Please add more information about this.";

If you are curious to test this functionality yourself or you want to use it in your application, you can check our documentation for more examples and the full list of the capabilities: SpreadProcessing Comments.

Try It and Share Your Feedback

No matter if you are already familiar with Telerik Document Processing or will meet the libraries for the first time, hurry up and get the latest bits so you can take advantage of the different document management possibilities they provide:

Download a Free Trial

And I am sure I have told you many times that your input is valuable. We do listen. So, do not be shy and drop us a line to share your feedback in the comments section below or directly in our Document Processing Libraries Feedback Portal


About the Author

Dimitar Karamfilov

Dimitar Karamfilov is a Support Officer in the UI for WinForms team. He joined Telerik after graduating from the Telerik Academy in 2013. Apart from work he likes outdoor activities and reading philosophy literature.

Related Posts


Comments are disabled in preview mode.