无法加载请求的类:PHPExcel

首先,我在这个URL下载PHPExcel: https : //github.com/PHPOffice/PHPExcel

我解压这个文件,并采取PHPExcel.php和PHPExcel文件夹。

我把它们放在Codeigniter的库文件夹中。

我加载PHPExcel,但它返回这个消息。

<?php class ExportSample extends REST_Controller{ public function __construct(){ parent::__construct(); $this->load->database(); $this->load->library('PHPExcel'); } } ?> 

错误:无法加载请求的类:PHPExcel

我认为把它放在图书馆,只是加载图书馆,但也许不是。

我设置时有任何错误吗?

请给我任何想法


更新

 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 

我认为你的路线是错误的。

你的库文件夹应该在application/third_party/PHPExcel/PHPExcel.php

之后,你需要在application/libraries/文件夹中创build一个库excel.php

把这段代码放在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(); } } 

在你的控制器ExportSample.php使用这个代码:

 <?php class ExportSample extends REST_Controller{ public function __construct(){ parent::__construct(); $this->load->database(); $this->load->library('Excel'); } } ?> 

我希望它会为你工作!

试试:

  require_once APPPATH . "/third_party/PHPExcel.php"; 

并在应用程序中克隆lib phpExel / third_party /

不要把它们放在你的库文件夹,只要把它放在你的应用程序/ third_party文件夹中

它应该看起来像

…应用程序/ THIRD_PARTY / PHPExcel.php

…应用程序/ THIRD_PARTY / PHPExcel / ….

之后,创build一个名为Excel.php或类似的东西,并把它放在你的库文件夹

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

你的库文件夹应该像../application/libraries/Excel.php

并在你的控制器

 class ExportSample extends REST_Controller { public function __construct() { parent::__construct(); $this->load->database(); $this->load->library('Excel'); } } 

这应该几乎完成工作