Update readme with doc links and better package description (#26)
* Update readme with doc links and better package description * Update readme with doc links and better package description * Update readme with doc links and better package description * Update readme with doc links and better package description * Update README.md Co-authored-by: Alexey Kopytko <alexey@kopytko.com> * Update README.md Co-authored-by: Alexey Kopytko <alexey@kopytko.com> * Update README.md Co-authored-by: Alexey Kopytko <alexey@kopytko.com> * Update README.md Co-authored-by: Alexey Kopytko <alexey@kopytko.com> * Update README.md Co-authored-by: Alexey Kopytko <alexey@kopytko.com>
This commit is contained in:
parent
a386acb9f4
commit
2809d7d97b
128
README.md
128
README.md
|
|
@ -2,12 +2,19 @@
|
|||
[](https://packagist.org/packages/pear/spreadsheet_excel_writer)
|
||||
[](https://coveralls.io/github/pear/Spreadsheet_Excel_Writer?branch=master)
|
||||
|
||||
# Spreadsheet_Excel_Writer
|
||||
|
||||
This package is [Spreadsheet_Excel_Writer](http://pear.php.net/package/Spreadsheet_Excel_Writer) and has been migrated from [svn.php.net](https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer).
|
||||
|
||||
Please report all new issues [via the PEAR bug tracker](http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Spreadsheet_Excel_Writer&order_by=ts1&direction=DESC&status=Open).
|
||||
|
||||
If this package is marked as unmaintained and you have fixes, please submit your pull requests and start discussion on the pear-qa mailing list.
|
||||
|
||||
|
||||
# Installation
|
||||
|
||||
## Pear
|
||||
|
||||
To test, run
|
||||
|
||||
$ phpunit
|
||||
|
|
@ -35,3 +42,124 @@ To install from Composer
|
|||
To install the latest development version
|
||||
|
||||
$ composer require pear/spreadsheet_excel_writer:dev-master
|
||||
|
||||
# Features
|
||||
|
||||
- writing Excel (.XLS) spreadsheets
|
||||
- support: strings (with formatting for text and cells), formulas, images (BMP)
|
||||
|
||||
# Limitations
|
||||
Library support only 2 types of format for writing XLS, also known as Binary Interchange File Format ([BIFF](https://www.openoffice.org/sc/excelfileformat.pdf)):
|
||||
- BIFF5 (Excel 5.0 - Excel 95)
|
||||
- BIFF8 (Excel 98 - Excel 2003)
|
||||
|
||||
**Some important limitations:**
|
||||
|
||||
| Limit | BIFF5 | BIFF8 |
|
||||
| --- | --- | --- |
|
||||
| Maximum number of rows | 16384 | 65535 |
|
||||
| Maximum number of columns | 255 | 255 |
|
||||
| Maximum data size of a record | 2080 bytes | 8224 bytes |
|
||||
| Unicode support | CodePage based character encoding | UTF-16LE |
|
||||
|
||||
Explanation of formats and specifications you can find [here](https://www.loc.gov/preservation/digital/formats/fdd/fdd000510.shtml) (section "Useful references")
|
||||
|
||||
|
||||
# Usage
|
||||
|
||||
## Basic usage
|
||||
```php
|
||||
use Spreadsheet_Excel_Writer;
|
||||
|
||||
|
||||
$filePath = __DIR__ . '/output/out.xls';
|
||||
$xls = new Spreadsheet_Excel_Writer($filePath);
|
||||
|
||||
// 8 = BIFF8
|
||||
$xls->setVersion(8);
|
||||
|
||||
$sheet = $xls->addWorksheet('info');
|
||||
|
||||
// only available with BIFF8
|
||||
$sheet->setInputEncoding('UTF-8');
|
||||
|
||||
$headers = [
|
||||
'id',
|
||||
'name',
|
||||
'email',
|
||||
'code',
|
||||
'address'
|
||||
];
|
||||
|
||||
$row = $col = 0;
|
||||
foreach ($headers as $header) {
|
||||
$sheet->write($row, $col, $header);
|
||||
$col++;
|
||||
}
|
||||
|
||||
for ($id = 1; $id < $max; $id++) {
|
||||
$data = [
|
||||
'id' => $id,
|
||||
'name' => 'Name Surname',
|
||||
'email' => 'mail@gmail.com',
|
||||
'password' => 'cfcd208495d565ef66e7dff9f98764da',
|
||||
'address' => '00000 North Tantau Avenue. Cupertino, CA 12345. (000) 1234567'
|
||||
];
|
||||
$sheet->writeRow($id, 0, $data);
|
||||
}
|
||||
|
||||
$xls->close();
|
||||
```
|
||||
|
||||
## Format usage
|
||||
```php
|
||||
$xls = new Spreadsheet_Excel_Writer();
|
||||
|
||||
$titleFormat = $xls->addFormat();
|
||||
$titleFormat->setFontFamily('Helvetica');
|
||||
$titleFormat->setBold();
|
||||
$titleFormat->setSize(10);
|
||||
$titleFormat->setColor('orange');
|
||||
$titleFormat->setBorder(1);
|
||||
$titleFormat->setBottom(2);
|
||||
$titleFormat->setBottomColor(44);
|
||||
$titleFormat->setAlign('center');
|
||||
|
||||
$sheet = $xls->addWorksheet('info');
|
||||
|
||||
$sheet->write(0, 0, 'Text 123', $titleFormat);
|
||||
```
|
||||
|
||||
## Header usage (Sending HTTP header for download dialog)
|
||||
```php
|
||||
$xls = new Spreadsheet_Excel_Writer();
|
||||
$xls->send('excel_'.date("Y-m-d__H:i:s").'.xls');
|
||||
```
|
||||
|
||||
|
||||
# Performance
|
||||
|
||||
**Platform:**
|
||||
Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
|
||||
PHP 7.4
|
||||
|
||||
**Test case:**
|
||||
Write xls (BIFF8 format, UTF-8), by 5 cells (1x number, 4x string without format/styles, average line length = 120 char) in each row
|
||||
|
||||
**Estimated performance:**
|
||||
|
||||
| Number of rows | Time (seconds) | Peak memory usage (MB) |
|
||||
| --- | --- | --- |
|
||||
| 10000 | 0.2 | 4 |
|
||||
| 20000 | 0.4 | 4 |
|
||||
| 30000 | 0.6 | 6 |
|
||||
| 40000 | 0.8 | 6 |
|
||||
| 50000 | 1.0 | 8 |
|
||||
| 65534 | 1.2 | 8 |
|
||||
|
||||
# Alternative solutions
|
||||
|
||||
- [PHPOffice/PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet)
|
||||
File formats supported: https://phpspreadsheet.readthedocs.io/en/latest/
|
||||
- [box/spout](https://github.com/box/spout)
|
||||
File formats supported: https://opensource.box.com/spout/
|
||||
|
|
|
|||
Loading…
Reference in New Issue