#修改excel表内第一个空格的内容为 'elan best' 并保存
>>> from openpyxl import Workbook
>>> from openpyxl import load_workbook>>> from openpyxl.writer.excel import ExcelWriter>>> wb = load_workbook ('C:\\Users\\elan\\Desktop\\python\\test.xlsx')>>> wb.sheetnames['Sheet1']
>>> ws = wb['Sheet1']
>>> ws.cell (1,1).value
1>>> ws.cell (1,1).value = '公务员职位表'
>>> ws.cell (1,1).value
'elan best'
>>> wb.save ('C:\\Users\\elan\\Desktop\\python\\test.xlsx')
######################################################################################
>>> wb = load_workbook ('C:\\Users\\elan\\Desktop\\python\\1.xlsx')
>>> sheet = wb.active#输出最大行数
>>> print(sheet.max_row)4#输出最大列数
>>> print(sheet.max_column)129#获取并打印出B4的值
>>> b4 = sheet['B4']
>>> print(f'({b4.column}, {b4.row}) is {b4.value}')(2, 4) is 1e74752a-176a-4d4e-a706-dd7822b0f95b#获取并打印出B4的值
>>> b4_too = sheet.cell(row=4, column=2)
>>> print(b4_too.value)1e74752a-176a-4d4e-a706-dd7822b0f95b#按行输出excel的数据
>>> for row in sheet.rows:
for cell in row: print(cell.value)
#按列输出excel的数据
>>> for column in sheet.columns:
for cell in column: print(cell.value)#打印第二行的excel数据
>>> for cell in list(sheet.rows)[2]:
print(cell.value)