python快速上手 + openpyxl 模块方法报错AttributeError: 'Worksheet' object has no attribute 'get_highest_row'

在学习《python编程快速上手》第十二章时,为了获取表格最大size(即最大高度和最大宽度)时,调用了Worksheet对象的get_highest_column()和get_highest_row()时,报错:

AttributeError: 'Worksheet' object has no attribute 'get_highest_row'

明显属性不存在,但是书上不可能写不存在的属性方法片咱们,唯一的可能就是由于使用版本不一致导致的;

上网一查,get_highest_row()和get_highest_row()在最新版的openpyxl模块中已经被删除了,那怎么获取我们想要的数据呢?

新模块中方法获取改为获取属性的值,直接用Worksheet对象的两个新属性,max_row和max_column获取

AttributeError: 'Worksheet' object has no attribute 'get_column_letter'

函数get_column_letter和column_index_from_string已被重定位到Openpyxl版本2.4 openpyxl.cell中openpyxl.utils。

目前接口在: from openpyxl.utils import get_column_letter

猜你喜欢

转载自blog.csdn.net/huofuman960209/article/details/86703776