python模块win32com用法详解

2026/1/17 22:48:12

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)#发送短信


python模块win32com用法详解.doc 将本文的Word文档下载到电脑
搜索更多关于: python模块win32com用法详解 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219