General: Work Item GH-394 - DefaultValueBinder is too much aggressive when converting string to numeric

This commit is contained in:
MarkBaker 2014-09-09 23:59:55 +01:00
parent 31d60ad524
commit d4a641c5c7
2 changed files with 6 additions and 11 deletions

View File

@ -76,31 +76,25 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
// Match the value against a few data types
if (is_null($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NULL;
} elseif ($pValue === '') {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ($pValue instanceof PHPExcel_RichText) {
return PHPExcel_Cell_DataType::TYPE_INLINE;
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) {
return PHPExcel_Cell_DataType::TYPE_BOOL;
} elseif (is_float($pValue) || is_int($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
if (is_string($pValue) && $pValue{0} === '0' && strlen($pValue) > 1 && $pValue{1} !== '.' ) {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
return PHPExcel_Cell_DataType::TYPE_ERROR;
} else {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_STRING;
}
}

View File

@ -35,6 +35,7 @@ Planned for v1.8.1
- Bugfix: (MBaker) - Fix to getStyle() call for cell object
- General: (MBaker) - Small performance improvement for autosize columns
- General: (frost-nzcr4) Work Item GH-379 - Change the getter/setter for zeroHeight to camel case
- General: (MBaker) Work Item GH-394 - DefaultValueBinder is too much aggressive when converting string to numeric
- Feature: (WiktrzGE) Work Item GH-404 - Methods to manage most of the existing options for Chart Axis, Major Grid-lines and Minor Grid-lines
- Feature: (frost-nzcr4) Work Item GH-403 - ODS read/write comments in the cell
- Feature: (CQD) Work Item GH-389 - Additional Mac CJK codepage definitions