| 1 |
# Welcome to PhpSpreadsheet's documentation |
| 2 |
|
| 3 |
 |
| 4 |
|
| 5 |
PhpSpreadsheet is a library written in pure PHP and providing a set of |
| 6 |
classes that allow you to read from and to write to different |
| 7 |
spreadsheet file formats, like Excel and LibreOffice Calc. |
| 8 |
|
| 9 |
## File formats supported |
| 10 |
|
| 11 |
|Format |Reading|Writing| |
| 12 |
|--------------------------------------------|:-----:|:-----:| |
| 13 |
|Open Document Format/OASIS (.ods) | ✓ | ✓ | |
| 14 |
|Office Open XML (.xlsx) Excel 2007 and above| ✓ | ✓ | |
| 15 |
|BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ | |
| 16 |
|BIFF 5 (.xls) Excel 95 | ✓ | | |
| 17 |
|SpreadsheetML (.xml) Excel 2003 | ✓ | | |
| 18 |
|Gnumeric | ✓ | | |
| 19 |
|HTML | ✓ | ✓ | |
| 20 |
|SYLK | ✓ | | |
| 21 |
|CSV | ✓ | ✓ | |
| 22 |
|PDF (using either the TCPDF, Dompdf or mPDF libraries, which need to be installed separately)| | ✓ | |
| 23 |
|
| 24 |
# Getting started |
| 25 |
|
| 26 |
## Software requirements |
| 27 |
|
| 28 |
The following software is required to develop using PhpSpreadsheet: |
| 29 |
|
| 30 |
- PHP version 5.6 or newer |
| 31 |
- PHP extension php\_zip enabled |
| 32 |
- PHP extension php\_xml enabled |
| 33 |
- PHP extension php\_gd2 enabled (if not compiled in) |
| 34 |
|
| 35 |
### PHP version support |
| 36 |
|
| 37 |
Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version |
| 38 |
|
| 39 |
## Installation |
| 40 |
|
| 41 |
Use [](https://getcomposer.orgcomposer](https://getcomposer.org](https://getcomposer.org) to install PhpSpreadsheet into your project: |
| 42 |
|
| 43 |
```sh |
| 44 |
composer require phpoffice/phpspreadsheet |
| 45 |
``` |
| 46 |
|
| 47 |
## Hello World |
| 48 |
|
| 49 |
This would be the simplest way to write a spreadsheet: |
| 50 |
|
| 51 |
```php |
| 52 |
<?php |
| 53 |
|
| 54 |
require 'vendor/autoload.php'; |
| 55 |
|
| 56 |
use PhpOffice\PhpSpreadsheet\Spreadsheet; |
| 57 |
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; |
| 58 |
|
| 59 |
$spreadsheet = new Spreadsheet(); |
| 60 |
$sheet = $spreadsheet->getActiveSheet(); |
| 61 |
$sheet->setCellValue('A1', 'Hello World !'); |
| 62 |
|
| 63 |
$writer = new Xlsx($spreadsheet); |
| 64 |
$writer->save('hello world.xlsx'); |
| 65 |
``` |
| 66 |
|
| 67 |
## Learn by example |
| 68 |
|
| 69 |
A good way to get started is to run some of the samples. Serve the samples via |
| 70 |
PHP built-in webserver: |
| 71 |
|
| 72 |
```sh |
| 73 |
php -S localhost:8000 -t vendor/phpoffice/phpspreadsheet/samples |
| 74 |
``` |
| 75 |
|
| 76 |
Then point your browser to: |
| 77 |
|
| 78 |
> http://localhost:8000/ |
| 79 |
|
| 80 |
The samples may also be run directly from the command line, for example: |
| 81 |
|
| 82 |
```sh |
| 83 |
php vendor/phpoffice/phpspreadsheet/samples/Basic/01_Simple.php |
| 84 |
``` |
| 85 |
|
| 86 |
## Learn by documentation |
| 87 |
|
| 88 |
For more in-depth documentation, you may read about an [overview of the |
| 89 |
architecture](./topics/architecture.md), |
| 90 |
[](./topics/creating-spreadsheet.mdcreating a spreadsheet](./topics/creating-spreadsheet.md](./topics/creating-spreadsheet.md), |
| 91 |
[](./topics/worksheets.mdworksheets](./topics/worksheets.md](./topics/worksheets.md), |
| 92 |
[](./topics/accessing-cells.mdaccessing cells](./topics/accessing-cells.md](./topics/accessing-cells.md) and |
| 93 |
[](./topics/reading-and-writing-to-file.mdreading and writing to files](./topics/reading-and-writing-to-file.md](./topics/reading-and-writing-to-file.md). |
| 94 |
|
| 95 |
Or browse the [](https://phpoffice.github.io/PhpSpreadsheet/masterAPI documentation](https://phpoffice.github.io/PhpSpreadsheet/master](https://phpoffice.github.io/PhpSpreadsheet/master). |
| 96 |
|
| 97 |
# Credits |
| 98 |
|
| 99 |
Please refer to the [contributor |
| 100 |
list](https://github.com/PHPOffice/PhpSpreadsheet/graphs/contributors) |
| 101 |
for up-to-date credits. |
| 102 |
|