I made a documentation change and noticed that the result when browsed locally did not quite match what is seen when browsing from the web. After some research, I found https://github.com/mkdocs/mkdocs/issues/2028 That described my situation well and suggested adding an extra javascript script to the configuration. This worked exactly as desired on my local machine. This accounts for the presence of extrajs.js and mkdocs.yml in this request. In addition to the display problem, "mkdocs build" generates the documentation into a directory which is not ignored by git. I added that directory to .gitignore as part of this request. Finally, since I don't know how exactly the documentation makes it to production, I made an insignificant change to one doc file as a sanity check.
3.3 KiB
Welcome to PhpSpreadsheet's documentation
PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.
File formats supported
| Format | Reading | Writing |
|---|---|---|
| Open Document Format/OASIS (.ods) | ✓ | ✓ |
| Office Open XML (.xlsx) Excel 2007 and above | ✓ | ✓ |
| BIFF 8 (.xls) Excel 97 and above | ✓ | ✓ |
| BIFF 5 (.xls) Excel 95 | ✓ | |
| SpreadsheetML (.xml) Excel 2003 | ✓ | |
| Gnumeric | ✓ | |
| HTML | ✓ | ✓ |
| SYLK | ✓ | |
| CSV | ✓ | ✓ |
| PDF (using either the TCPDF, Dompdf or mPDF libraries, which need to be installed separately) | ✓ |
Getting started
Software requirements
PHP version 7.2 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by
composer. See the require section of the composer.json file
for details.
PHP version support
Support for PHP versions will only be maintained for a period of six months beyond the end of life of that PHP version.
Installation
Use composer to install PhpSpreadsheet into your project:
composer require phpoffice/phpspreadsheet
Or also download the documentation and samples if you plan to use them:
composer require phpoffice/phpspreadsheet --prefer-source
Hello World
This would be the simplest way to write a spreadsheet:
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');
Learn by example
A good way to get started is to run some of the samples. Don't forget to download them via --prefer-source composer
flag. And then serve them via PHP built-in webserver:
php -S localhost:8000 -t vendor/phpoffice/phpspreadsheet/samples
Then point your browser to:
The samples may also be run directly from the command line, for example:
php vendor/phpoffice/phpspreadsheet/samples/Basic/01_Simple.php
Learn by documentation
For more documentation in depth, you may read about an overview of the architecture, creating a spreadsheet, worksheets, accessing cells and reading and writing to files.
Or browse the API documentation.
Credits
Please refer to the contributor list for up-to-date credits.