vdbf / import-php
Simple importer written in PHP >= 5.3
dev-master
2015-09-10 09:03 UTC
Requires
- php: >=5.3.0
- phpoffice/phpexcel: 1.8.1
Requires (Dev)
- phpunit/phpunit: 4.8.5
This package is not auto-updated.
Last update: 2024-11-09 18:54:07 UTC
README
Simple importer written in PHP
Example
<?php /** * Excel sheet example: * | A | B | C | * | 1 | 2 | 3 | * | 4 | 5 | 6 | */ $path = 'path/to/file.xlsx'; $importer = new Vdbf\Import\Excel\SingleSheetImporter(new Vdbf\Import\Excel\Reader()); //importer closure is called for every data-row $importer->import($path, function ($row, $header) { print_r($header); //['A', 'B', 'C'] print_r($row); //[1, 2, 3] }); //importer dump method dumps all rows to a 2D associative array $dump = $importer->dump($path); print_r($dump) //[['A' => 1, 'B' => 2, 'C' => 3], ['A' => 4, 'B' => 5, 'C' => 6]]
Configuration
The importer can be constructed with an array of options as a second argument.
<?php $options = [ 'read_header' => false, //skips reading the first row as a header row, defaults to true 'sheet_index' => 1 //imports the second sheet, defaults to 0 ]; $importer = new Vdbf\Import\Excel\SingleSheetImporter(new Vdbf\Import\Excel\Reader(), $options); ...