diff --git a/README.md b/README.md index d00dacb..326f961 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SimpleXLSXGen class 0.9.17 (Official) +# SimpleXLSXGen class 0.9.18 (Official) [](https://www.patreon.com/shuchkin) [](https://github.com/shuchkin/simplexlsxgen/blob/master/license.md) [](https://github.com/shuchkin/simplexlsxgen/stargazers) [](https://github.com/shuchkin/simplexlsxgen/network) [](https://github.com/shuchkin/simplexlsxgen/issues) Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.
@@ -62,6 +62,7 @@ SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx'); ## History +v0.9.18 (2020-08-22) fixed fast shared strings index
v0.9.17 (2020-08-21) Fixed real numbers in 123.45 format detection, fast shared strings index (thx fredriksundin)
v0.9.16 (2020-07-29) Fixed time detection in HH:MM:SS format
v0.9.15 (2020-07-14) escape of shared strings for special chars in cells [#1](https://github.com/shuchkin/simplexlsxgen/issues/1)
diff --git a/src/SimpleXLSXGen.php b/src/SimpleXLSXGen.php index 337511b..d06b2cf 100644 --- a/src/SimpleXLSXGen.php +++ b/src/SimpleXLSXGen.php @@ -188,9 +188,9 @@ class SimpleXLSXGen { if ( is_string($v) ) { - if ( preg_match( '/^[-+]?\d{1,18}$/', $v ) ) { + if ( preg_match( '/^[-+]?[1-9]\d{0,17}$/', $v ) ) { $cv = ltrim($v,'+'); - } elseif ( preg_match('/^[-+]?\d+\.\d+$/', $v ) ) { + } elseif ( preg_match('/^[-+]?(0|[1-9]\d*)\.\d+$/', $v ) ) { $cv = ltrim($v,'+'); } elseif ( preg_match('/^([-+]?\d+)%$/', $v, $m) ) { $cv = round( $m[1] / 100, 2); @@ -214,14 +214,15 @@ class SimpleXLSXGen { $ct = 's'; // shared string $v = str_replace(['&','<','>'],['&','<','>'], $v); $cv = false; - if ( isset($SI_KEYS[$v]) ) { - $cv = $SI_KEYS[$v]; + $skey = '~'.$v; + if ( isset($SI_KEYS[ $skey ]) ) { + $cv = $SI_KEYS[ $skey ]; } if ( $cv === false ) { $SI[] = $v; $cv = count( $SI ) - 1; - $SI_KEYS[$v] = $cv; + $SI_KEYS[$skey] = $cv; } } } elseif ( is_int( $v ) || is_float( $v ) ) {