简体   繁体   中英

How do I find the max row in Openpyxl

max_row函数返回的值高于应有的值(其中具有值的最大行是第7行,但max_row返回10),如果我尝试遍历一列以查找其中没有任何内容的第一行,获得与max_row相同的值。

This would be easier to understand if you work with excel on java. Excel cell have properties which define them as active or inactive. If you enter a value to a cell then delete the value, the cell still remains active. max_row returns the row number of the last active cell, hence you get 10 rather than 7 even if the sheet now have data only till row 7 it may once have data till 10.

Manually you can clear the cell (Editing->Clear->Clear All) for the cell in excel making it inactive again. Not sure how to do the same via code in python.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM