Commit 2395ca4fa03c77f5006a05df81b65e1accfac6af
1 parent
f6e54131
add round func for values in xlsx parser
Showing
1 changed file
with
10 additions
and
2 deletions
Show diff stats
lib/XlsxParser.php
@@ -36,6 +36,10 @@ class XlsxParser extends TableParser | @@ -36,6 +36,10 @@ class XlsxParser extends TableParser | ||
36 | protected $current_node; | 36 | protected $current_node; |
37 | protected $current_sheet; | 37 | protected $current_sheet; |
38 | 38 | ||
39 | + // глубина округления для флоата | ||
40 | + // @todo - перенести вродительский класс и применить в дочерних классах | ||
41 | + protected $float_precision = 6; | ||
42 | + | ||
39 | public function setup() | 43 | public function setup() |
40 | { | 44 | { |
41 | 45 | ||
@@ -164,9 +168,13 @@ class XlsxParser extends TableParser | @@ -164,9 +168,13 @@ class XlsxParser extends TableParser | ||
164 | if (isset($child->v)) { | 168 | if (isset($child->v)) { |
165 | $value = (string)$child->v; | 169 | $value = (string)$child->v; |
166 | 170 | ||
167 | - if ( isset($attr['t']) ) | ||
168 | - // it's not a value it's a string, so fetch it from string array | 171 | + if ( isset($attr['t']) ){ |
172 | + // it's not a value it's a string, so fetch it from string array | ||
169 | $value = $this->strings_arr[$value]; | 173 | $value = $this->strings_arr[$value]; |
174 | + } else { | ||
175 | + $value = (string)round( $value, $this->float_precision ); | ||
176 | + } | ||
177 | + | ||
170 | 178 | ||
171 | } else { | 179 | } else { |
172 | $value = ''; | 180 | $value = ''; |