python - Using pywin32 (XLWINGS) how do you read the text of an existing comment? -


i can set , delete comments in excel sheet unable (read)the contents of existing comment. xlwings doesn't have method need drop down com object.

import xlwings xw wb = xw.workbook.active() xw.range('a1').api.addcomment('some text') xw.range('a1').api.deletecomment() xw.range('a1').api.addcomment('more text') # sadness on best effort far comment_text = xw.range('a1').api.comment.shape.textframe.characters.text 

question: ... how read text of existing comment?
problem reading comment not writing it

do not disturb @ linked title how write excel comments using python? , answer showing reading. used example confusing shows passed comment returned string:

>>> sheet.range("a1").comment.text("hello world") u'hello world' 

comment.text method

returnvalue = instance.text(text, start, overwrite) 

parameters
text type: system.object optional object. text added.
start type: system.object optional object. character number added text placed. if argument omitted, existing text in comment deleted.
overwrite type: system.object optional object. true overwrite existing text. default value false (text inserted).
return value
type: system.string

as all parameter optional, text() return comment text.

>>> sheet.range("a1").comment.text() u'hello world' 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -