![](/img/trans.png)
[英]Is there any method to get the number of rows and columns present in .xlsx sheet using openpyxl?
[英]Is it possible to get the number of rows with content present in excel sheet using openpyxl?
我尝试这样使用
sheet.get_highest_row()
但输出为104578
我的Excel工作表中只有3行。 我只需要选择Excel工作表中存在的行数
在Excel中打开文件,然后按Ctrl-End。 这将根据Excel选择最后一个单元格。 这可能是行104578中某处的空单元格。如果是这种情况,请在Excel中选择所有空行,然后删除并保存。 这应该更新最后一行。
要获得行数,只需从工作表对象获取属性max_row
:
rows = sheet.max_row
print(rows)
在您的情况下,它将打印3
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.