未找到类“CI_Excel” [英] Class 'CI_Excel' not found

查看:158
本文介绍了未找到类“CI_Excel”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我加载excel的库时,我得到这个错误。我遵循这个教程中的所有内容,并仍然收到一些错误

When I load the library of excel I got this error. I follow everything in this Tutorial and still got some error

我使用codeigniter框架。

Im using codeigniter framework.


类CI_Excel未找到/ var / www / html / warehouse / system / core / Common.php在线196

Class 'CI_Excel' not found in /var/www/html/warehouse/system/core/Common.php on line 196

这是我的控制器

class Dashboard extends CI_Controller {

public function __construct(){
    parent::__construct();

    $this->load->library('excel');
    $this->load->model('dashboard_model');
}

public function download(){
    $this->excel->setActiveSheetIndex(0);
    $this->excel->getActiveSheet()->setTitle('Warehouse List');
    //$this->load->database();
    $results = $this->dashboard_model->get_all();
    $this->excel->getActiveSheet()->fromArray($results);
    $filename='Warehouse List.xls';
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename="'.$filename.'"');
    header('Cache-Control: max-age=0');
    $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
    $objWriter->save('php://output');
}
}

这是我的库中的Excel类

This is my Excel class in my Libraries

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');  

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

class Excel extends PHPExcel {

    public function __construct() {
        parent::__construct();
    }

}


推荐答案

尝试这样...这里工作完美。

Try like this...Here working perfectly.

Setp1:下载PHPExcel。(下载: http://phpexcel.codeplex.com/

Setp1 : Download PHPExcel.(download it here: http://phpexcel.codeplex.com/)

Setp2:解压缩或解压缩下载的PHPExcel lib文件和复制整个文件夹在 application / librares

Setp2 : Unzip or extract the downloaded PHPExcel lib files and copy whole folder in application/librares

然后

class Dashboard extends CI_Controller {

public function __construct(){
    parent::__construct();

   $this->load->library('PHPExcel/Classes/PHPExcel');
    $this->load->model('dashboard_model');
}
public function create(){
//Create A PHPExcel Object
        $phpexcel=new PHPExcel();
//code more

如果你想按照教程的方式。这个...

If you want to follow the way of tutorial..Just try this...

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');  

require_once APPPATH."third_party/Classes/PHPExcel.php";//Your problem was here

class Excel extends PHPExcel {

    public function __construct() {
        parent::__construct();
    }

}

这篇关于未找到类“CI_Excel”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆