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)) \下面是一些测试代码。
if __name__ == \
xls = easyExcel(r'D:\\test.xls')
PNFILE = r'c:\\screenshot.bmp'
xls.addPicture('Sheet1', PNFILE, 20,20,1000,1000) xls.cpSheet('Sheet1')
xls.close()
xls.save()
(4)python调用短信猫控件,发短信
#! /usr/bin/env python #coding=gbk
import sys
import win32com.client
ocxname='ShouYan_SmsGate61.Smsgate' axocx=win32com.client.Dispatch(ocxname) axocx.CommPort=8#设置COM端口号
axocx.SmsService='+8613800100500'#设置短信服务号码 axocx.Settings='9600,n,8,1'#设置com端口速度 axocx.sn='loyin'
c=axocx.Connect(1)#连接短信猫或手机
print '连接情况',axocx.Link()
axocx.SendSms('python确实是很好的','15101021000',0)#发送短信

