From 3b334dce1fd6b7da1b8858fab2e3680044a14179 Mon Sep 17 00:00:00 2001 From: Chris Graham Date: Mon, 30 Mar 2015 22:17:44 +0100 Subject: [PATCH] Fix number detection --- src/Spout/Writer/Internal/XLSX/Worksheet.php | 2 +- src/Spout/Writer/XLS.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spout/Writer/Internal/XLSX/Worksheet.php b/src/Spout/Writer/Internal/XLSX/Worksheet.php index f778b8c..edde970 100644 --- a/src/Spout/Writer/Internal/XLSX/Worksheet.php +++ b/src/Spout/Writer/Internal/XLSX/Worksheet.php @@ -149,7 +149,7 @@ EOD; if (empty($cellValue)) { $data .= '/>' . PHP_EOL; } else { - if (trim($cellValue, '-0123456789.') == '' /*similar to is_numeric without having PHPs regular quirkiness*/) { + if (trim(ltrim($cellValue, '-'), '0123456789.') == '' /*similar to is_numeric without having PHPs regular quirkiness*/) { $data .= '>' . $cellValue . '' . PHP_EOL; } else { if ($this->shouldUseInlineStrings) { diff --git a/src/Spout/Writer/XLS.php b/src/Spout/Writer/XLS.php index 2278783..ac55d5a 100644 --- a/src/Spout/Writer/XLS.php +++ b/src/Spout/Writer/XLS.php @@ -164,7 +164,7 @@ class XLS extends AbstractWriter $this->home(); foreach ($dataRow as $cell) { - if ($cell != '' && trim($cell, '-0123456789.') == '' /*similar to is_numeric without having PHPs regular quirkiness*/) { + if ($cell != '' && trim(ltrim($cell, '-'), '0123456789.') == '' /*similar to is_numeric without having PHPs regular quirkiness*/) { $wasWriteSuccessful = $wasWriteSuccessful && $this->number($cell); } else {