圆月山庄资源网 Design By www.vgjia.com

如下所示:

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,字符串

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com