Improve default value binder handling of string/numeric values
- Modified regexp to handle scientific notation and apply appropriate tests rather than drop through to string - modified handler to detect integers too long for PHP, and treat as string rather than convert to float
This commit is contained in:
parent
78c2f23621
commit
d44aebc0a4
|
@ -86,8 +86,11 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||||
return PHPExcel_Cell_DataType::TYPE_BOOL;
|
return PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||||
} elseif (is_float($pValue) || is_int($pValue)) {
|
} elseif (is_float($pValue) || is_int($pValue)) {
|
||||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||||
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
|
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
|
||||||
if (is_string($pValue) && $pValue{0} === '0' && strlen($pValue) > 1 && $pValue{1} !== '.' ) {
|
$tValue = ltrim($pValue, '+-');
|
||||||
|
if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.' ) {
|
||||||
|
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
|
} elseif((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
|
||||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
}
|
}
|
||||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||||
|
|
Loading…
Reference in New Issue