From 6a098dd7e436b5bfd8f9ed01ccf1ac793dd3e81b Mon Sep 17 00:00:00 2001 From: Sergey Shuchkin Date: Wed, 20 May 2020 23:36:47 +0600 Subject: [PATCH] 0.9.13 if string more 160 chars, save as inlineStr --- README.md | 3 ++- src/SimpleXLSXGen.php | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1690ced..1ef1f7d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SimpleXLSXGen class 0.9.12 (Official) +# SimpleXLSXGen class 0.9.13 (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.
@@ -49,6 +49,7 @@ SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx'); ![XLSX screenshot](datatypes.png) ## History +v0.9.13 (2020-05-21) if string more 160 chars, save as inlineStr
v0.9.12 (2020-05-21) readme fixed
v0.9.11 (2020-05-21) removed XML unimportant attributes
v0.9.10 (2020-05-20) initial release \ No newline at end of file diff --git a/src/SimpleXLSXGen.php b/src/SimpleXLSXGen.php index 105d7e8..3c65e4b 100644 --- a/src/SimpleXLSXGen.php +++ b/src/SimpleXLSXGen.php @@ -203,9 +203,12 @@ class SimpleXLSXGen { } elseif ( preg_match('/^(\d\d):(\d\d):(\d\d)$/', $v, $m ) ){ $cv = $this->_date2excel(0,0,0,$m[1],$m[2],$m[3]); $cs = 4; // [14] mm-dd-yy - } elseif ( preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/', $v, $m ) ){ - $cv = $this->_date2excel($m[1],$m[2],$m[3],$m[4],$m[5],$m[6]); + } elseif ( preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/', $v, $m ) ) { + $cv = $this->_date2excel( $m[1], $m[2], $m[3], $m[4], $m[5], $m[6] ); $cs = 5; // [22] m/d/yy h:mm + } elseif ( mb_strlen( $v ) > 160 ) { + $ct = 'inlineStr'; + $cv = htmlentities( $v, ENT_QUOTES ); } else { $ct = 's'; // shared string $v = htmlentities($v, ENT_QUOTES); @@ -221,7 +224,8 @@ class SimpleXLSXGen { continue; } - $row .= '' . $cv . "\r\n"; + $row .= '' + .($ct === 'inlineStr' ? ''.$cv.'' : '' . $cv . '')."\r\n"; } $ROWS[] = $row . "\r\n"; }