Python 操作excel,python操作excel,首先安装python2.
Python 操作excel,python操作excel,首先安装python2.
首先安装python2.5,然后下载pywin32软件包(提供win com支持),大多数微软产品都作为com server,所以需要下这个包用作comclient与微软的产品通信
from win32com.client import constants, Dispatchclass EasyExcel: def __init__(self, filename=None): self.xlApp = Dispatch('Excel.Application') if filename: self.filename = filename self.xlBook = self.xlApp.Workbooks.Open(filename) else: print "please input the filename" def close(self): self.xlBook.Close(SaveChanges=0) del self.xlApp def getCell(self, sheet, row, col): "Get value of one cell" sht = self.xlBook.Worksheets(sheet) return sht.Cells(row, col).Value def getRange(self, sheet, row1, col1, row2, col2): "return a 2d array (i.e. tuple of tuples)" sht = self.xlApp.Worksheets(sheet) return sht.Range(sht.Cells(row1, col1), sht.Cells(row2, col2)).Value#该片段来自于http://byrx.net
相关内容
- 文本编辑器。学习五天Python,新手第一次发.,,#!/usr/bi
- phpdisk 盲注脚本,phpdisk注脚本,#===========
- 深度优先遍历嵌套容器,深度历嵌套容器,一个小花招,
- python创建和删除目录的代码,python创建代码,#----------
- python Flask框架下获取用户的IP地址的范例代码,pythonf
- 多线程获取腾讯新闻,多线程获取腾讯,# -*- coding
- ASCII转换成十六进制,ascii转换十六进制,#!/usr/bin/e
- python对指定目录下的文件进行批量重命名,python重命名
- Python 分割文件以及合并文件,python分割,#!/usr/bin/p
- python编写的超简单端口转发程序,python编写端口转发
评论关闭