PHP Classes
elePHPant
Icontem

PHPExcel Formatter: Extract data from Excel into arrays or MySQL

Recommend this page to a friend!
  Info   View files Documentation   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-05-09 (15 days ago) RSS 2.0 feedNot enough user ratingsTotal: 17 This week: 17All time: 8,876 This week: 53Up
Version License PHP version Categories
phpexcelformatter 1.0MIT/X Consortium ...5PHP 5, Databases, Files and Folders
Description Author

This package can extract data from Excel into arrays or MySQL.

It can parse an Excel spreadsheet and extracts data into an array or a MySQL database table.

It can be configured to pick only certain columns of data of the spreadsheet.

  Performance   Level  
Name: Rene Korss <contact>
Classes: 2 packages by
Country: Estonia Estonia

Details

Latest Stable Version Total Downloads License SensioLabsInsight

PHPExcelFormatter

PHPExcelFormatter is class to make it more simple to get data from Excel documents.

  • Read columns what you really need
  • Set column names for documents what dosen't have column names on first row
  • Set your DB field names for columns
  • Retrieve data in array or MySQL query format
  • Greate for importing files and then letting user to connect document columns with your DB fields :) (example coming)

Composer

composer require renekorss/phpexcelformatter

Usage

// Require needed files
require __DIR__ . '/vendor/autoload.php';

use RKD\PHPExcelFormatter\PHPExcelFormatter;
use RKD\PHPExcelFormatter\Exception\PHPExcelFormatterException;

try{
  // Load file
  $formatter = new PHPExcelFormatter('example1.xls');

  // Output columns array (document must have column names on first row)
  $formatterColumns = array(
    'username' => 'username',
    'phone'    => 'phone_no',
    'email'    => 'email_address'
  );

  // Output columns array (document dosen't have column names on first row)
  // Skip foruth column (age) (third in array), because we don't need that data
  // NOTE: if document dosen't have column names on first line, second parameter for PHPExcelFormatter should be $readColumns = false, otherwise it will skip first line of data
  $formatterColumns = array(
    'username',
    'email_address',
    'phone',
    4 => 'sex'
  );

  // Set our columns
  $formatter->setFormatterColumns($formatterColumns);

  // Output as array
  $output = $formatter->output('a');
  // OR
  // $output = $formatter->output('array');

  // Print array
  echo '<pre>'.print_r($output, true).'</pre>';

  // Set MySQL table
  $formatter->setMySQLTableName('users');

  // Output as mysql query
  $output = $formatter->output('m');
  // OR
  // $output = $formatter->output('mysql');

  // Print mysql query
  echo '<pre>'.print_r($output, true).'</pre>';

}catch(PHPExcelFormatterException $e){
  echo 'Error: '.$e->getMessage();
}

View examples

Want to contribute / have ideas?

Fork us or create issue!

Uses (thanks)

PHPOffice/PHPExcel

License

PHPExcelFormatter is licensed under MIT

  Files folder image Files  
File Role Description
Files folder imageexamples (3 files)
Files folder imagesrc (1 file, 1 directory)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file example1.php Example Example script
  Accessible without login Plain text file example2.php Example Example script
  Accessible without login Plain text file example3.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imageException (1 file)
  Plain text file PHPExcelFormatter.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Plain text file PHPExcelFormatterException.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:17
This week:17
All time:8,876
This week:53Up