求高人指点pywintypes.com_error: (-2146827864, 'OLE error 0x800a01a8', None, None)

PGPgao 2012-01-07 04:04:24
遇到了下面的错误,不是每次都会出现,不知道原因,求高人指点
[exec] Traceback (most recent call last):
[exec] File "D:\WN_RBV28C00_SVN\script\makeres\excelCombine.py", line 216, in
[exec] mainEntry()
[exec] File "D:\WN_RBV28C00_SVN\script\makeres\excelCombine.py", line 198, in mainEntry
[exec] combine()
[exec] File "D:\WN_RBV28C00_SVN\script\makeres\excelCombine.py", line 182, in combine
[exec] combineExcel()
[exec] File "D:\WN_RBV28C00_SVN\script\makeres\excelCombine.py", line 152, in combineExcel
[exec] oneSheet.Cells(idxWriteRow,col).value = colValue
[exec] File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 172, in __call__
[exec] return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
[exec] pywintypes.com_error: (-2146827864, 'OLE error 0x800a01a8', None, None)

源码~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def combineExcel():
#combine to outexcel from inexcel

global strTime
strTime = str(excel.getTime())
global OutExcel
if OutExcel.find(":") == -1:
#set absolute path
OutExcel = rootPath.decode("GBK") + os.sep.decode("GBK") + OutExcel
#open excel for output
myExcel = excel.CExcel(OutExcel,OutExcel+strTime)
idxSheet = 0
for oneSheetName in SheetName.split(","):
oneSheet = None
try:
oneSheet = myExcel.xlBook.Worksheets(oneSheetName)
except Exception,data:
print ("Error:read excel [%s] sheet [%s] " %(OutExcel,oneSheetName))
continue
idxWriteRow = int(FirstLine.split(",")[idxSheet])
while 1:
#get line which begin to write
idxWriteRow = idxWriteRow + 1
if oneSheet.Cells(idxWriteRow,1).value is None \
and oneSheet.Cells(idxWriteRow,2).value is None\
and oneSheet.Cells(idxWriteRow,3).value is None\
and oneSheet.Cells(idxWriteRow,4).value is None:
#read over
break
for key0,dictSheet in dictExcel.items():
#get every excel
dictRow = dictSheet[oneSheetName]
for row,dictCol in dictRow.items():
#get every row
if dictCol[1] is None and dictCol[2] is None and dictCol[3] is None and dictCol[4] is None:
continue
if ProductLine == "" or isContainProduct(ProductType,dictCol[int(ProductLine.split(",")[idxSheet])]) == 0:
#filter product
if ProductType is None or ProductType == "":
#max column index is product line
MaxCol = int(ProductLine.split(",")[idxSheet])
else:
#max column index is product line - 1
MaxCol = int(ProductLine.split(",")[idxSheet]) - 1
for col,colValue in dictCol.items():
#get every column
if col > MaxCol:
break
#write output file
oneSheet.Cells(idxWriteRow,col).value = colValue
idxWriteRow = idxWriteRow + 1
idxSheet = idxSheet + 1
myExcel.close()
#temp file paste the output file
shutil.copy(OutExcel+strTime, OutExcel)
#delete temp file
try:
os.remove(OutExcel+strTime)
except:
print "remove temp file faild,but it is does not matter"
...全文
2109 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
iambic 2012-01-07
  • 打赏
  • 举报
回复
google OLE error 800a01a8
PGPgao 2012-01-07
  • 打赏
  • 举报
回复
估计是在执行到赋值的那句的时候
tskill excel了

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧