2017 © Pedro Peláez
 

library import-php

Simple importer written in PHP >= 5.3

image

vdbf/import-php

Simple importer written in PHP >= 5.3

  • Thursday, September 10, 2015
  • by eelkevdbos
  • Repository
  • 2 Watchers
  • 1 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

import-php

Build Status Code Coverage Scrutinizer Code Quality, (*1)

Simple importer written in PHP, (*2)

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., (*3)

<?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);

...

The Versions

10/09 2015

dev-master

9999999-dev

Simple importer written in PHP >= 5.3

  Sources   Download

MIT

The Requires

 

The Development Requires

excel import