1. Go to this page and download the library: Download renekorss/phpexcelformatter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
renekorss / phpexcelformatter example snippets
// Require needed files
ter\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 fourth 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();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.