Skip to content

fix(xlsx): keep integer rendering when a blank cell promotes a column to float - #2485

Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/xlsx-int-float-formatting
Open

Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/xlsx-int-float-formatting

Conversation

@ManoharPaturi

Copy link
Copy Markdown

Fixes #2484.

After reading each sheet, integral float columns (every non-null value is integral) are rewritten to object-dtype ints before to_html, so whole numbers keep their integer rendering even when a blank cell promoted the column to float64. Applied to both the .xlsx and .xls paths.

New tests cover the mixed blank/int column for both formats (fail on main with 1.0/2.0, pass here) plus float-column preservation cases; suite otherwise unchanged (891 passed, same 5 pre-existing env failures as main).

A single blank cell makes pandas read a numeric column as float64, so
every whole number in it rendered as "1.0" even though Excel shows "1".
Columns whose present values are all whole numbers are converted back to
integers before the HTML render; fractional columns, missing cells and
non-float columns are unchanged.

Applies to both the .xlsx and .xls converters.
Copilot AI lite review requested due to automatic review settings September 13, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XLSX/XLS: whole numbers render as "1.0" when the column contains a blank cell

2 participants