Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add PHPExcel library in laravel?

i want to create new module in laravel which include PHPExcel library. where to put library. how to access it.

i have put the PHPExcel library at below location

laravel\project\application\libraries\PHPEXCEL

it give me error PHP Fatal error: Class 'PHPExcel' not found.

like image 431
user2733745 Avatar asked Mar 02 '14 16:03

user2733745


People also ask

How to install PHPExcel library in laravel?

1:- Add "phpoffice/phpexcel": "dev-master" to your composer. json. 2:- execute "composer update" on terminal. 3:- Open the file "/vendor/composer/autoload_namespaces.

What is PHPExcel library?

PHPExcel is a PHP library providing an ability to work (read/create/edit) spreadsheet files (formats: . xls, . xlsx, CSV, . ods, and some others). Official PHPExcel library page on GitHub https://github.com/PHPOffice/PHPExcel.


2 Answers

You can use the PHPExcel Composer package. Just add "phpoffice/phpexcel": "dev-master" to your composer.json and enter composer update. This way the library will be "installed" and you can use it as normal (for example $objPHPExcel = new PHPExcel();) No need for manual includes etc.

Update may 2016

Instead of editing your composer.json, please use the 'official' command:

composer require phpoffice/phpexcel

like image 187
trizz Avatar answered Oct 06 '22 06:10

trizz


Below are the step to use PHPEXCEL Library with laravel 5

1:- Install "phpoffice" Package in Laravel 5. Below is the link for the packages

2:- Add "phpexcel/phpexcel": "dev-master" to your composer.json. Ex:- "require": { "phpexcel/phpexcel": "dev-master" }

3:- Then execute "composer update".

4:- Open the file "/vendor/composer/autoload_namespaces.php". Paste the below line in the file.

// Include PHPEXCEL Library with Laravel 5
'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'),

5:- Now you can use PHPEXCEL library in your controllers or middleware or library. use PHPExcel; use PHPExcel_IOFactory;

For more details you can access "https://github.com/pantlavanya/export-to-excel-using-phpoffice-phpexcel-in-laravel-5" link.

like image 24
Lavanya Pant Avatar answered Oct 06 '22 05:10

Lavanya Pant