Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
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
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
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.