python操作Excel
来源:互联网 发布:京东首届网络电影节 编辑:程序博客网 时间:2024/06/05 07:42
# encoding : utf-8 #设置编码方式import xlrd #导入xlrd模块#打开指定文件路径的excel文件xlsfile = r'D:\AutoPlan\apisnew.xls' book = xlrd.open_workbook(xlsfile) #获得excel的book对象#获取sheet对象,方法有2种:sheet_name=book.sheet_names()[0] #获得指定索引的sheet名字print sheet_namesheet1=book.sheet_by_name(sheet_name) #通过sheet名字来获取,当然如果你知道sheet名字了可以直接指定sheet0=book.sheet_by_index(0) #通过sheet索引获得sheet对象#获取行数和列数:nrows = sheet.nrows #行总数ncols = sheet.ncols #列总数#获得指定行、列的值,返回对象为一个值列表row_data = sheet.row_values(0) #获得第1行的数据列表col_data = sheet.col_values(0) #获得第一列的数据列表,然后就可以迭代里面的数据了#通过cell的位置坐标获得指定cell的值cell_value1 = sheet.cell_value(0,1) ##只有cell的值内容,如:http://xxx.xxx.xxx.xxx:8850/2/photos/square/print cell_value1cell_value2 = sheet.cell(0,1) ##除了cell值内容外还有附加属性,如:text:u'http://xxx.xxx.xxx.xxx:8850/2/photos/square/'print cell_value2
0 0
- Flask Excel python操作excel
- 使用python操作excel
- python 操作 excel
- python操作excel
- python操作excel
- python操作Excel word
- python操作Excel
- Python操作Excel
- python操作excel
- python 写Excel操作
- Python Excel操作
- python操作excel
- python 操作Excel
- python操作excel
- python操作excel
- Python操作Excel
- Python-操作Excel
- Python操作Excel
- 分治算法
- 数据类型转换的坑
- ReactNative-通过setState控制组件的更新和变化
- 三级-下拉菜单
- Extjs6开发环境搭建
- python操作Excel
- iOS APP内WiFi配置相关
- BZOJ 1224: [HNOI2002]彩票 搜索,上下界剪枝,前缀和优化
- UITableView代理方法解释
- Thinkphp搜索附带分页
- 缺少msvcr110.dll
- 题目1016:火星A+B
- python Sessions和Cookies区别
- spark向量矩阵的使用(scala)