Compare commits
108 Commits
Author | SHA1 | Date |
---|---|---|
Sergey Shuchkin | 306aa7dad9 | |
Oleg Kosarev | dc974d2ef9 | |
Sergey Shuchkin | c78750ffe7 | |
Sergey Shuchkin | 9cdb08ee98 | |
Oleg Kosarev | 32276c4486 | |
Oleg Kosarev | 3646e702ae | |
Oleg Kosarev | 81120e6f72 | |
Oleg Kosarev | c449813bb1 | |
Oleg Kosarev | 4f4ac11dae | |
Sergey Shuchkin | 1fa442f667 | |
Sergey Shuchkin | 1ee4e5eb50 | |
Sergey Shuchkin | e02d764d0d | |
Sergey Shuchkin | f65e57c735 | |
Javier | 4f3d09925c | |
Javier | 95da6b5c05 | |
Sergey Shuchkin | b3060667f2 | |
Sergey Shuchkin | cb19defa37 | |
Sergey Shuchkin | 5a154b24f9 | |
Sergey Shuchkin | b46f63fce7 | |
Andrew Robinson | bb09c0d38c | |
Andrew Robinson | 91ca3f6fff | |
Sergey Shuchkin | 59cdc277ee | |
Sergey Shuchkin | 343e549ca1 | |
Sergey Shuchkin | 61e55d6277 | |
Javier | 9b52ff6ac7 | |
Javier | 317fb0982e | |
Sergey Shuchkin | 765001ae96 | |
Sergey Shuchkin | c2f3077812 | |
Sergey Shuchkin | af53c754c3 | |
Sergey Shuchkin | 6d7608f8ca | |
Sergey Shuchkin | 80091bb9be | |
Sergey Shuchkin | 21b1d9a4b8 | |
Sergey Shuchkin | c1434378bc | |
Sergey Shuchkin | 75252a4a0c | |
Robin | f9d5480bb3 | |
Sergey Shuchkin | aff0fa243d | |
Sergey Shuchkin | 82b0db1f8e | |
Sergey Shuchkin | aef6ee4935 | |
Sergey Shuchkin | 053574d1e1 | |
Sergey Shuchkin | f74163d311 | |
Sergey Shuchkin | 0bf38275d7 | |
Sergey Shuchkin | 459b1666e9 | |
Sergey Shuchkin | b63c66f8e9 | |
Sergey Shuchkin | 1b5701a07f | |
Sergey Shuchkin | 199e5691e7 | |
Sergey Shuchkin | c54b314328 | |
Sergey Shuchkin | 6db113f753 | |
Sergey Shuchkin | ff3f016358 | |
Sergey Shuchkin | bcd3586731 | |
Sergey Shuchkin | 402c6b9417 | |
Sergey Shuchkin | 5840fd5285 | |
Andrew Robinson | 4543922330 | |
Andrew Robinson | d49f8996df | |
mrjemson | 5309e6a002 | |
mrjemson | ab28bc319d | |
mrjemson | e145bd5777 | |
mrjemson | 2ee7237016 | |
mrjemson | a0a932e2f5 | |
mrjemson | fc884044ac | |
mrjemson | d84c842d38 | |
mrjemson | 0dafc8bf9e | |
mrjemson | 82f19a9f35 | |
mrjemson | 139602c340 | |
mrjemson | ac34d8f527 | |
Sergey Shuchkin | c55d77c63e | |
Sergey Shuchkin | c3d10db967 | |
Sergey Shuchkin | 1c206d06bc | |
Sergey Shuchkin | f0cbc32af9 | |
Sergey Shuchkin | 121f1222c2 | |
Sergey Shuchkin | 40eb704eb2 | |
Sergey Shuchkin | 4005e8cbd1 | |
appel | 9d82a43fe6 | |
Sergey Shuchkin | 9a555eef9b | |
Sergey Shuchkin | 79ffbb5e30 | |
Sergey Shuchkin | 868cf8edc0 | |
Sergey Shuchkin | 7f5c584772 | |
Sergey Shuchkin | 5b58103e3b | |
Sergey Shuchkin | 6d49a90fe7 | |
Sergey Shuchkin | c8a94d552a | |
Sergey Shuchkin | c9fa7da689 | |
Sergey Shuchkin | 0d059fdf6e | |
Sergey Shuchkin | dcb5f8ad65 | |
Sergey Shuchkin | f970452779 | |
Sergey Shuchkin | 6abd0286bb | |
Sergey Shuchkin | 8bfbe078db | |
Sergey Shuchkin | 6ece83f9ce | |
Sergey Shuchkin | 4f375a4c30 | |
Sergey Shuchkin | 41c6e7ca51 | |
Marc Robledo | ef7b0fff02 | |
Sergey Shuchkin | 860da7f493 | |
Sergey Shuchkin | eeec88dbf0 | |
Sergey Shuchkin | 1e866f82bf | |
Sergey Shuchkin | 17098b57ef | |
Sergey Shuchkin | ab49ffadd7 | |
Sergey Shuchkin | 99c6be2fb4 | |
Sergey Shuchkin | d1ccfc6f17 | |
Sergey Shuchkin | 21db9eca96 | |
Sergey Shuchkin | 8b6d0505b5 | |
Sergey Shuchkin | 205396b998 | |
Sergey Shuchkin | 42558401ef | |
Sergey Shuchkin | 07d3e91c28 | |
Savino Rapillo | 3abb47b9b4 | |
Sergey Shuchkin | 0fc338d802 | |
Sergey Shuchkin | a8093b9d8e | |
Sergey Shuchkin | a9219575df | |
Sergey Shuchkin | 476e083f29 | |
Julien Turbide | db598d4ee4 | |
Sergey Shuchkin | a551f6485b |
|
@ -1 +1,5 @@
|
|||
vendor*
|
||||
/vendor*
|
||||
/books.fw.png
|
||||
/datatypes.fw.png
|
||||
/styles.fw.png
|
||||
/.gitignore
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
# Changelog
|
||||
|
||||
## 1.3.15 (2023-04-19)
|
||||
* added meta: setTitle, setSubject, setAuthor, setCompany, setManager, setKeywords, setDescription, setCategory, setApplication, setLastModifiedBy. Thx [Oleg Kosarev](https://github.com/DevOlegKosarev)
|
||||
|
||||
## 1.3.14 (2023-04-18)
|
||||
* fixed "This action doesn't work on multiple selection" error
|
||||
|
||||
## 1.3.13 (2023-04-11)
|
||||
* ```$xlsx->rightToLeft()``` - RTL mode. Column A is on the far right, Column B is one column left of Column A, and so on. Also, information in cells is displayed in the Right to Left format.
|
||||
|
||||
## 1.3.12 (2023-03-31)
|
||||
* ```<style font-size="32">Big Text</style>``` - font size in cells, thx [Andrew Robinson](https://github.com/mrjemson)
|
||||
|
||||
## 1.3.11 (2023-03-28)
|
||||
* freezePanes( corner_cell ) - freezePanes to keep an area of a worksheet visible while you scroll, corner_cell is not included, thx [Javier](https://github.com/xaviermdq)
|
||||
|
||||
## 1.3.10 (2022-12-14)
|
||||
* added borders ```<style border="medium">Black Border</style>``` see colored [examples](https://github.com/shuchkin/simplexlsxgen#formatting)
|
||||
* added formulas ```<f v="100">SUM(B1:B10)</f>``` see [examples](https://github.com/shuchkin/simplexlsxgen#data-types)
|
||||
* added internal links ```<a href="sheet2!A1">Go to page 2</a>```
|
||||
* added custom number formats ```<style nf=""£"#,##0.00">500</style>```
|
||||
* added 3 currencies ```$data = [ ['$100.23', '2000.00 €', '1200.30 ₽'] ];```
|
||||
|
||||
## 1.2.16 (2022-08-12)
|
||||
* added `autoFilter( $range )`
|
||||
```php
|
||||
$xlsx->autoFilter('A2:B10');
|
||||
```
|
||||
* fixed `0%` bug
|
||||
|
||||
## 1.2.15 (2022-07-05)
|
||||
* added wrap words in long strings `<wraptext>long long line</wraptext>`
|
||||
|
||||
## 1.2.14 (2022-06-10)
|
||||
* added example [JS array to Excel (AJAX)](https://github.com/shuchkin/simplexlsxgen#js-array-to-excel-ajax)
|
||||
|
||||
## 1.2.13 (2022-06-01)
|
||||
* setColWidth(num_col_started_1, size_in_chars) - set column width
|
||||
|
||||
## 1.2.12 (2022-05-17)
|
||||
* Vertical align (tags top,middle,bottom) `<bottom>12345</bottom>`
|
||||
|
||||
## 1.2.11 (2022-05-01)
|
||||
* Row height `<style height="50">Custom row height 50</style>`
|
||||
|
||||
|
||||
## 1.2.10 (2022-04-24)
|
||||
* Added colors `<style color="#FFFF00" bgcolor="#00FF00">Yellow text on blue background</style>`, thx [mrjemson](https://github.com/mrjemson)
|
||||
|
||||
## 1.1.12 (2022-03-15)
|
||||
* Added `$xlsx->mergeCells('A1:C1')`
|
||||
|
||||
## 1.1.11 (2022-02-05)
|
||||
* sheet name maximum length is 31 chars, mb_substr used now
|
||||
* license fixed
|
||||
|
||||
## 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 " and & in sheets names
|
||||
|
||||
## 1.0.16 (2021-07-01)
|
||||
* Fixed "&" 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
|
219
README.md
219
README.md
|
@ -1,12 +1,14 @@
|
|||
# SimpleXLSXGen class 0.9.18 (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-2023<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,13 +17,10 @@ $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');
|
||||
$xlsx = Shuchkin\SimpleXLSXGen::fromArray( $books );
|
||||
$xlsx->saveAs('books.xlsx'); // or downloadAs('books.xlsx') or $xlsx_content = (string) $xlsx
|
||||
```
|
||||
![XLSX screenshot](books.png)
|
||||
```
|
||||
// SimpleXLSXGen::download() or SimpleXSLSXGen::downloadAs('table.xlsx');
|
||||
```
|
||||
|
||||
## Installation
|
||||
The recommended way to install this library is [through Composer](https://getcomposer.org).
|
||||
|
@ -34,40 +33,198 @@ $ composer require shuchkin/simplexlsxgen
|
|||
or download class [here](https://github.com/shuchkin/simplexlsxgen/blob/master/src/SimpleXLSXGen.php)
|
||||
|
||||
## Examples
|
||||
Use UTF-8 encoded strings.
|
||||
### Data types
|
||||
```php
|
||||
$data = [
|
||||
['Integer', 123],
|
||||
['Float', 12.35],
|
||||
['Procent', '12%'],
|
||||
['Percent', '12%'],
|
||||
['Currency $', '$500.67'],
|
||||
['Currency €', '200 €'],
|
||||
['Currency ₽', '1200.30 ₽'],
|
||||
['Currency (other)', '<style nf=""£"#,##0.00">500</style>'],
|
||||
['Currency Float (other)', '<style nf="#,##0.00\ [$£-1];[Red]#,##0.00\ [$£-1]">500.250</style>'],
|
||||
['Datetime', '2020-05-20 02:38:00'],
|
||||
['Date','2020-05-20'],
|
||||
['Time','02:38:00'],
|
||||
['String', 'See SimpleXLSXGen column autosize feature']
|
||||
['Date', '2020-05-20'],
|
||||
['Time', '02:38:00'],
|
||||
['Datetime PHP', new DateTime('2021-02-06 21:07:00')],
|
||||
['String', 'Very long UTF-8 string in autoresized column'],
|
||||
['Formula', '<f v="135.35">SUM(B1:B2)</f>'],
|
||||
['Hyperlink', 'https://github.com/shuchkin/simplexlsxgen'],
|
||||
['Hyperlink + Anchor', '<a href="https://github.com/shuchkin/simplexlsxgen">SimpleXLSXGen</a>'],
|
||||
['Internal link', '<a href="sheet2!A1">Go to second page</a>'],
|
||||
['RAW string', "\0" . '2020-10-04 16:02:00']
|
||||
];
|
||||
SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx');
|
||||
SimpleXLSXGen::fromArray($data)->saveAs('datatypes.xlsx');
|
||||
```
|
||||
![XLSX screenshot](datatypes.png)
|
||||
|
||||
### Debug
|
||||
### 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>'],
|
||||
['Green', '<style color="#00FF00">12345.67</style>'],
|
||||
['Bold Red Text', '<b><style color="#FF0000">12345.67</style></b>'],
|
||||
['Size 32 Font', '<style font-size="32">Big Text</style>'],
|
||||
['Blue Text and Yellow Fill', '<style bgcolor="#FFFF00" color="#0000FF">12345.67</style>'],
|
||||
['Border color', '<style border="#000000">Black Thin Border</style>'],
|
||||
['<top>Border style</top>','<style border="medium"><wraptext>none, thin, medium, dashed, dotted, thick, double, hair, mediumDashed, dashDot,mediumDashDot, dashDotDot, mediumDashDotDot, slantDashDot</wraptext></style>'],
|
||||
['Border sides', '<style border="none dotted#0000FF medium#FF0000 double">Top No + Right Dotted + Bottom medium + Left double</style>'],
|
||||
['Left', '<left>12345.67</left>'],
|
||||
['Center', '<center>12345.67</center>'],
|
||||
['Right', '<right>Right Text</right>'],
|
||||
['Center + Bold', '<center><b>Name</b></center>'],
|
||||
['Row height', '<style height="50">Row Height = 50</style>'],
|
||||
['Top', '<style height="50"><top>Top</top></style>'],
|
||||
['Middle + Center', '<style height="50"><middle><center>Middle + Center</center></middle></style>'],
|
||||
['Bottom + Right', '<style height="50"><bottom><right>Bottom + Right</right></bottom></style>'],
|
||||
['<center>MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS MERGE CELLS</center>', null],
|
||||
['<top>Word wrap</top>', "<wraptext>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</wraptext>"],
|
||||
];
|
||||
SimpleXLSXGen::fromArray($data)
|
||||
->setDefaultFont('Courier New')
|
||||
->setDefaultFontSize(14)
|
||||
->setColWidth(1, 35)
|
||||
->mergeCells('A20:B20')
|
||||
->saveAs('styles_and_tags.xlsx');
|
||||
```
|
||||
![XLSX screenshot](styles.png)
|
||||
|
||||
### RAW Strings
|
||||
Prefix #0 cell value (use double quotes).
|
||||
```php
|
||||
$PushkinDOB = '1799-07-06';
|
||||
$data = [
|
||||
['Datetime as raw string', "\0".'2023-01-09 11:16:34'],
|
||||
['Date as raw string', "\0".$PushkinDOB],
|
||||
['Disable type detection', "\0".'+12345'],
|
||||
['Insert greater/less them simbols', "\0".'20- short term: <6 month'],
|
||||
|
||||
];
|
||||
SimpleXLSXGen::fromArray($data)
|
||||
->saveAs('test_rawstrings.xlsx');
|
||||
```
|
||||
|
||||
### 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();
|
||||
|
||||
// Autofilter
|
||||
$xlsx->autoFilter('A1:B10');
|
||||
|
||||
// Freeze rows and columns from top-left corner up to, but not including,
|
||||
// the row and column of the indicated cell
|
||||
$xlsx->freezePanes('C3');
|
||||
|
||||
// RTL mode
|
||||
// Column A is on the far right, Column B is one column left of Column A, and so on. Also, information in cells is displayed in the Right to Left format.
|
||||
$xlsx->rightToLeft();
|
||||
|
||||
// Set Meta Data Files
|
||||
// this data in propertis Files and Info file in Office
|
||||
$xlsx->setAuthor('Sergey Shuchkin <sergey.shuchkin@gmail.com>')
|
||||
->setCompany('Microsoft <info@microsoft.com>')
|
||||
->setManager('Bill Gates <bill.gates@microsoft.com>')
|
||||
->setLastModifiedBy("Sergey Shuchkin <sergey.shuchkin@gmail.com>")
|
||||
->setTitle('This is Title')
|
||||
->setSubject('This is Subject')
|
||||
->setKeywords('Keywords1, Keywords2, Keywords3, KeywordsN')
|
||||
->setDescription('This is Description')
|
||||
->setCategory('This is Сategory')
|
||||
->setApplication('Shuchkin\SimpleXLSXGen')
|
||||
```
|
||||
### JS array to Excel (AJAX)
|
||||
```php
|
||||
<?php // array2excel.php
|
||||
if (isset($_POST['array2excel'])) {
|
||||
require __DIR__.'/simplexlsxgen/src/SimpleXLSXGen.php';
|
||||
$data = json_decode($_POST['array2excel'], false);
|
||||
\Shuchkin\SimpleXLSXGen::fromArray($data)->downloadAs('file.xlsx');
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>JS array to Excel</title>
|
||||
</head>
|
||||
<script>
|
||||
|
||||
function array2excel() {
|
||||
var books = [
|
||||
["ISBN", "title", "author", "publisher", "ctry"],
|
||||
[618260307, "The Hobbit", "J. R. R. Tolkien", "Houghton Mifflin", "USA"],
|
||||
[908606664, "Slinky Malinki", "Lynley Dodd", "Mallinson Rendel", "NZ"]
|
||||
];
|
||||
var json = JSON.stringify(books);
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
|
||||
request.onload = function () {
|
||||
if (this.status === 200) {
|
||||
var file = new Blob([this.response], {type: this.getResponseHeader('Content-Type')});
|
||||
var fileURL = URL.createObjectURL(file);
|
||||
var filename = "", m;
|
||||
var disposition = this.getResponseHeader('Content-Disposition');
|
||||
if (disposition && (m = /"([^"]+)"/.exec(disposition)) !== null) {
|
||||
filename = m[1];
|
||||
}
|
||||
var a = document.createElement("a");
|
||||
if (typeof a.download === 'undefined') {
|
||||
window.location = fileURL;
|
||||
} else {
|
||||
a.href = fileURL;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
} else {
|
||||
alert("Error: " + this.status + " " + this.statusText);
|
||||
}
|
||||
}
|
||||
|
||||
request.open('POST', "array2excel.php");
|
||||
request.responseType = "blob";
|
||||
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
request.send("array2excel=" + encodeURIComponent(json));
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<input type="button" onclick="array2excel()" value="array2excel" />
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## 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.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
|
BIN
books.png
BIN
books.png
Binary file not shown.
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 22 KiB |
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "shuchkin/simplexlsxgen",
|
||||
"description": "Export data to Excel XLSx file. PHP XLSX generator.",
|
||||
"keywords": ["php", "excel", "xlsx", "generator", "creator", "backend"],
|
||||
"keywords": ["php", "excel", "xlsx", "generator", "writer", "creator", "backend"],
|
||||
"homepage": "https://github.com/shuchkin/simplexlsxgen",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
|
@ -17,6 +17,7 @@
|
|||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4",
|
||||
"ext-mbstring": "*",
|
||||
"ext-zlib": "*"
|
||||
}
|
||||
|
|
BIN
datatypes.png
BIN
datatypes.png
Binary file not shown.
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 14 KiB |
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Lukas Martinelli
|
||||
Copyright (c) 2020-2022 Sergey Shuchkin sergey.shuchkin@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 190 KiB |
Loading…
Reference in New Issue