imtigger / oneexcel
PHP Excel read/write abstraction layer, support PhpSpreadSheet, LibXL, Spout and PHP fputcsv
Installs: 27 048
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 4
Open Issues: 1
Requires
- php: >=5.6.4
- box/spout: ^2.7
- phpoffice/phpspreadsheet: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
Suggests
- ext-excel: Required for LibXL driver
README
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.
Installation
Requirements
- PHP >= 5.6.4
php_zip
,php_xmlreader
,php_simplexml
enabled- (Recommended) LibXL installed &
php_excel
enabled
Composer
OneExcel can only be installed from Composer.
Run the following command:
$ composer require imtigger/oneexcel
Writer
Basic Usage
$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();
Reader
(Version 0.6+)
$excel = OneExcelReaderFactory::create() ->fromFile('excel.xlsx') // ->withDriver(Driver::SPOUT) ->make(); foreach ($excel->row() as $row) { // } $excel->close();
Documents
Known Issues
- 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)