记录一下openpyxl一些舍弃的方法对应的新用法
1.一些舍弃的方法
舍弃方法 | 现用法 | 描述 |
---|---|---|
wb.get_sheet_names() | wb.sheetnames | 所有工作表 |
wb.get_sheet_by_name('Sheet1') | wb['Sheet1'] | 获取工作表 |
wb.get_active_sheet() | wb.active | 当前活动表 |
sheet.get_highest_row() | sheet.max_row | 获取最大行 |
sheet.get_highest_column() | sheet.max_column | 获取最大列 |
wb.remove_sheet(sheet) | wb.remove(sheet) | 删除工作表 |
2.一些需要修改的导入
openpyxl 2.4 版本之后 get_column_letter
和 get_column_letter
方法从 openpyxl.cell
迁入 openpyxl.utils
try:
from openpyxl.cell import get_column_letter, column_index_from_string
except ImportError:
from openpyxl.utils import get_column_letter, column_index_from_string