We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Programatically creating ThreadedCommentAuthor to add a ThreadedComment

I am trying to create a way to programatically add threaded comments to a specific cell using the Comments.AddThreadedComment() method. However I do not know how to programatically create an instance of the ThreadedCommentAuthor class for the argument. It would be great to have some clarification about doing this. Thanks.

You may please try following sample code and provide feedback.

Workbook wb = new Workbook();
int i = wb.Worksheets.ThreadedCommentAuthors.Add("author 1", "user id 1", "provider id 1");
wb.Worksheets[0].Comments.AddThreadedComment("A1", "Hello 1", wb.Worksheets.ThreadedCommentAuthors[0]);
i = wb.Worksheets.ThreadedCommentAuthors.Add("author 2", "user id 2", "provider id 2");
wb.Worksheets[0].Comments.AddThreadedComment("A1", "Hello 2", wb.Worksheets.ThreadedCommentAuthors[1]);

Screenshot 2019-05-14 at 12.12.37 AM.jpg (104.5 KB)
Output.zip (7.8 KB)

Thank you very much. That was quite helpful in solving the issue.

@ahsaniqbalsidiqui one more question. I was wondering if there was a way to access the user id and provider id from within the workbook or otherwise programatically?

The Workbook.Worksheets.BuiltInDocumentProperties contains the Author name, but I wasn’t sure about the other two arguments to add ThreadedCommentAuthors. If you could provide some insight, that would be great. Thanks.

The Workbook.Worksheets.BuiltInDocumentProperties is not the same as ThreadedCommentAuthors. Each user in the thread has his own id which can be asked from the respective user. I am afraid there is no automated way to generate these strings i.e. Id and Provider. You may please use your own scheme while creating these strings for uniqueness and identity. It cannot be generated/obtained from a workbook.