Read the complete article on adding comments in Excel using Python
Last active
February 2, 2024 14:05
-
-
Save aspose-com-gists/a84c46e782e6befe28d8ab7ee34fbf38 to your computer and use it in GitHub Desktop.
Add Comments in Excel Worksheet using Python
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
# Instantiating a Workbook object | |
workbook = Workbook("workbook.xlsx") | |
# Obtaining the reference of the first worksheet by passing its sheet index | |
worksheet = workbook.getWorksheets().get(0) | |
# Adding a comment to "F5" cell | |
commentIndex = worksheet.getComments().add("F5") | |
# Accessing the newly added comment | |
comment = worksheet.getComments().get(commentIndex) | |
# Setting the comment note | |
comment.setNote("Hello Aspose!") | |
# Saving the Excel file | |
workbook.save("output.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
# Instantiating a Workbook object | |
workbook = Workbook("workbook.xlsx") | |
# Obtaining the reference of the first worksheet by passing its sheet index | |
worksheet = workbook.getWorksheets().get(0) | |
# Adding a comment to "F5" cell | |
commentIndex = worksheet.getComments().add("F5") | |
# Accessing the newly added comment | |
comment = worksheet.getComments().get(commentIndex) | |
# Setting the comment note | |
comment.setNote("Hello Aspose!") | |
# Setting the font size of a comment to 14 | |
comment.getFont().setSize(14) | |
# Setting the font of a comment to bold | |
comment.getFont().setBold(True) | |
# Setting the height of the font to 10 | |
comment.setHeightCM(10) | |
# Setting the width of the font to 2 | |
comment.setWidthCM(2) | |
# Saving the Excel file | |
workbook.save("output.xlsx") |
@rohitvishwakarma-sf
Please read our complete blog post that explains how to read, add, edit, and delete threaded comments in Excel using Python.
You can find the code here: https://gist.github.com/aspose-com-gists/1ca33b35d960d5e37753cdf314425c13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a note not commnet.
How to add comment ? the new excel threaded comments ?