1
import win32com.client as win32
excelApp = win32.Dispatch("Excel.Application")
wb = excel.Workbooks.Add()
excel.Visible = True
ws = wb.Worksheets("Planilha1")
ws.Cells(1,1).Value=str('=RTD("RTDTrading.RTDServer";; "SIMH3_B_0"; "DAT")')
---------------------------------------------------------------------------
com_error                                 Traceback (most recent call last)
<ipython-input-23-dc3fa0e565b5> in <module>
      4 excel.Visible = True
      5 ws = wb.Worksheets("Planilha1")
----> 6 ws.Cells(1,1).Value=str('=RTD("RTDTrading.RTDServer";; "SIMH3_B_0"; "DAT")')

~\anaconda3\lib\site-packages\win32com\client\__init__.py in __setattr__(self, attr, value)
    480                 except KeyError:
    481                         raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
--> 482                 self._oleobj_.Invoke(*(args + (value,) + defArgs))
    483         def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None):
    484                 return _get_good_single_object_(obj, obUserName, resultCLSID)

com_error: (-2147352567, 'Exceção.', (0, None, None, None, 0, -2146827284), None)

这个想法是在excel中编写这个公式,然后读取数据。有没有人有任何解决方案?谢谢你。

4

0 回答 0