mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4f375a4c30 | |||
41c6e7ca51 | |||
ef7b0fff02 | |||
860da7f493 |
71
README.md
71
README.md
@ -1,4 +1,4 @@
|
||||
# SimpleXLSXGen class 1.0.10 (Official)
|
||||
# SimpleXLSXGen class 1.0.11 (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/>
|
||||
@ -42,48 +42,56 @@ $data = [
|
||||
['Time','02:38:00'],
|
||||
['Datetime PHP', new DateTime('2021-02-06 21:07:00')],
|
||||
['String', 'Long UTF-8 String in autoresized column'],
|
||||
['Hyperlink', 'https://github.com/shuchkin/simplexlsxgen'],
|
||||
['Hyperlink + Anchor', '<a href="https://github.com/shuchkin/simplexlsxgen">SimpleXLSXGen</a>'],
|
||||
['Hyperlink', 'https://github.com/shuchkin/simplexlsxgen'],
|
||||
['Hyperlink + Anchor', '<a href="https://github.com/shuchkin/simplexlsxgen">SimpleXLSXGen</a>'],
|
||||
['RAW string', "\0".'2020-10-04 16:02:00']
|
||||
];
|
||||
SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx'); // or ->downloadAs('datatypes.xlsx');
|
||||
SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx');
|
||||
```
|
||||

|
||||
### Fluid examples
|
||||
|
||||
### Formatting
|
||||
```php
|
||||
SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx'); // output to browser for download
|
||||
SimpleXLSXGen::fromArray( $books )->addSheet( $books2 )->download(); // multiple sheets
|
||||
(new SimpleXLSXGen)->addSheet( $books, 'Modern style')->save();
|
||||
$data = [
|
||||
['Normal', '12345.67'],
|
||||
['Bold', '<b>12345.67</b>'],
|
||||
['Italic', '<i>12345.67</i>'],
|
||||
['Underline', '<u>12345.67</u>'],
|
||||
['Strike', '<s>12345.67</s>'],
|
||||
['Bold + Italic', '<b><i>12345.67</i></b>'],
|
||||
['Hyperlink', 'https://github.com/shuchkin/simplexlsxgen'],
|
||||
['Italic + Hyperlink + Anchor', '<i><a href="https://github.com/shuchkin/simplexlsxgen">SimpleXLSXGen</a></i>'],
|
||||
['Left', '<left>12345.67</left>'],
|
||||
['Center', '<center>12345.67</center>'],
|
||||
['Right', '<right>Right Text</right>'],
|
||||
['Center + Bold', '<center><b>Name</b></center>']
|
||||
];
|
||||
SimpleXLSXGen::fromArray( $data )
|
||||
->setDefaultFont( 'Courier New' )
|
||||
->setDefaultFontSize( 14 )
|
||||
->saveAs('styles_and_tags.xlsx');
|
||||
```
|
||||
### Old school, multiple sheets
|
||||

|
||||
|
||||
### More examples
|
||||
```php
|
||||
// Fluid interface, output to browser for download
|
||||
SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx');
|
||||
|
||||
// Fluid interface, multiple sheets
|
||||
SimpleXLSXGen::fromArray( $books )->addSheet( $books2 )->download();
|
||||
|
||||
// Alternative interface, sheet name, get xlsx content
|
||||
$xlsx_cache = (string) (new SimpleXLSXGen)->addSheet( $books, 'Modern style');
|
||||
|
||||
// Classice interface
|
||||
$xlsx = new SimpleXLSXGen();
|
||||
$xlsx->addSheet( $books, 'Catalog 2021' );
|
||||
$xlsx->addSheet( $books2, 'Stephen King catalog');
|
||||
$xlsx->downloadAs('books_2021.xlsx');
|
||||
exit();
|
||||
```
|
||||
### Formatting
|
||||
```php
|
||||
$data = [
|
||||
['Normal', '12345.67'],
|
||||
['Bold', '<b>12345.67</b>'],
|
||||
['Italic', '<i>12345.67</i>'],
|
||||
['Underline', '<u>12345.67</u>'],
|
||||
['Strike', '<s>12345.67</s>'],
|
||||
['Bold + Italic', '<b><i>12345.67</i></b>'],
|
||||
['Hyperlink', 'https://github.com/shuchkin/simplexlsxgen'],
|
||||
['Italic + Hyperlink + Anchor', '<i><a href="https://github.com/shuchkin/simplexlsxgen">SimpleXLSXGen</a></i>'],
|
||||
['Left', '<left>12345.67</left>'],
|
||||
['Center', '<center>12345.67</center>'],
|
||||
['Right', '<right>Right Text</right>'],
|
||||
['Center + Bold', '<center><b>Name</b></center>']
|
||||
];
|
||||
SimpleXLSXGen::fromArray( $data )
|
||||
->setDefaultFont( 'Courier New' )
|
||||
->setDefaultFontSize( 14 )
|
||||
->saveAs('styles_and_tags.xlsx');
|
||||
```
|
||||

|
||||
|
||||
### Debug
|
||||
```php
|
||||
ini_set('error_reporting', E_ALL );
|
||||
@ -97,6 +105,7 @@ SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
|
||||
|
||||
|
||||
## History
|
||||
v1.0.11 (2021-05-14) Fixed 0.00% format, thx [marcrobledo](https://github.com/shuchkin/simplexlsxgen/pull/34), more examples in README.md<br/>
|
||||
v1.0.10 (2021-05-03) + Hyperlinks, + Minimal formatting<br/>
|
||||
v0.9.25 (2021-02-26) Added PHP Datetime object values in a cells<br/>
|
||||
v0.9.24 (2021-02-26) * Percent<br/>
|
||||
|
@ -476,7 +476,7 @@ class SimpleXLSXGen {
|
||||
} elseif ( preg_match( '/^([-+]?\d+)%$/', $v, $m ) ) {
|
||||
$cv = round( $m[1] / 100, 2 );
|
||||
$N = self::N_PERCENT_INT; // [9] 0%
|
||||
} elseif ( preg_match( '/^([-+]\d+\.\d+)%$/', $v, $m ) ) {
|
||||
} elseif ( preg_match( '/^([-+]?\d+\.\d+)%$/', $v, $m ) ) {
|
||||
$cv = round( $m[1] / 100, 4 );
|
||||
$N = self::N_PRECENT_DEC; // [10] 0.00%
|
||||
} elseif ( preg_match( '/^(\d\d\d\d)-(\d\d)-(\d\d)$/', $v, $m ) ) {
|
||||
|
Reference in New Issue
Block a user