| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 258 | All time:  7,832 This week: 80  | ||||
| Version | License | PHP version | Categories | |||
| phpexcelformatter 1.0.0 | MIT/X Consortium ... | 5 | PHP 5, Databases, Files and Folders | 
| Description | Author | ||||||||
| This package can extract data from Excel into arrays or MySQL. | 
 | 
PHPExcelFormatter is class to make it more simple to get data from Excel documents.
composer require renekorss/phpexcelformatter
// 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
Fork us or create issue!
PHPExcelFormatter is licensed under MIT
|  Files (9) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  examples (3 files) | ||||
|  src (1 file, 1 directory) | ||||
|    .editorconfig | Data | Auxiliary data | ||
|    composer.json | Data | Auxiliary data | ||
|    LICENSE | Lic. | License text | ||
|    README.md | Doc. | Documentation | ||
|  Files (9) | / | examples | 
| File | Role | Description | 
|---|---|---|
|    example1.php | Example | Example script | 
|    example2.php | Example | Example script | 
|    example3.php | Example | Example script | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
 | 
 | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.