Python利用openpyxl库遍历Sheet的方法
2017-02-11 00:27
507 查看
方法一,利用 sheet.iter_rows() 获取 Sheet1 表中的所有行,然后遍历
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 表中最大行和列的值,然后遍历
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利用前序和中序遍历结果重建二叉树的方法
- Python openpyxl 遍历所有sheet 查找特定字符串
- Python利用前序和中序遍历结果重建二叉树的方法
- Python利用递归和walk()遍历目录文件的方法示例
- python 遍历文件(夹) 的os.walk方法
- ArrayList利用迭代器Iterator遍历方法实现数据(新闻)的删除、添加、显示功能例子
- 利用非递归方法实现二叉树的层次遍历
- 利用swig实现python调用C/C++的方法
- 浅析遍历子进程方法(利用list_for_each)
- 利用python正则表达式 遍历目录后取出目录树中的所有特定目录
- python ── 遍历dict的两种方法比较
- Python遍历文件夹的两种方法比较
- Python遍历文件夹的两种方法比较
- 遍历python字典几种方法
- [python][计算方法]利用无穷级数计算幂运算(开根号)
- Python遍历目录文件的两种方法
- 遍历python字典几种方法
- 利用在带有游标的过程中使用 WHILE的方法取出各个门店零售的销售数据(遍历多表取出数字)
- 遍历python字典几种方法