2016-12-03 15:00:54 +00:00
|
|
|
# Welcome to PhpSpreadsheet's documentation
|
2016-11-27 10:34:17 +00:00
|
|
|
|
|
|
|
![Logo](./assets/logo.svg)
|
|
|
|
|
2016-12-03 15:00:54 +00:00
|
|
|
PhpSpreadsheet is a library written in pure PHP and providing a set of
|
|
|
|
classes that allow you to read from and to write to different
|
|
|
|
spreadsheet file formats, like Excel and LibreOffice Calc.
|
2016-11-27 10:34:17 +00:00
|
|
|
|
2016-12-03 13:16:45 +00:00
|
|
|
# Getting started
|
|
|
|
|
|
|
|
## Software requirements
|
|
|
|
|
|
|
|
The following software is required to develop using PhpSpreadsheet:
|
|
|
|
|
2017-01-23 02:44:16 +00:00
|
|
|
- PHP version 5.6 or newer
|
2017-03-11 02:48:46 +00:00
|
|
|
- PHP extension php\_zip enabled
|
2016-12-03 15:00:54 +00:00
|
|
|
- PHP extension php\_xml enabled
|
|
|
|
- PHP extension php\_gd2 enabled (if not compiled in)
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
**Note:** PHP 5.6.29 has [a bug](https://bugs.php.net/bug.php?id=73530) that
|
2017-02-14 05:29:07 +00:00
|
|
|
prevents SQLite3 caching to work correctly. Use a newer (or older) versions of
|
|
|
|
PHP if you need SQLite3 caching.
|
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
## Installation
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
Use [composer](https://getcomposer.org/) to install PhpSpreadsheet into your project:
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
```sh
|
|
|
|
composer require phpoffice/phpspreadsheet
|
2016-12-03 13:16:45 +00:00
|
|
|
```
|
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
**Note:** If you want the unreleased, unstable development version use
|
|
|
|
`phpoffice/phpspreadsheet:dev-develop` instead.
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
## Hello World
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
This would be the simplest way to write a spreadsheet:
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
```php
|
2016-12-03 13:16:45 +00:00
|
|
|
<?php
|
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
require 'vendor/autoload.php';
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
|
|
$sheet->setCellValue('A1', 'Hello World !');
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
$writer = new Xlsx($spreadsheet);
|
|
|
|
$writer->save('hello world.xlsx');
|
2016-12-03 13:16:45 +00:00
|
|
|
```
|
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
## Learn by example
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
A good way to get started is to run some of the samples. Serve the sample via
|
|
|
|
PHP built-in webserver;
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
```sh
|
|
|
|
php -S localhost:8000 -t vendor/phpoffice/phpspreadsheet/samples
|
2016-12-03 13:16:45 +00:00
|
|
|
```
|
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
Then point your browser to:
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
> http://localhost:8000/
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
The samples may also be run directly from the command line, for example:
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
```sh
|
|
|
|
php vendor/phpoffice/phpspreadsheet/samples/01_Simple.php
|
2016-12-03 13:16:45 +00:00
|
|
|
```
|
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
## Learn by documentation
|
2016-12-03 13:16:45 +00:00
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
For more in-depth documentation, you may read about an [overview of the
|
|
|
|
architecture](./topics/architecture.md),
|
|
|
|
[creating a spreadsheet](./topics/creating-spreadsheet.md),
|
|
|
|
[worksheets](./topics/worksheets.md),
|
|
|
|
[accessing cells](./topics/accessing-cells.md) and
|
|
|
|
[reading and writing to files](./topics/reading-and-writing-to-file.md).
|
2016-12-03 13:16:45 +00:00
|
|
|
|
|
|
|
# Credits
|
|
|
|
|
2017-03-13 02:33:02 +00:00
|
|
|
Please refer to the [contributor
|
2016-12-03 15:00:54 +00:00
|
|
|
list](https://github.com/PHPOffice/PhpSpreadsheet/graphs/contributors)
|
|
|
|
for up-to-date credits.
|