python win32com对EXCEL操作中的问题

定义了一个类
class easyExcel:

def __init__(self, filename=None):
    self.xlApp = win32com.client.Dispatch('Excel.Application')
    if filename:
        self.filename = filename
        self.xlBook = self.xlApp.Workbooks.Open(filename)
    else:
        self.xlBook = self.xlApp.Workbooks.Add()
        self.filename = ''

def save(self, newfilename=None):
    if newfilename:
        self.filename = newfilename
        self.xlBook.SaveAs(newfilename)
    else:
        self.xlBook.Save()

def close(self):
    self.xlBook.Close(SaveChanges=0)
    del self.xlApp

def getCell(self, sheet, row, col):
    sht = self.xlBook.Worksheets(sheet)
    return sht.Cells(row, col).Value

def setCell(self, sheet, row, col, value):
    sht = self.xlBook.Worksheets(sheet)
    sht.Cells(row, col).Value= value

def getRange(self, sheet, row1, col1, row2, col2):
    sht = self.xlBook.Worksheets(sheet)
    return sht.Range(sht.Cells(row1, col1), sht.Cells(row2, col2)).Value

def addPicture(self, sheet, pictureName, Left, Top, Width, Height):
    sht = self.xlBook.Worksheets(sheet)
    sht.Shapes.AddPicture(pictureName, 1, 1, Left, Top, Width, Height)

def cpSheet(self, before):
    shts = self.xlBook.Worksheets
    shts(1).Copy(None,shts(1))

使用其中的setCell函数
lhwexcele.setCell('sheet1',0,0,'xkmc')
总是会提示
AttributeError: 'NoneType' object has no attribute 'Value'

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^