1.打开和保存工作表
file_name = r"X:\temp\whip.xlsx"
wb = openpyxl.load_workbook(file_name)
sheet = wb.active
sheet.cell(1,1).value = "helloworld"
wb.save("temp.xlsx")
2.获取基础属性
获取行数列数
max_row = sheet.max_row
max_column = sheet.maxcolumn
根据字母返回列的数字
from openpyxl.utils import get_column_letter, column_index_from_string
# 根据列的数字返回字母
print(get_column_letter(2)) # B
# 根据字母返回列的数字
print(column_index_from_string('D')) # 4