python操作excel 批量发送工资信息
来源:互联网 发布:mac pages如何保存 编辑:程序博客网 时间:2024/05/16 17:07
#encoding:gbkimport sysreload(sys)sys.setdefaultencoding( "gbk" )import xlrdimport xlwtimport smtplib import stringimport osfrom email.mime.text import MIMEText mail_host="smtp.163.com" mail_user="ccc" mail_pass="cccpwd"mail_postfix="163.com" def send_mail(to_list,sub,content): me="hello"+"<"+mail_user+"@"+mail_postfix+">" msg = MIMEText(content,_subtype='plain',_charset='gb2312') msg['Subject'] = sub msg['From'] = me msg['To'] = to_listtry: server = smtplib.SMTP() server.connect(mail_host) server.login(mail_user,mail_pass) server.sendmail(me, to_list, msg.as_string()) server.close() print "".join(content)return True except Exception, e: print "exception ......\r"print str(e) return False def list_2_string(lst ):ret = ""for x in lst:if type(x) is not string:ret += str(x)else:ret += xreturn retdef vonvert(a,b):return ord(a) - ord(b)class Excel():def do_work(self, inEfile, outfile):rfile = xlrd.open_workbook(inEfile)table = rfile.sheet_by_index(0x01)table.row_values(0x00)table.col_values(0x00)nrows = table.nrowsncols = table.ncolscollist = []collist.append(0x00)collist.append(0x01)collist.append(0x02)collist.append(0x03)collist.append(0x04)collist.append(0x05)collist.append(0x06)collist.append(0x07)sfile = open("result.txt",'w')colmail = 7tlist = []for x in collist:tlist.append(table.cell(0,x).value)for x in tlist:print xfor idx in range(2,7):mail = str(table.cell(idx,colmail).value)content = []for x in range(0,6):content.append(table.cell(idx,x).value)msg = ""for y in range(len(content)):msg += str(tlist[y])msg += " : "msg += str(content[y])msg += "\n"sndmsg_ok = "send ok : " + mail + "," + msgsndmsg_bad = "send failed : " + mail + "," + msgif send_mail(mail,"salary",msg):print sndmsg_oksfile.write(sndmsg_ok + '\r')else:print sndmsg_badsfile.write(sndmsg_bad + '\r')sfile.close()if __name__ == "__main__":t = Excel()t.do_work("h:\\test.xls","test")
test.xls内容如下
0 0
- python操作excel 批量发送工资信息
- 使用python对txt,excel批量操作
- python+shell 批量获取服务器信息并且生成excel表
- 工资读取excel表格发送工具
- Qt批量操作Excel
- Python 批量发送邮件脚本
- 利用Excel批量快速发送电子邮件
- python ssh批量操作
- python+批量肉鸡操作
- 【详解】【记录】Python写Excel预约信息表并发送邮件
- Flask Excel python操作excel
- Python批量操作文件,批量合并
- kafka-python批量发送数据的方法
- Python学习记录-----批量发送post请求
- Python学习记录-----批量发送post请求
- 使用python操作excel
- python 操作 excel
- python操作excel
- 基于 GTK+ 和 X 的 GUI 在嵌入式Linux 下的应用
- synchronized使用
- django+python 操作数据库
- JavaScript程序设计之常用内置对象
- LRU Cache
- python操作excel 批量发送工资信息
- ubuntu 13.10 搭建 嵌入式 debian 交叉编译工具
- Camera显示之Framework层设置显示窗口
- MFC笔记1:对话框学习
- 开发者在美国市场提升应用安装量的策略
- redmine通过https远程连接svn
- 可并堆——左偏树 Leftist Heap
- iMatrix平台新版本6.0.0.Dev发布了,大家快来看一看啦!
- 远程登录补丁