Skip to content

Conversation

@matheuszpher
Copy link

Closes #63010

Fixes an issue where ExcelFile.parse() with openpyxl resets
Worksheet.max_row and Worksheet.max_column to None.

Changes

Removed the sheet.reset_dimensions() call for read-only sheets,
as it causes unexpected loss of dimension information after parsing.

Reproducible example

import pandas as pd

with pd.ExcelFile("some_file.xlsx") as excel_file:
    ws = excel_file.book["Sheet1"]
    dim_before = (ws.max_row, ws.max_column)
    excel_file.parse(sheet_name=ws.title)
    dim_after = (ws.max_row, ws.max_column)

assert dim_before == dim_after  # now passes ✅

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As expressed in the linked issue, I'm negative on this approach.

@rhshadrach rhshadrach added Bug IO Excel read_excel, to_excel labels Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug IO Excel read_excel, to_excel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: ExcelFile.parse sets sheet.max_row and sheet.max_column to None

2 participants