1
0
mirror of https://github.com/shuchkin/simplexlsxgen.git synced 2023-08-10 21:12:59 +03:00

fixed fast shared strings index

This commit is contained in:
Sergey Shuchkin 2020-08-22 13:54:34 +06:00
parent 9b2c9d3e1c
commit aafe6abd5b
2 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# SimpleXLSXGen class 0.9.17 (Official) # SimpleXLSXGen class 0.9.18 (Official)
[<img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.herokuapp.com%2Fshuchkin" />](https://www.patreon.com/shuchkin) [<img src="https://img.shields.io/github/license/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/blob/master/license.md) [<img src="https://img.shields.io/github/stars/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/stargazers) [<img src="https://img.shields.io/github/forks/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/network) [<img src="https://img.shields.io/github/issues/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/issues) [<img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.herokuapp.com%2Fshuchkin" />](https://www.patreon.com/shuchkin) [<img src="https://img.shields.io/github/license/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/blob/master/license.md) [<img src="https://img.shields.io/github/stars/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/stargazers) [<img src="https://img.shields.io/github/forks/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/network) [<img src="https://img.shields.io/github/issues/shuchkin/simplexlsxgen" />](https://github.com/shuchkin/simplexlsxgen/issues)
Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.<br/> Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.<br/>
@ -62,6 +62,7 @@ SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
## History ## History
v0.9.18 (2020-08-22) fixed fast shared strings index<br/>
v0.9.17 (2020-08-21) Fixed real numbers in 123.45 format detection, fast shared strings index (thx fredriksundin)<br/> v0.9.17 (2020-08-21) Fixed real numbers in 123.45 format detection, fast shared strings index (thx fredriksundin)<br/>
v0.9.16 (2020-07-29) Fixed time detection in HH:MM:SS format<br/> v0.9.16 (2020-07-29) Fixed time detection in HH:MM:SS format<br/>
v0.9.15 (2020-07-14) escape of shared strings for special chars in cells [#1](https://github.com/shuchkin/simplexlsxgen/issues/1) <br/> v0.9.15 (2020-07-14) escape of shared strings for special chars in cells [#1](https://github.com/shuchkin/simplexlsxgen/issues/1) <br/>

View File

@ -188,9 +188,9 @@ class SimpleXLSXGen {
if ( is_string($v) ) { if ( is_string($v) ) {
if ( preg_match( '/^[-+]?\d{1,18}$/', $v ) ) { if ( preg_match( '/^[-+]?[1-9]\d{0,17}$/', $v ) ) {
$cv = ltrim($v,'+'); $cv = ltrim($v,'+');
} elseif ( preg_match('/^[-+]?\d+\.\d+$/', $v ) ) { } elseif ( preg_match('/^[-+]?(0|[1-9]\d*)\.\d+$/', $v ) ) {
$cv = ltrim($v,'+'); $cv = ltrim($v,'+');
} elseif ( preg_match('/^([-+]?\d+)%$/', $v, $m) ) { } elseif ( preg_match('/^([-+]?\d+)%$/', $v, $m) ) {
$cv = round( $m[1] / 100, 2); $cv = round( $m[1] / 100, 2);
@ -214,14 +214,15 @@ class SimpleXLSXGen {
$ct = 's'; // shared string $ct = 's'; // shared string
$v = str_replace(['&','<','>'],['&amp;','&lt;','&gt;'], $v); $v = str_replace(['&','<','>'],['&amp;','&lt;','&gt;'], $v);
$cv = false; $cv = false;
if ( isset($SI_KEYS[$v]) ) { $skey = '~'.$v;
$cv = $SI_KEYS[$v]; if ( isset($SI_KEYS[ $skey ]) ) {
$cv = $SI_KEYS[ $skey ];
} }
if ( $cv === false ) { if ( $cv === false ) {
$SI[] = $v; $SI[] = $v;
$cv = count( $SI ) - 1; $cv = count( $SI ) - 1;
$SI_KEYS[$v] = $cv; $SI_KEYS[$skey] = $cv;
} }
} }
} elseif ( is_int( $v ) || is_float( $v ) ) { } elseif ( is_int( $v ) || is_float( $v ) ) {