参考网页: https://www.cnblogs.com/yhms/p/10138513.html https://www.jb51.net/article/117515.htm import os from openpyxl import load_workbook def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. # Press the green button in the gutter to run the script. if __name__ == '__main__': print_hi('PyCharm') os.chdir("D:\Images\python_excel_test") workbook1 = load_workbook('test_case.xlsx') sheet = workbook1['test_data'] data = sheet.cell(3, 2).value print(data) for row in sheet.rows: for cell in row: print(cell.value) for column in sheet.columns: for cell in column: print(cell.value)
本文介绍了如何使用Python的openpyxl库来加载工作簿,提取单元格数据,并演示了遍历行和列的方法。适合初学者了解Excel文件操作的基本步骤。
783

被折叠的 条评论
为什么被折叠?



