Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

DefaultValueBinder is too much aggressive when converting string to numeric #394

Closed
jdespatis opened this issue Jun 30, 2014 · 1 comment
Assignees
Milestone

Comments

@jdespatis
Copy link

The method PHPExcel_Cell_DefaultValueBinder::dataTypeForValue() tries to convert strings that contain numeric to numeric

It's a good thing, however if the input string is something like "0101010101", the resulting numeric in Excel will be 101010101, therefore the leading 0 has disappeared (because it has been considered as a number)

I think it's too much agressive, because there's here an information that has disappeared (the leading 0)

In fact, I get from database a phone number, that is a string in database: "0101010101", I put that value into an Excel Cell, and obviously, I don't want this value to be changed

As a result, I would add a condition for converting a string to a numeric:
if the string only contains number (not decimal), and begins with a leading 0, it must not be converting to decimal

What do you think of it?

@MarkBaker
Copy link
Member

I'd suggest that any numeric value that was a straight 0 or anything beginning 0. should still be converted to a number.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants