Python利用openpyxl库遍历Sheet的实例
2018-05-03 15:26
976 查看
方法一,利用 sheet.iter_rows() 获取 Sheet1 表中的所有行,然后遍历
import openpyxl wb = openpyxl.load_workbook('example.xlsx') sheet = wb.get_sheet_by_name('Sheet1') for row in sheet.iter_rows(): for cell in row: print(cell.coordinate, cell.value) print('--- END OF ROW ---')
sheet = wb.get_sheet_by_name('Sheet1') for rowOfCellObjects in sheet['A1':'C3']: for cellObj in rowOfCellObjects: print(cellObj.coordinate, cellObj.value) print('--- END OF ROW ---')
方法二,利用 sheet.max_row sheet.max_colum 获取 Sheet1 表中最大行和列的值,然后遍历
以上这篇Python利用openpyxl库遍历Sheet的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- Python利用openpyxl库遍历Sheet的方法
- Python openpyxl 遍历所有sheet 查找特定字符串
- python实现的二叉树定义与遍历算法实例
- 利用python的第三方openpyxl模块做Appium数据驱动测试
- 利用Python爬取微博数据生成词云图片实例代码
- 用python操作excel的强大工具:openpyxl(附上实例脚本)
- python利用hook技术破解https的实例代码
- Python遍历目录的4种方法实例介绍
- Python 遍历子文件和所有子文件夹的代码实例
- [转载] python利用psutil遍历进程名字和exe所在目录
- 利用python获得时间的实例说明
- 利用PYTHON全自动生成分析报告实例
- python脚本实例002- 利用requests库实现应用登录
- C#利用反射,遍历获得一个类的所有属性名,以及该类的实例的所有属性的值
- 利用python爬取散文网的文章实例教程
- Python利用SVM进行实例建模
- python-利用pyaudio进行声音录制及简单实例代码分享
- 利用Python实现Windows下的鼠标键盘模拟的实例代码
- python3:利用socket建立的一个简单的聊天client端和server端实例
- python利用装饰器进行运算的实例分析