本文摘自php中文网,作者不言,侵删。
这篇文章主要介绍了关于Python利用openpyxl库遍历Sheet的实例,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下方法一,利用 sheet.iter_rows() 获取 Sheet1 表中的所有行,然后遍历
1 2 3 4 5 6 7 | 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 ---' )
|
1 2 3 4 5 | 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利用pickle模块完成增删改查等一些功能
以上就是Python利用openpyxl库遍历Sheet的实例的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Python中的特殊变量__name__有什么用?
Python语言是做什么
Python数据类型的区别
Python使用arrow库处理时间数据的示例详解
Python开发学习包括哪些内容
Python color怎么设置
Python中tornado同步与异步i/o实例代码讲解
Python怎么做大数据分析
Python docx 中文字体设置的操作方法
Python中range() 函数的使用介绍(附代码)
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » Python利用openpyxl库遍历Sheet的实例