无法加载请求的类: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'); } }
这应该几乎完成工作
- 在ajax调用期间显示一个带有进度的模式窗口
- (已解决)文件名C:\ xampp \ tmp \ php4632.tmp在上传数据中不可读取excel与codeigniter到mysql
- 将excel表导入codeigniter中的mysql数据库
- codeigniter中不存在的类错误
- CodeIgniter:从excel intp现有的MySQL数据库上传数据
- codeigniter导出到excel在localhost上运行良好,服务器上出现错误
- 生成Excel表格在codeigniter与样式表
- 无法读取CodeIgniter中的Excel文件
- 在codeigniter中使用PHPExcel从数据库创buildExcel工作表