PHP Excel read/write abstraction layer, support PhpSpreadSheet, LibXL, Spout and PHP fputcsv
/fgetcsv
Targets to simplify server compatibility issue between Excel libraries and performance issue in huge files.
Ideal for simple-formatted but huge spreadsheet files such as reporting.
- PHP >= 5.6.4
php_zip
,php_xmlreader
,php_simplexml
enabled- (Recommended) LibXL installed &
php_excel
enabled
OneExcel can only be installed from Composer.
Run the following command:
$ composer require imtigger/oneexcel
$excel = OneExcelWriterFactory::create()
->toFile('excel.xlsx')
->make();
$excel->writeCell(1, 0, 'Hello');
$excel->writeCell(2, 1, 'World');
$excel->writeCell(3, 2, 3.141592653, ColumnType::NUMERIC);
$excel->writeRow(4, ['One', 'Excel']);
$excel->writeCell(4, 2, 'Test');
$excel->output();
```Selection](driver.md)
### Advanced Usage
```php
$excel = OneExcelWriterFactory::create()
->fromFile('template.xlsx', Format::XLSX)
->toStream('excel.csv', Format::CSV)
->withDriver(Driver::SPOUT)
->make();
$excel->writeCell(1, 0, 'Hello');
$excel->writeCell(2, 1, 'World');
$excel->writeCell(3, 2, 3.141592653, ColumnType::NUMERIC);
$excel->writeRow(4, ['One', 'Excel']);
$excel->writeCell(4, 2, 'Test');
$excel->output();
(Version 0.6+)
$excel = OneExcelReaderFactory::create()
->fromFile('excel.xlsx')
// ->withDriver(Driver::SPOUT)
->make();
foreach ($excel->row() as $row) {
//
}
$excel->close();
- Spout reader driver output empty rows as SINGLE column (Upstream problem?)
- Spout do not support random read/write rows (Upstream limitation, Won't fix)
- Spout do not support formula (Upstream limitation, Won't fix)
- fputcsv driver ignores all ColumnType::* (File-type limitation, Won't fix)