Reputation: 1225
First, I download the PHPExcel in this URL : https://github.com/PHPOffice/PHPExcel
And I unzip this file and take PHPExcel.php and PHPExcel Folder.
I put them in libraries folder in Codeigniter.
I load the PHPExcel but it returns this message.
<?php
class ExportSample extends REST_Controller{
public function __construct(){
parent::__construct();
$this->load->database();
$this->load->library('PHPExcel');
}
}
?>
Error : Unable to load the requested class: PHPExcel
I think put it in libraries and just load the library but maybe it is not.
Is any mistake when I setting it?
Please give me any idea
update
Error message : require_once(): Failed opening required '/var/www/html/appservice/application//third_party/PHPExcel.php' (include_path='.:/usr/share/php:/usr/share/pear') in
<b>/var/www/html/appservice/application/libraries/Excel.php
Upvotes: 1
Views: 11997
Reputation: 770
I think your path is wrong.
Your library folder should be in:application/third_party/PHPExcel/PHPExcel.php
After that you need to create one library excel.php
in application/libraries/
folder.
Put this code in excel.php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once APPPATH."/third_party/PHPExcel/Classes/PHPExcel.php";
require_once APPPATH."/third_party/PHPExcel/Classes/PHPExcel/IOFactory.php";
class Excel extends PHPExcel {
public function __construct() {
parent::__construct();
}
}
And use this code in your controller ExportSample.php
:
<?php
class ExportSample extends REST_Controller{
public function __construct(){
parent::__construct();
$this->load->database();
$this->load->library('Excel');
}
}
?>
I hope it will work for you!
Upvotes: 2
Reputation: 5439
Dont put them in your libraries folder, just put it in your application/third_party folder
it should look like
...application/third_party/PHPExcel.php
...application/third_party/PHPExcel/....
After that create a library called Excel.php or something like that and put it in your library folder
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once APPPATH."/third_party/PHPExcel.php";
class Excel extends PHPExcel
{
public function __construct()
{
parent::__construct();
}
}
your library folder shoud look like ../application/libraries/Excel.php
And in your Controller
class ExportSample extends REST_Controller
{
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('Excel');
}
}
that should pretty much get the job done
Upvotes: 0
Reputation: 1139
Try :
require_once APPPATH . "/third_party/PHPExcel.php";
And clone lib phpExel in application/third_party/
Upvotes: 0