From 2395ca4fa03c77f5006a05df81b65e1accfac6af Mon Sep 17 00:00:00 2001 From: Mihail Date: Wed, 18 Nov 2015 14:53:42 +0200 Subject: [PATCH] add round func for values in xlsx parser --- lib/XlsxParser.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/XlsxParser.php b/lib/XlsxParser.php index fc48c53..d32dfef 100644 --- a/lib/XlsxParser.php +++ b/lib/XlsxParser.php @@ -36,6 +36,10 @@ class XlsxParser extends TableParser protected $current_node; protected $current_sheet; + // глубина округления для флоата + // @todo - перенести вродительский класс и применить в дочерних классах + protected $float_precision = 6; + public function setup() { @@ -164,9 +168,13 @@ class XlsxParser extends TableParser if (isset($child->v)) { $value = (string)$child->v; - if ( isset($attr['t']) ) - // it's not a value it's a string, so fetch it from string array + if ( isset($attr['t']) ){ + // it's not a value it's a string, so fetch it from string array $value = $this->strings_arr[$value]; + } else { + $value = (string)round( $value, $this->float_precision ); + } + } else { $value = ''; -- libgit2 0.21.4