以下是 Python 代码实现:

import openpyxl

# 打开工作簿
wb = openpyxl.load_workbook('example.xlsx')

# 遍历每个工作表
for ws in wb.worksheets:
    # 如果不是当前工作表
    if ws != wb.active:
        # 遍历每行
        for row in ws.iter_rows():
            # 遍历每个单元格
            for cell in row:
                # 如果单元格中包含'软件工程'
                if '软件工程' in str(cell.value):
                    # 复制整行到当前工作表
                    new_row = [c.value for c in row]
                    wb.active.append(new_row)
                    break

# 保存工作簿
wb.save('example.xlsx')
Python 循环遍历 Excel 工作簿,查找并复制包含'软件工程'的单元格所在行

原文地址: http://www.cveoy.top/t/topic/l47e 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录