Learn how to Read, Add, and Edit Threaded Comments in Excel using C#
Last active
May 21, 2024 03:33
-
-
Save aspose-com-gists/4893b4828cedeee19b0f54f65c0f184d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code example demonstrates how to add threaded comments in an Excel worksheet | |
// Create an instance of the Workbook class | |
Workbook workbook = new Workbook(); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Add an Author | |
var authorIndex = workbook.Worksheets.ThreadedCommentAuthors.Add("Aspose Test", "", ""); | |
var author = workbook.Worksheets.ThreadedCommentAuthors[authorIndex]; | |
// Add Threaded Comment | |
worksheet.Comments.AddThreadedComment("A1", "Test Threaded Comment", author); | |
// Save the output file | |
workbook.Save("AddThreadedComments_out.xlsx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code example demonstrates how to delete threaded comments in an Excel worksheet | |
// Load an existing Excel file | |
Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); | |
// Get all the comments | |
var comments = workbook.Worksheets[0].Comments; | |
// Remove Comments | |
comments.RemoveAt("A1"); | |
// Save the output file | |
workbook.Save("DeleteThreadedComments.xlsx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code example demonstrates how to edit threaded comments in an Excel worksheet | |
// Load an existing Excel file | |
Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Get Threaded Comments for a specific cell | |
var threadedComments = worksheet.Comments.GetThreadedComments("A1"); | |
var comment = threadedComments[0]; | |
// Update the comment note | |
comment.Notes = "Updated Comment"; | |
// Save the output file | |
workbook.Save("EditThreadedComments.xlsx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code example demonstrates how to read threaded comments for a specified cell in an Excel worksheet | |
// Load an existing Excel file | |
Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Get Threaded Comments for a specific cell | |
var threadedComments = worksheet.Comments.GetThreadedComments("A1"); | |
// Read the threaded comments | |
foreach (var comment in threadedComments) | |
{ | |
Console.WriteLine("Author Name: " + comment.Author.Name); | |
Console.WriteLine("Threaded comment Notes:" + comment.Notes); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code example demonstrates how to read threaded comments for a specified cell in an Excel worksheet | |
// Load an existing Excel file | |
Workbook workbook = new Workbook("AddThreadedComments_out.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Get all the comments | |
var comments = worksheet.Comments; | |
// Read all the threaded comments | |
foreach (var comment in comments) | |
{ | |
// Process threaded comments | |
foreach (var threadedComment in comment.ThreadedComments) | |
{ | |
Console.WriteLine("Author Name: " + threadedComment.Author.Name); | |
Console.WriteLine("Threaded comment author User Id: " + threadedComment.Author.UserId); | |
Console.WriteLine("Threaded comment author ProviderId:" + threadedComment.Author.ProviderId); | |
Console.WriteLine("Threaded comment Notes:" + threadedComment.Notes); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment