mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
Compare commits
3 Commits
tags/0.9.2
...
0.9.24
Author | SHA1 | Date | |
---|---|---|---|
21db9eca96 | |||
8b6d0505b5 | |||
205396b998 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,3 @@
|
||||
vendor*
|
||||
vendor*
|
||||
/books.fw.png
|
||||
/datatypes.fw.png
|
||||
|
@ -1,10 +1,10 @@
|
||||
# SimpleXLSXGen class 0.9.22 (Official)
|
||||
# SimpleXLSXGen class 0.9.24 (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)
|
||||
|
||||
Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.<br/>
|
||||
(!) XLSX reader [here](https://github.com/shuchkin/simplexlsx).
|
||||
|
||||
**Sergey Shuchkin** <sergey.shuchkin@gmail.com> 2020<br/>
|
||||
**Sergey Shuchkin** <sergey.shuchkin@gmail.com> 2020-2021<br/>
|
||||
|
||||
*Hey, bro, please ★ the package for my motivation :)*
|
||||
|
||||
@ -36,7 +36,7 @@ or download class [here](https://github.com/shuchkin/simplexlsxgen/blob/master/s
|
||||
$data = [
|
||||
['Integer', 123],
|
||||
['Float', 12.35],
|
||||
['Procent', '12%'],
|
||||
['Percent', '12%'],
|
||||
['Datetime', '2020-05-20 02:38:00'],
|
||||
['Date','2020-05-20'],
|
||||
['Time','02:38:00'],
|
||||
@ -72,6 +72,8 @@ SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
|
||||
|
||||
|
||||
## History
|
||||
v0.9.24 (2021-02-26) * Percent<br/>
|
||||
v0.9.23 (2021-01-25) Fix local floats in XML<br/>
|
||||
v0.9.22 (2020-11-04) Added multiple sheets support, thx [Savino59](https://github.com/Savino59), class ready for extend now<br/>
|
||||
v0.9.21 (2020-10-17) Updated images<br/>
|
||||
v0.9.20 (2020-10-04) Disable type detection if string started with chr(0)<br/>
|
||||
|
BIN
datatypes.png
BIN
datatypes.png
Binary file not shown.
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 17 KiB |
@ -223,7 +223,7 @@ class SimpleXLSXGen {
|
||||
} elseif ( $cfilename === 'xl/worksheets/sheet1.xml' ) {
|
||||
foreach ( $this->sheets as $k => $v ) {
|
||||
$filename = 'xl/worksheets/sheet'.($k+1).'.xml';
|
||||
$xml = $this->_sheetToXML($this->sheets[$k], $template);
|
||||
$xml = $this->_sheetToXML($k, $template);
|
||||
$this->_writeEntry($fh, $cdrec, $filename, $xml );
|
||||
$entries++;
|
||||
}
|
||||
@ -330,14 +330,16 @@ class SimpleXLSXGen {
|
||||
$cdrec .= $e['comments'];
|
||||
}
|
||||
|
||||
protected function _sheetToXML(&$sheet, $template) {
|
||||
|
||||
protected function _sheetToXML($idx, $template) {
|
||||
// locale floats fr_FR 1.234,56 -> 1234.56
|
||||
$_loc = setlocale(LC_NUMERIC, 0);
|
||||
setlocale(LC_NUMERIC,'C');
|
||||
$COLS = [];
|
||||
$ROWS = [];
|
||||
if ( count($sheet['rows']) ) {
|
||||
if ( count($this->sheets[$idx]['rows']) ) {
|
||||
$CUR_ROW = 0;
|
||||
$COL = [];
|
||||
foreach( $sheet['rows'] as $r ) {
|
||||
foreach( $this->sheets[$idx]['rows'] as $r ) {
|
||||
$CUR_ROW++;
|
||||
$row = '<row r="'.$CUR_ROW.'">';
|
||||
$CUR_COL = 0;
|
||||
@ -409,7 +411,9 @@ class SimpleXLSXGen {
|
||||
$this->SI_KEYS[$skey] = $cv;
|
||||
}
|
||||
}
|
||||
} elseif ( is_int( $v ) || is_float( $v ) ) {
|
||||
} elseif ( is_int( $v ) ) {
|
||||
$cv = $v;
|
||||
} elseif ( is_float( $v ) ) {
|
||||
$cv = $v;
|
||||
} else {
|
||||
continue;
|
||||
@ -429,6 +433,9 @@ class SimpleXLSXGen {
|
||||
$ROWS[] = '<row r="1"><c r="A1" t="s"><v>0</v></c></row>';
|
||||
$REF = 'A1:A1';
|
||||
}
|
||||
//restore locale
|
||||
setlocale(LC_NUMERIC, $_loc);
|
||||
|
||||
return str_replace(['{REF}','{COLS}','{ROWS}'],
|
||||
[ $REF, implode("\r\n", $COLS), implode("\r\n",$ROWS) ],
|
||||
$template );
|
||||
|
Reference in New Issue
Block a user