【问题标题】:AttributeError: 'Worksheet' object has no attribute 'get_highest_row' in openpyxl(python)AttributeError:“工作表”对象在 openpyxl(python)中没有属性“get_highest_row”
【发布时间】:2019-10-22 12:58:17
【问题描述】:

我在尝试获取 excel 表中的行数时遇到属性错误。我在 python 中使用了 openpyxl 库

这是使用的python 3x版本和openpyxl最新版本

导入openpyxl 从 openpyxl 导入 load_workbook wb=load_workbook("automation-book-example.xlsx")

获取表格

ws=wb.get_sheet_by_name('Sheet1')

打印(ws.get_highest_row())

Traceback(最近一次调用最后一次): 文件“C:\Users\kamaraj\Desktop\python-excel\openpyxl\automation-book-example.py”,第 9 行,在 打印(ws.get_highest_row()) AttributeError:“工作表”对象没有属性“get_highest_row”

【问题讨论】:

    标签: python python-3.x openpyxl


    【解决方案1】:

    get_highest_row() 方法已弃用,您可以通过调用工作表的 max_row 或 max_column 属性来获取最高行或最高列。

    ws=wb.get_sheet_by_name('Sheet1')
    
    print(ws.max_row)
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-12
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 2018-08-13
    相关资源
    最近更新 更多