Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does my openpyxl load only pull one cell in worksheet

I have this openpyxl intent on reading rows in an XLSX document.

But for some reason it is only reading the value in cell A1, then finishing.

What am I missing?

from openpyxl import load_workbook

Dutch = load_workbook(filename='languages/READY-Language Translation-- August (SOS) Dutch_dut_Compared_Results.xlsx', read_only=True)
Dws = Dutch.get_sheet_by_name(name='Ouput')

for row in Dws.iter_rows():
    for cell in row:
        print(cell.value)
like image 862
arcee123 Avatar asked Oct 25 '25 00:10

arcee123


1 Answers

If you load your workbook in read mode, and openpyxl is not reading the sheet as expected, say A1:A1, you can reset the max row and col with ws.reset_dimensions().

Documentaion here

Example:

from openpyxl import load_workbook

wb = load_workbook(filename='languages/READY-Language Translation-- August (SOS) Dutch_dut_Compared_Results.xlsx', read_only=True)
ws = wb['Ouput']
ws.reset_dimensions()

for row in ws.rows:
    for cell in row:
        print(cell.value)
like image 111
dangkv Avatar answered Oct 26 '25 14:10

dangkv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!