Python 如何从COM客户端获取Excel单元格的值

Python 如何从COM客户端获取Excel单元格的值,python,excel,com,comtypes,Python,Excel,Com,Comtypes,现在,我无法使用以下代码从COM和Python读取的Excel单元格中检索值: from comtypes.client import CreateObject filename=r'testrap.xlsx' app = CreateObject("Excel.Application") app.Visible = True wb = app.Workbooks.Open(filename) worksheet = wb.sheets(1) for row in range(1,11):

现在,我无法使用以下代码从COM和Python读取的Excel单元格中检索值:

from comtypes.client import CreateObject
filename=r'testrap.xlsx'
app = CreateObject("Excel.Application")
app.Visible = True
wb = app.Workbooks.Open(filename)
worksheet = wb.sheets(1)

for row in range(1,11):
    data = worksheet.Cells(row,1).Value
    print(data)
我总是很紧张

comtypes.client.lazybind.NamedProperty object at 0x....
打印在屏幕上,而不是单元格的值

我做错了什么?

根据,使用索引表示法访问带有参数的属性<代码>工作表和
工作表.单元格
是带参数的属性,而不是方法。此外,
为。因此,这应该是可行的:

from comtypes.client import CreateObject
filename=r'testrap.xlsx'
app = CreateObject("Excel.Application")
app.Visible = True
wb = app.Workbooks.Open(filename)
worksheet = wb.Sheets[1]

for row in range(1,11):
    data = worksheet.Cells[row, 1].Value()
    print(data)
但Windows电脑上没有,因此无法测试此ATM