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
|
||||
/datatypes.fw.png
|
||||
/styles.fw.png
|
||||
/.gitignore
|
||||
|
@ -1,5 +1,8 @@
|
||||
# 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)
|
||||
|
||||
|
21
README.md
21
README.md
@ -1,8 +1,10 @@
|
||||
# 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-2021<br/>
|
||||
|
||||
@ -15,7 +17,7 @@ $books = [
|
||||
[618260307, 'The Hobbit', 'J. R. R. Tolkien', 'Houghton Mifflin', 'USA'],
|
||||
[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 screenshot](books.png)
|
||||
@ -46,7 +48,7 @@ $data = [
|
||||
['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)
|
||||
|
||||
@ -66,7 +68,7 @@ $data = [
|
||||
['Right', '<right>Right Text</right>'],
|
||||
['Center + Bold', '<center><b>Name</b></center>']
|
||||
];
|
||||
SimpleXLSXGen::fromArray( $data )
|
||||
Shuchkin\SimpleXLSXGen::fromArray( $data )
|
||||
->setDefaultFont( 'Courier New' )
|
||||
->setDefaultFontSize( 14 )
|
||||
->saveAs('styles_and_tags.xlsx');
|
||||
@ -76,15 +78,16 @@ SimpleXLSXGen::fromArray( $data )
|
||||
### More examples
|
||||
```php
|
||||
// Fluid interface, output to browser for download
|
||||
SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx');
|
||||
Shuchkin\SimpleXLSXGen::fromArray( $books )->downloadAs('table.xlsx');
|
||||
|
||||
// Fluid interface, multiple sheets
|
||||
SimpleXLSXGen::fromArray( $books )->addSheet( $books2 )->download();
|
||||
Shuchkin\SimpleXLSXGen::fromArray( $books )->addSheet( $books2 )->download();
|
||||
|
||||
// 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
|
||||
use Shuchkin\SimpleXLSXGen
|
||||
$xlsx = new SimpleXLSXGen();
|
||||
$xlsx->addSheet( $books, 'Catalog 2021' );
|
||||
$xlsx->addSheet( $books2, 'Stephen King catalog');
|
||||
@ -101,5 +104,5 @@ $data = [
|
||||
['Debug', 123]
|
||||
];
|
||||
|
||||
SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
|
||||
Shuchkin\SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
|
||||
```
|
||||
|
@ -17,6 +17,7 @@
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"ext-mbstring": "*",
|
||||
"ext-zlib": "*"
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Shuchkin;
|
||||
|
||||
/**
|
||||
* Class SimpleXLSXGen
|
||||
* Export data to MS Excel. PHP XLSX generator
|
||||
@ -34,7 +36,6 @@ class SimpleXLSXGen {
|
||||
const A_RIGHT = 2;
|
||||
const A_CENTER = 3;
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$this->curSheet = -1;
|
||||
$this->defaultFont = 'Calibri';
|
||||
@ -556,7 +557,7 @@ class SimpleXLSXGen {
|
||||
} elseif ( is_float( $v ) ) {
|
||||
$vl = mb_strlen( (string) $v );
|
||||
$cv = $v;
|
||||
} elseif ( $v instanceof DateTime ) {
|
||||
} elseif ( $v instanceof \DateTime ) {
|
||||
$vl = 16;
|
||||
$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
|
||||
|
Loading…
Reference in New Issue
Block a user