mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
1.1.10
This commit is contained in:
parent
40eb704eb2
commit
121f1222c2
3
.gitignore
vendored
3
.gitignore
vendored
@ -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
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
21
README.md
21
README.md
@ -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');
|
||||||
```
|
```
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"php": ">=5.4",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"ext-zlib": "*"
|
"ext-zlib": "*"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace Shuchkin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SimpleXLSXGen
|
* Class SimpleXLSXGen
|
||||||
* Export data to MS Excel. PHP XLSX generator
|
* Export data to MS Excel. PHP XLSX generator
|
||||||
@ -34,7 +36,6 @@ class SimpleXLSXGen {
|
|||||||
const A_RIGHT = 2;
|
const A_RIGHT = 2;
|
||||||
const A_CENTER = 3;
|
const A_CENTER = 3;
|
||||||
|
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->curSheet = -1;
|
$this->curSheet = -1;
|
||||||
$this->defaultFont = 'Calibri';
|
$this->defaultFont = 'Calibri';
|
||||||
@ -556,7 +557,7 @@ class SimpleXLSXGen {
|
|||||||
} elseif ( is_float( $v ) ) {
|
} elseif ( is_float( $v ) ) {
|
||||||
$vl = mb_strlen( (string) $v );
|
$vl = mb_strlen( (string) $v );
|
||||||
$cv = $v;
|
$cv = $v;
|
||||||
} elseif ( $v instanceof DateTime ) {
|
} elseif ( $v instanceof \DateTime ) {
|
||||||
$vl = 16;
|
$vl = 16;
|
||||||
$cv = $this->date2excel( $v->format('Y'), $v->format('m'), $v->format('d'), $v->format('H'), $v->format('i'), $v->format('s') );
|
$cv = $this->date2excel( $v->format('Y'), $v->format('m'), $v->format('d'), $v->format('H'), $v->format('i'), $v->format('s') );
|
||||||
$N = self::N_DATETIME; // [22] m/d/yy h:mm
|
$N = self::N_DATETIME; // [22] m/d/yy h:mm
|
||||||
|
Loading…
Reference in New Issue
Block a user