This content originally appeared on Telerik Blogs and was authored by Dimitar Karamfilov
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");
worksheet.Cells[c3Index].SetIsWrapped(true);
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:
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:
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;
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:
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
This content originally appeared on Telerik Blogs and was authored by Dimitar Karamfilov
Dimitar Karamfilov | Sciencx (2022-07-18T07:22:03+00:00) Comments Now Supported in RadSpreadProcessing. Retrieved from https://www.scien.cx/2022/07/18/comments-now-supported-in-radspreadprocessing/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.