Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/1ca33b35d960d5e37753cdf314425c13 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/1ca33b35d960d5e37753cdf314425c13 to your computer and use it in GitHub Desktop.
# This code example demonstrates how to add threaded comments in an Excel worksheet
# Create an instance of the Workbook class
workbook = Workbook();
# Add an Author
authorIndex = workbook.worksheets.threaded_comment_authors.add("Aspose Test", "", "");
author = workbook.worksheets.threaded_comment_authors[authorIndex];
# Add Threaded Comment
workbook.worksheets[0].comments.add_threaded_comment("A1", "Test Threaded Comment", author);
# Save the output file
workbook.save("D:\\Files\\AddThreadedComments_out.xlsx");
# This code example demonstrates how to delete threaded comments in an Excel worksheet
# Load an existing Excel file
workbook = Workbook("D:\\Files\\AddThreadedComments_out.xlsx")
# Get all the comments
comments = workbook.worksheets[0].comments
# Remove Comments
comments.remove_at("A1")
# Save the output file
workbook.save("D:\\Files\\DeleteThreadedComments.xlsx");
# This code example demonstrates how to edit threaded comments in an Excel worksheet
# Load an existing Excel file
workbook = Workbook("D:\\Files\\AddThreadedComments_out.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0];
# Get Threaded Comments for a specific cell
threadedComments = worksheet.comments.get_threaded_comments("A1");
comment = threadedComments[0]
# Update the comment note
comment.notes = "Updated Comment";
# Save the output file
workbook.save("D:\\Files\\EditThreadedComments.xlsx");
# This code example demonstrates how to read threaded comments for a specified cell in an Excel worksheet
# Load an existing Excel file
workbook = Workbook("D:\\Files\\AddThreadedComments_out.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0];
# Get Threaded Comments for a specific cell
threadedComments = worksheet.comments.get_threaded_comments("A1");
# Read the threaded comments
for comment in threadedComments:
print("Author Name: " + comment.author.name)
print("Threaded comment Notes:" + comment.notes)
# This code example demonstrates how to read all threaded comments from an Excel worksheet
# Load an existing Excel file
workbook = Workbook("D:\\Files\\MultipleThreadedComments_out.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0];
# Get all the comments
comments = worksheet.comments
# Read all the threaded comments
for comment in comments:
# Process threaded comments
for threadedComment in comment.threaded_comments:
print("Author Name: " + threadedComment.author.name)
print("Threaded comment author User Id: " + threadedComment.author.user_id)
print("Threaded comment author ProviderId:" + threadedComment.author.provider_id)
print("Threaded comment Notes:" + threadedComment.notes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment