1
0
mirror of https://github.com/shuchkin/simplexlsxgen.git synced 2023-08-10 21:12:59 +03:00
This commit is contained in:
Sergey Shuchkin 2022-02-05 18:32:10 +06:00
parent 40eb704eb2
commit 121f1222c2
5 changed files with 572 additions and 563 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
vendor* /vendor*
/books.fw.png /books.fw.png
/datatypes.fw.png /datatypes.fw.png
/styles.fw.png /styles.fw.png
/.gitignore

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
## 1.1.10 (2022-02-05)
* namespace added, use Shuchkin\SimpleXLSXGen
## 1.0.23 (2022-02-01) ## 1.0.23 (2022-02-01)
* fixed dates if year < 1900 and time only cells, thx [fapth](https://github.com/shuchkin/simplexlsxgen/issues/51) * fixed dates if year < 1900 and time only cells, thx [fapth](https://github.com/shuchkin/simplexlsxgen/issues/51)

View File

@ -1,8 +1,10 @@
# SimpleXLSXGen # SimpleXLSXGen
[<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/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.
(!) XLSX reader [here](https://github.com/shuchkin/simplexlsx). - XLSX reader [here](https://github.com/shuchkin/simplexlsx)
- XLS reader [here](https://github.com/shuchkin/simplexls)
- CSV reader/writer [here](https://github.com/shuchkin/simplecsv)
**Sergey Shuchkin** <sergey.shuchkin@gmail.com> 2020-2021<br/> **Sergey Shuchkin** <sergey.shuchkin@gmail.com> 2020-2021<br/>
@ -15,7 +17,7 @@ $books = [
[618260307, 'The Hobbit', 'J. R. R. Tolkien', 'Houghton Mifflin', 'USA'], [618260307, 'The Hobbit', 'J. R. R. Tolkien', 'Houghton Mifflin', 'USA'],
[908606664, 'Slinky Malinki', 'Lynley Dodd', 'Mallinson Rendel', 'NZ'] [908606664, 'Slinky Malinki', 'Lynley Dodd', 'Mallinson Rendel', 'NZ']
]; ];
$xlsx = SimpleXLSXGen::fromArray( $books ); $xlsx = Shuchkin\SimpleXLSXGen::fromArray( $books );
$xlsx->saveAs('books.xlsx'); // or downloadAs('books.xlsx') or $xlsx_content = (string) $xlsx $xlsx->saveAs('books.xlsx'); // or downloadAs('books.xlsx') or $xlsx_content = (string) $xlsx
``` ```
![XLSX screenshot](books.png) ![XLSX screenshot](books.png)
@ -46,7 +48,7 @@ $data = [
['Hyperlink + Anchor', '<a href="https://github.com/shuchkin/simplexlsxgen">SimpleXLSXGen</a>'], ['Hyperlink + Anchor', '<a href="https://github.com/shuchkin/simplexlsxgen">SimpleXLSXGen</a>'],
['RAW string', "\0".'2020-10-04 16:02:00'] ['RAW string', "\0".'2020-10-04 16:02:00']
]; ];
SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx'); Shuchkin\SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx');
``` ```
![XLSX screenshot](datatypes.png) ![XLSX screenshot](datatypes.png)
@ -66,7 +68,7 @@ $data = [
['Right', '<right>Right Text</right>'], ['Right', '<right>Right Text</right>'],
['Center + Bold', '<center><b>Name</b></center>'] ['Center + Bold', '<center><b>Name</b></center>']
]; ];
SimpleXLSXGen::fromArray( $data ) Shuchkin\SimpleXLSXGen::fromArray( $data )
->setDefaultFont( 'Courier New' ) ->setDefaultFont( 'Courier New' )
->setDefaultFontSize( 14 ) ->setDefaultFontSize( 14 )
->saveAs('styles_and_tags.xlsx'); ->saveAs('styles_and_tags.xlsx');
@ -76,15 +78,16 @@ SimpleXLSXGen::fromArray( $data )
### More examples ### More examples
```php ```php
// Fluid interface, output to browser for download // Fluid interface, output to browser for download
SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx'); Shuchkin\SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx');
// Fluid interface, multiple sheets // Fluid interface, multiple sheets
SimpleXLSXGen::fromArray( $books )->addSheet( $books2 )->download(); Shuchkin\SimpleXLSXGen::fromArray( $books )->addSheet( $books2 )->download();
// Alternative interface, sheet name, get xlsx content // Alternative interface, sheet name, get xlsx content
$xlsx_cache = (string) (new SimpleXLSXGen)->addSheet( $books, 'Modern style'); $xlsx_cache = (string) (new Shuchkin\SimpleXLSXGen)->addSheet( $books, 'Modern style');
// Classic interface // Classic interface
use Shuchkin\SimpleXLSXGen
$xlsx = new SimpleXLSXGen(); $xlsx = new SimpleXLSXGen();
$xlsx->addSheet( $books, 'Catalog 2021' ); $xlsx->addSheet( $books, 'Catalog 2021' );
$xlsx->addSheet( $books2, 'Stephen King catalog'); $xlsx->addSheet( $books2, 'Stephen King catalog');
@ -101,5 +104,5 @@ $data = [
['Debug', 123] ['Debug', 123]
]; ];
SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx'); Shuchkin\SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
``` ```

View File

@ -17,6 +17,7 @@
] ]
}, },
"require": { "require": {
"php": ">=5.4",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-zlib": "*" "ext-zlib": "*"
} }

File diff suppressed because it is too large Load Diff