How I can install the PHPExcel library in laravel?
There's actually a neat new PHPExcel library specifically made for Laravel. Easy installation and it looks easy to use (I'm unaffiliated). https://laravel-excel.com/
You should use composer: Add "phpexcel/phpexcel": "dev-master"
to your composer.json
"require": {
"phpexcel/phpexcel": "dev-master"
}
Then execute composer update
. So you can use it as normal:
public function import($path){
$objPHPExcel = PHPExcel_IOFactory::load($path);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
for ($row = 1; $row <= $highestRow; ++$row) {
var_dump($objWorksheet->getCellByColumnAndRow(1, $row));
}
}
For install PhpExcel in laravel 5.
Please visit this link for pakage -https://packagist.org/packages/phpoffice/phpexcel.
Please follow the instruction --
1:- Add "phpoffice/phpexcel": "dev-master"
to your composer.json.
2:- execute "composer update"
on terminal.
3:- Open the file "/vendor/composer/autoload_namespaces.php". Paste the below line in the file.
'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'),
4:- Now you can use PHPEXCEL library in your controllers or middleware or library.
use PHPExcel;
use PHPExcel_IOFactory;