跳至内容
Python 俱乐部
用户工具
登录
站点工具
搜索
工具
显示页面
修订记录
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
python-files:excel
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
====== Python 使用 xlrd 读取 Excel格式文件 ====== 使用 xlrd 能够很方便的读取 excel 文件内容, 而且这是个跨平台的库,能够在windows,linux/unix,等平台上面使用。 软件可以去这个地址[[http://www.lexicon.net/sjmachin/xlrd.htm]]下载。 ===== 简单例子 ===== <code python> import xlrd fname = "sample.xls" bk = xlrd.open_workbook(fname) shxrange = range(bk.nsheets) try: sh = bk.sheet_by_name("Sheet1") except: print "no sheet in %s named Sheet1" % fname return None nrows = sh.nrows ncols = sh.ncols print "nrows %d, ncols %d" % (nrows,ncols) cell_value = sh.cell_value(1,1) print cell_value row_list = [] for i in range(1,nrows): row_data = sh.row_values(i) row_list.append(row_data) </code> ===== xlrd 模块内容 ===== 详细的xlrd模块帮助在他的主页上[[http://www.lexicon.net/sjmachin/xlrd.html]] ===== excel 文件格式 ===== 如果想彻底研究excel的话,这边有讲解excel格式的文档: http://sc.openoffice.org/excelfileformat.pdf
python-files/excel.txt
· 最后更改: 2010/06/02 01:18 (外部编辑)
页面工具
显示页面
修订记录
反向链接
回到顶部