Skip to content

fix(xlsx): keep integer rendering when blanks promote a column to float - #2524

Open
Frank_zhu (Frank-zhu0404) wants to merge 1 commit into
microsoft:mainfrom
Frank-zhu0404:fix/issue-2484-excel-int-format
Open

Frank_zhu (Frank-zhu0404) wants to merge 1 commit into
microsoft:mainfrom
Frank-zhu0404:fix/issue-2484-excel-int-format

Conversation

@Frank-zhu0404

Copy link
Copy Markdown

Summary

  • After reading each sheet, convert float64 columns whose non-null values are all whole numbers back to ints (object dtype) before to_html, so values like 1 no longer render as 1.0 when a blank cell promoted the column.
  • Applied to both the .xlsx and .xls converters.
  • Adds regression tests covering the issue repro, mixed blank/int columns, fractional preservation, and the shared helper.

Fixes #2484.

Test plan

  • Reproduced the issue on main (1.0 / 2.0); confirmed fixed output (1 / 2)
  • pytest packages/markitdown/tests/test_xlsx_number_formatting.py — 5 passed
  • Related xlsx tests (test_xlsx_images.py, showZeroes misc) — 25 passed

A single blank cell makes pandas read a numeric column as float64, so
every whole number rendered as "1.0". Convert integral float columns
back to ints before to_html for both .xlsx and .xls.

Fixes microsoft#2484.
@Frank-zhu0404

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

1 participant