How to find the last row in a column using a regular openpyxl workbook?

I use openpyxl to check data across all lines that have "Default" in it. But for this I need to know how many lines there are.

I know there is a way to do this if I use the Iterable workbook mode, but I also add a new sheet to the workbook and in iterative mode, which is not possible.

+4
source share
1 answer

ws.max_row will give you the number of lines per sheet.

Starting with openpyxl 2.4, you can also access individual rows and columns and use their length to answer the question.

len(ws['A'])

Although it is worth noting that Excel uses for checking data for a single column 1:1048576.

+17

Source: https://habr.com/ru/post/1614588/


All Articles