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

31 Commits

Author SHA1 Message Date
121f1222c2 1.1.10 2022-02-05 18:32:10 +06:00
40eb704eb2 1.0.23 2022-02-01 02:50:32 +06:00
4005e8cbd1 Merge pull request #48 from appel/patch-1
added a ; in the Debug section.
2021-11-28 20:43:00 +06:00
9d82a43fe6 added a ; in the Debug section. 2021-11-28 08:48:15 -05:00
9a555eef9b 1.0.22 2021-10-29 03:37:04 +06:00
79ffbb5e30 1.0.21 2021-09-20 00:51:25 +06:00
868cf8edc0 1.0.21 2021-09-03 22:12:48 +06:00
7f5c584772 1.0.20 2021-07-29 12:16:10 +06:00
5b58103e3b 1.0.19 2021-07-28 22:01:02 +06:00
6d49a90fe7 1.0.18 2021-07-28 05:06:23 +06:00
c8a94d552a 1.0.17 2021-07-28 01:45:25 +06:00
c9fa7da689 1.0.16 2021-07-01 03:03:57 +06:00
0d059fdf6e 1.0.16 2021-07-01 03:01:35 +06:00
dcb5f8ad65 1.0.15 2021-06-22 00:57:29 +06:00
f970452779 1.0.14 2021-06-08 09:59:42 +06:00
6abd0286bb 1.0.14 2021-06-08 09:51:10 +06:00
8bfbe078db 1.0.13 2021-05-29 23:21:45 +06:00
6ece83f9ce 1.0.12 2021-05-19 10:21:09 +06:00
4f375a4c30 1.0.11 2021-05-14 16:52:30 +06:00
41c6e7ca51 Merge pull request #34 from marcrobledo/marcrobledo-fix-percentage
fix percentage with decimals
2021-05-14 16:37:33 +06:00
ef7b0fff02 fix percentage with decimals
make sign optional for percentage values with decimals
2021-05-14 10:55:07 +02:00
860da7f493 1.0.10 2021-05-03 03:22:26 +06:00
eeec88dbf0 1.0.10 2021-05-03 03:19:14 +06:00
1e866f82bf 1.0.10 2021-05-03 03:17:24 +06:00
17098b57ef 1.0.10 2021-05-03 03:08:41 +06:00
ab49ffadd7 example $xlsx_content = (string) $xlsx 2021-03-01 00:09:42 +06:00
99c6be2fb4 Added PHP Datetime object values in a cells 2021-02-26 21:45:38 +06:00
d1ccfc6f17 Added PHP Datetime object values in a cells 2021-02-26 21:39:13 +06:00
21db9eca96 * percent 2021-02-26 12:55:41 +06:00
8b6d0505b5 Fix local floats in XML 2021-01-25 22:43:37 +06:00
205396b998 Fix local floats in XML 2021-01-25 22:19:37 +06:00
7 changed files with 792 additions and 466 deletions

6
.gitignore vendored
View File

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

102
CHANGELOG.md Normal file
View File

@ -0,0 +1,102 @@
# Changelog
## 1.1.10 (2022-02-05)
* namespace added, use Shuchkin\SimpleXLSXGen
## 1.0.23 (2022-02-01)
* fixed dates if year < 1900 and time only cells, thx [fapth](https://github.com/shuchkin/simplexlsxgen/issues/51)
## 1.0.22 (2021-10-29)
* Escape \x00 and \x0B (vertical tab)
## 1.0.21 (2021-09-03)
* Fixed saveAs / downloadAs / etc methods more than once
## 1.0.20 (2021-07-29)
* Fixed sheet names duplicates (Page, Page (1), Page (2)...)
## 1.0.19 (2021-07-28)
* Fixed sheet names duplicates
## 1.0.18 (2021-07-28)
* Fixed email regex
## 1.0.17 (2021-07-28)
* Fixed &quot; and &amp; in sheets names
## 1.0.16 (2021-07-01)
* Fixed &quot;&amp;&quot; in hyperlinks
## 1.0.15 (2021-06-22)
* Fixed *mailto* hyperlinks detection
## 1.0.14 (2021-06-08)
* Added *mailto* hyperlinks support (thx Howard Martin)
```php
SimpleXLSXGen::fromArray([
['Mailto hyperlink', '<a href="mailto:sergey.shuchkin@gmail.com">Please email me</a>']
])->saveAs('test.xlsx');
```
## 1.0.13 (2021-05-29)
* Fixed hyperlinks in several sheets
* Added [Opencollective donation link](https://opencollective.com/simplexlsx)
## 1.0.12 (2021-05-19)
* Fixed hyperlink regex
## 1.0.11 (2021-05-14)
* Fixed 0.00% format, thx [marcrobledo](https://github.com/shuchkin/simplexlsxgen/pull/34), more examples in README.md
## 1.0.10 (2021-05-03)
Stable release
* Added hyperlinks and minimal formatting
## 0.9.25 (2021-02-26)
* Added PHP Datetime object values in a cells
## 0.9.24 (2021-02-26)
* Percent support
## 0.9.23 (2021-01-25)
* Fix local floats in XML
## 0.9.22 (2020-11-04)
* Added multiple sheets support, thx [Savino59](https://github.com/Savino59), class ready for extend now
## 0.9.21 (2020-10-17)
* Updated images
## 0.9.20 (2020-10-04)
* Disable type detection if string started with chr(0)
## 0.9.19 (2020-08-23)
* Numbers like SKU right aligned now
## 0.9.18 (2020-08-22)
* Fixed fast shared strings index
## 0.9.17 (2020-08-21)
* Fixed real numbers in 123.45 format detection, fast shared strings index (thx fredriksundin)
## 0.9.16 (2020-07-29)
* Fixed time detection in HH:MM:SS format
## 0.9.15 (2020-07-14)
* Escape of shared strings for special chars in cells [#1](https://github.com/shuchkin/simplexlsxgen/issues/1)
## 0.9.14 (2020-05-31)
* Fixed num2name A-Z,AA-AZ column names, thx Ertan Yusufoglu
## 0.9.13 (2020-05-21)
* If string more 160 chars, save as inlineStr
## 0.9.12 (2020-05-21)
* Readme fixed
## 0.9.11 (2020-05-21)
* Removed XML unimportant attributes
## 0.9.10 (2020-05-20)
* Initial release

View File

@ -1,12 +1,14 @@
# SimpleXLSXGen class 0.9.22 (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)
# 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)
Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.<br/>
(!) XLSX reader [here](https://github.com/shuchkin/simplexlsx).
Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.
- 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<br/>
**Sergey Shuchkin** <sergey.shuchkin@gmail.com> 2020-2021<br/>
*Hey, bro, please ★ the package for my motivation :)*
*Hey, bro, please ★ the package for my motivation :) and [donate](https://opencollective.com/simplexlsx) for more motivation!*
## Basic Usage
```php
@ -15,8 +17,8 @@ $books = [
[618260307, 'The Hobbit', 'J. R. R. Tolkien', 'Houghton Mifflin', 'USA'],
[908606664, 'Slinky Malinki', 'Lynley Dodd', 'Mallinson Rendel', 'NZ']
];
$xlsx = SimpleXLSXGen::fromArray( $books );
$xlsx->saveAs('books.xlsx'); // or downloadAs('books.xlsx')
$xlsx = Shuchkin\SimpleXLSXGen::fromArray( $books );
$xlsx->saveAs('books.xlsx'); // or downloadAs('books.xlsx') or $xlsx_content = (string) $xlsx
```
![XLSX screenshot](books.png)
@ -36,52 +38,71 @@ 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'],
['Datetime PHP', new DateTime('2021-02-06 21:07:00')],
['String', 'Long UTF-8 String in autoresized column'],
['Disable Type Detection', "\0".'2020-10-04 16:02:00']
['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');
Shuchkin\SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx');
```
![XLSX screenshot](datatypes.png)
### 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>']
];
Shuchkin\SimpleXLSXGen::fromArray( $data )
->setDefaultFont( 'Courier New' )
->setDefaultFontSize( 14 )
->saveAs('styles_and_tags.xlsx');
```
### Old school, multiple sheets
![XLSX screenshot](styles.png)
### More examples
```php
// Fluid interface, output to browser for download
Shuchkin\SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx');
// Fluid interface, multiple sheets
Shuchkin\SimpleXLSXGen::fromArray( $books )->addSheet( $books2 )->download();
// Alternative interface, sheet name, get xlsx content
$xlsx_cache = (string) (new Shuchkin\SimpleXLSXGen)->addSheet( $books, 'Modern style');
// Classic interface
use Shuchkin\SimpleXLSXGen
$xlsx = new SimpleXLSXGen();
$xlsx->addSheet( $books, 'Catalog 2021' );
$xlsx->addSheet( $books2, 'Stephen King catalog');
$xlsx->downloadAs('books_2021.xlsx');
exit();
```
### Debug
## Debug
```php
ini_set('error_reporting', E_ALL );
ini_set('display_errors', 1 );
$data = [
['Debug', 123]
]
SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
];
Shuchkin\SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
```
## History
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/>
v0.9.19 (2020-08-23) Numbers like SKU right aligned now<br/>
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.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.14 (2020-05-31) fixed num2name A-Z,AA-AZ column names, thx Ertan Yusufoglu<br/>
v0.9.13 (2020-05-21) if string more 160 chars, save as inlineStr<br/>
v0.9.12 (2020-05-21) readme fixed<br/>
v0.9.11 (2020-05-21) removed XML unimportant attributes<br/>
v0.9.10 (2020-05-20) initial release

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 45 KiB

File diff suppressed because it is too large Load Diff

BIN
styles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB