Add comment to excel using python win32

柔情痞子 提交于 2019-12-01 13:16:23

问题


I am trying to add new comment to excel with python, using win32.

import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
wb = excel.Workbooks.Open(r'C:\...\.xlsx')
ws = wb.Worksheets('sheet1')
ws.Cells(1,1).AddComment = "comment"

--> object has no attribute 'AddComment'

Do you know how to add new comment to excel using win32? Thank you!


回答1:


Add comment is a method not a property.

ws = wb.Worksheets('sheet1')
ws.Cells(1,1).AddComment("comment")

Just read the the documentation in the MSDN.



来源:https://stackoverflow.com/questions/47222373/add-comment-to-excel-using-python-win32

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!