我有一个关于 excel 的 win32com 绑定的问题。我设置了早期绑定并遵循了 O'Reilly 的“Win32 上的 Python 编程”一书中的一些示例。
以下代码工作正常:
book2.xlApp.Worksheets('Sheet1').Cells(1,1).Font.ColorIndex = 1
book2.xlApp.Worksheets('Sheet1').Cells(1,1).Font.ColorIndex = 2
它根据数字改变整个单元格的字体颜色。但是,这不起作用:
book2.xlApp.Worksheets('Sheet1').Cells(1,1).Characters(start,length).Font.ColorIndex = 1
我收到以下回调:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
AttributeError: Characters instance has no __call__ method
但是在 Excels VBA 中,代码可以工作。谁能指出我的解决方案?我真的需要在 excel 单元格中更改部分字符串。
非常感谢。