Skip to content

ENH: Columns formatted as "Text" in Excel are read as numbers #61539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 3 tasks
pranay-sa opened this issue Jun 3, 2025 · 0 comments
Open
1 of 3 tasks

ENH: Columns formatted as "Text" in Excel are read as numbers #61539

pranay-sa opened this issue Jun 3, 2025 · 0 comments
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@pranay-sa
Copy link

pranay-sa commented Jun 3, 2025

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

When reading Excel files, pandas ignores Excel's "Text" cell formatting and converts text-formatted numbers (e.g., IDs, codes) to numeric types (int/float).
This requires manual conversion back to strings, which can be inefficient , for a huge dataset and prone to errors.

Image

Feature Description

Add an option in pd.read_excel() to respect Excel's cell formatting
(e.g., dtype_from_format=True), or set it to true by default , preserving text-formatted columns as strings.

Alternative Solutions

OpenPyXL/Xlrd Engine + Format Detection
Read cell formats directly (requires manual parsing):

from openpyxl import load_workbook

wb = load_workbook("data.xlsx", data_only=False)
sheet = wb.active
text_columns = [col for col in sheet.columns if sheet.cell(row=1, column=col[0].column).number_format == "@"]

Additional Context

No response

@pranay-sa pranay-sa added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant