From 976e7f064a0aec1865683feb29138b87fadf49d4 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 23 Jan 2015 16:49:20 +0000 Subject: [PATCH] Excel TRIM function only trims spaces, not tabs or other spacing characters --- Classes/PHPExcel/Calculation/TextData.php | 3 +-- unitTests/rawTestData/Calculation/TextData/TRIM.data | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Classes/PHPExcel/Calculation/TextData.php b/Classes/PHPExcel/Calculation/TextData.php index 7a52d2e7..148a5b75 100644 --- a/Classes/PHPExcel/Calculation/TextData.php +++ b/Classes/PHPExcel/Calculation/TextData.php @@ -118,13 +118,12 @@ class PHPExcel_Calculation_TextData { */ public static function TRIMSPACES($stringValue = '') { $stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue); - if (is_bool($stringValue)) { return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); } if (is_string($stringValue) || is_numeric($stringValue)) { - return trim(preg_replace('/ +/',' ',trim($stringValue,' '))); + return trim(preg_replace('/ +/',' ',trim($stringValue, ' ')), ' '); } return NULL; } // function TRIMSPACES() diff --git a/unitTests/rawTestData/Calculation/TextData/TRIM.data b/unitTests/rawTestData/Calculation/TextData/TRIM.data index ea1bd050..ea800963 100644 --- a/unitTests/rawTestData/Calculation/TextData/TRIM.data +++ b/unitTests/rawTestData/Calculation/TextData/TRIM.data @@ -1,6 +1,6 @@ "HELLO ", "HELLO" " HELLO", "HELLO" -" HELLO ", "HELLO" +" HELLO ", "HELLO" " HELLO", " HELLO" "HELLO WORLD", "HELLO WORLD" TRUE, "TRUE"