[Python.NET] Indexer not working on Interop
Phat Loc
phat.loc at gmail.com
Mon Mar 19 16:50:31 EDT 2018
Hi All,
I was expecting the code below to work. Basically I casting a
System.__ComObject into a Range Interface (
https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range_members(v=office.14).aspx).
There should be an indexer but I can't seem to get it to work?
Thanks,
Phat
from PyExcel import PyAddin
import Microsoft.Office.Interop.Excel as Excel
app = Excel._Application(PyAddin.CurrentInstance.ExcelApp)
selection = Excel.Range(app.Selection)
In [5]: selection[1,1]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-bb1b652c6740> in <module>()
----> 1 selection[1,1]
TypeError: 'Range' object is not subscriptable
In [6]: selection.Cells[1,1]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-f8b14ac4d116> in <module>()
----> 1 selection.Cells[1,1]
TypeError: unindexable object
In [7]: selection.Cells(1,1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-e8b900b98026> in <module>()
----> 1 selection.Cells(1,1)
TypeError: object is not callable
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20180319/d595bd82/attachment-0001.html>
More information about the PythonDotNet
mailing list