I am new to stackoverflow and quite recently learned about basic Python. This is the first time I use openpyxl. I used to use xlrd and xlsxwriter, and I managed to make some useful programs. But now I need a .xlsx reader & writer.
There is a file that I need to read and edit with data already stored in the code. Suppose .xlsx has five columns with data: A, B, C, D, E. In column A, I have more than 1000 rows with data. In column D, I have 150 rows of data.
Basically, I want the program to find the last row with the data in this column (say, D). Then write the saved data variable in the next available row (last row + 1) in column D.
The problem is that I cannot use ws.get_highest_row() because it returns the row 1000 in column A.
Basically, for now this is all I have:
data = 'xxx' from openpyxl import load_workbook wb = load_workbook('book.xlsx', use_iterators=True) ws = wb.get_sheet_by_name('Sheet1') last_row = ws.get_highest_row()
Obviously this does not work at all. last_row returns 1000.
source share