Excel TRIM function only trims spaces, not tabs or other spacing characters

This commit is contained in:
MarkBaker 2015-01-23 16:49:20 +00:00
parent fb18b7b598
commit 976e7f064a
2 changed files with 2 additions and 3 deletions

View File

@ -118,13 +118,12 @@ class PHPExcel_Calculation_TextData {
*/ */
public static function TRIMSPACES($stringValue = '') { public static function TRIMSPACES($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); $stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) { if (is_bool($stringValue)) {
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
} }
if (is_string($stringValue) || is_numeric($stringValue)) { if (is_string($stringValue) || is_numeric($stringValue)) {
return trim(preg_replace('/ +/',' ',trim($stringValue,' '))); return trim(preg_replace('/ +/',' ',trim($stringValue, ' ')), ' ');
} }
return NULL; return NULL;
} // function TRIMSPACES() } // function TRIMSPACES()

View File

@ -1,6 +1,6 @@
"HELLO ", "HELLO" "HELLO ", "HELLO"
" HELLO", "HELLO" " HELLO", "HELLO"
" HELLO ", "HELLO" " HELLO ", "HELLO"
" HELLO", " HELLO" " HELLO", " HELLO"
"HELLO WORLD", "HELLO WORLD" "HELLO WORLD", "HELLO WORLD"
TRUE, "TRUE" TRUE, "TRUE"