Thursday, 15 September 2011

pywintypes.com_error in Python during Excel import -



pywintypes.com_error in Python during Excel import -

i error on running module gasprop. not understand error means , how prepare it:

import gasprop traceback (most recent phone call last): file "<stdin>", line 1, in <module> file "gasprop.py", line 13, in <module> sheet = wb.sheets("input1") file "c:\python27\lib\site-packages\win32com\gen_py\00020813-0000-0000-c000-000000000046x0x1x6\sheets.py", line 113, in __call__ ret = self._oleobj_.invoketypes(0, lcid, 2, (9, 0), ((12, 1),),index pywintypes.com_error: (-2147352567, 'exception occurred.', (0, none, none, none, 0, -2147352565), none)

and here module gasprop:

import win32com.client, os xl = win32com.client.gencache.ensuredispatch("excel.application") thisdir = os.getcwd() wb = xl.workbooks.open(thisdir+"/input1.xlsx") sheet = wb.sheets("input1") ...... def megaverify(self): listtr,listp=[],[] in range(16): tr=float(sheet.range("d"+str(5+i)).value) p=float(sheet.range("c"+str(5+i)).value) listtr.append(tr);listp.append(p) homecoming tr, p

you can utilize teсhnique more info error:

import win32api e_msg = win32api.formatmessage(-2147352565) print e_msg.decode('cp1251')

the message means excel file not have sheet name "input1". can rename it.

python excel operating-system

No comments:

Post a Comment