Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-kb/c4825ef99a5b7273a1c426dc15bc7f88 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-kb/c4825ef99a5b7273a1c426dc15bc7f88 to your computer and use it in GitHub Desktop.
Add Threaded Comments in Excel using Python. For details: https://kb.aspose.com/cells/python/add-threaded-comments-in-excel-using-python/
import aspose.cells as ac
def main():
# Apply Aspose.Cells license
license = ac.License()
license.set_license("license.lic")
# Create a workbook and get the first worksheet
workbook = ac.Workbook()
sheet = workbook.worksheets[0]
# Add a value to cell A1
sheet.cells.get("A1").put_value("Hello")
# Create an author for threaded comments
authors = workbook.worksheets.threaded_comment_authors
author_index = authors.add("Aspose Test", "", "")
author = authors[author_index]
# Add a threaded comment to cell A1
sheet.comments.add_threaded_comment("A1", "Test Threaded Comment", author)
# Save the Excel file
workbook.save("AddThreadedComments_out.xlsx")
print("Threaded comment added successfully.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment