import openpyxl wb = openpyxl.load_workbook('example.xlsx') print(wb) <openpyxl.workbook.workbook.Workbook object at 0x000001979C39CC88>
import openpyxl wb = openpyxl.load_workbook('example.xlsx') '''获取当前活动工作表''' print(wb.get_active_sheet()) '''获取所有的工作表''' print(wb.get_sheet_names()) '''通过Sheet1 name获取到工作表单''' print(wb.get_sheet_by_name('Sheet1'))
wb = openpyxl.load_workbook('example.xlsx') sheet = wb.get_sheet_by_name('Sheet1') '''有了WS之后,就可以访问cell对象了''' cell = sheet['B1'] print(cell.value) print(cell.row) print(cell.column) print(cell.coordinate)
Apples
1
2
B1