Skip to content

Modify XLSX RW to keep decimal for floats with a zero decimal part#1262

Closed
rtek wants to merge 1 commit intoPHPOffice:masterfrom
rtek:fix-floats-not-written
Closed

Modify XLSX RW to keep decimal for floats with a zero decimal part#1262
rtek wants to merge 1 commit intoPHPOffice:masterfrom
rtek:fix-floats-not-written

Conversation

@rtek
Copy link
Contributor

@rtek rtek commented Nov 25, 2019

This is:

  • a bugfix

Why this change is needed?

Prior to 1.10, all numeric values where read as floats. In 1.10
numeric values are read using 0 + x, which relies on PHP type
juggling rules. As a result, float(0.0) is written as string('0'),
then read back as int(0). This fix causes the writer to retain the
the decimal for float values such that a reader can differentiate
floats from ints.

Checklist:

Prior to 1.10, all numeric values where read as floats. In 1.10
numeric values are read using 0 + x, which relies on PHP type
juggling rules. As a result, float(0.0) is written as string('0'),
then read back as int(0). This fix causes the writer to retain the
the decimal for float values such that a reader can differentiate
floats from ints.
@PowerKiKi PowerKiKi closed this in cf30c2a Nov 30, 2019
@PowerKiKi
Copy link
Member

Thanks for this great PR !

BlackyTay pushed a commit to BlackyTay/PhpSpreadsheet that referenced this pull request Aug 8, 2025
Prior to 1.10, all numeric values where read as floats. In 1.10
numeric values are read using 0 + x, which relies on PHP type
juggling rules. As a result, float(0.0) is written as string('0'),
then read back as int(0). This fix causes the writer to retain the
the decimal for float values such that a reader can differentiate
floats from ints.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants