Python中openpyxl如何遍历所有sheet查找特定字符串-创新互联
小编给大家分享一下Python中openpyxl如何遍历所有sheet查找特定字符串,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
创新互联建站主营辽阳县网站建设的网络公司,主营网站建设方案,成都App定制开发,辽阳县h5重庆小程序开发搭建,辽阳县网站营销推广欢迎辽阳县等地区企业咨询如下所示:
from openpyxl import workbook from openpyxl import load_workbook from openpyxl import worksheet def find_false_in_sheet(sheet): for column in sheet.iter_cols(): for cell2 in column: if cell2.value is not None: # print cell2.value # print type(cell2.value) info2 = cell2.value.find('false') if info2 == 0: print cell2 print cell2.value def find_false_in_xlsx(file_name): print file_name wb = load_workbook(file_name) all_sheets = wb.get_sheet_names() print(all_sheets) for i in range(len(all_sheets)): sheet = wb.get_sheet_by_name(all_sheets[i]) print (sheet.title + ': max_row: ' + str(sheet.max_row) + ' max_column: ' + str(sheet.max_column)) find_false_in_sheet(sheet) # start find_false_in_xlsx("test.xlsx") # for row in sheet.iter_rows(): # for cell in row: # if cell.value is not None: # info = cell.value.find('BB') # if info == 0: # print cell.value
以上是“Python中openpyxl如何遍历所有sheet查找特定字符串”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!
网页题目:Python中openpyxl如何遍历所有sheet查找特定字符串-创新互联
网站链接:http://azwzsj.com/article/hojjc.html