Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can install the PHPExcel library in laravel?

I'm trying to use this library to create excel files but not how to install it. I was considering to download the library from its home page (http://phpexcel.codeplex.com/wikipage?title=Examples) but also do not know what folder should I place it. How I can install?

like image 538
TuGordoBello Avatar asked May 20 '14 15:05

TuGordoBello


2 Answers

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));
    }

}
like image 148
Razor Avatar answered Sep 24 '22 05:09

Razor


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;
like image 39
Vipul Avatar answered Sep 25 '22 05:09

Vipul