使用python win32向Excel添加注释 [英] Add comment to excel using python win32

查看:178
本文介绍了使用python win32向Excel添加注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Win32在python中为Excel添加新注释。

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"

->对象没有属性'AddComment'

--> object has no attribute 'AddComment'

您知道如何使用Win32向Excel添加新注释吗?
谢谢!

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

推荐答案

添加注释不是方法,而是属性。

Add comment is a method not a property.

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

只需阅读 MSDN中的文档

这篇关于使用python win32向Excel添加注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆