Python openpyxl 遍歷所有sheet 查找特定字符串的方法
更新時間:2018年12月10日 15:12:58 作者:lysaausb1
今天小編就為大家分享一篇Python openpyxl 遍歷所有sheet 查找特定字符串的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:
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 查找特定字符串就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Pytorch Tensor基本數(shù)學(xué)運算詳解
今天小編就為大家分享一篇Pytorch Tensor基本數(shù)學(xué)運算詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-12-12
在Python中使用swapCase()方法轉(zhuǎn)換大小寫的教程
這篇文章主要介紹了在Python中使用swapCase()方法轉(zhuǎn)換大小寫的教程,是Python入門中的基礎(chǔ)知識,需要的朋友可以參考下2015-05-05
Python爬蟲實現(xiàn)抓取京東店鋪信息及下載圖片功能示例
這篇文章主要介紹了Python爬蟲實現(xiàn)抓取京東店鋪信息及下載圖片功能,涉及Python頁面請求、響應(yīng)、解析等相關(guān)操作技巧,需要的朋友可以參考下2018-08-08
基于python OpenCV實現(xiàn)動態(tài)人臉檢測
這篇文章主要為大家詳細介紹了基于python OpenCV實現(xiàn)動態(tài)人臉檢測,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-05-05

