!Codeigniter无法调用PHPExcel

WBOY
풀어 주다: 2016-06-13 12:49:54
원래의
876명이 탐색했습니다.

紧急求助!Codeigniter无法调用PHPExcel
我是初学Codeigniter,使用其文件上传类将csv或者excel文件上传,同时,使用过PHPExcel来读取内容,装入数据库。我的程序如下:
controllers/products.php文件:

        $memsn = $this->session->userdata('MEMSN');
$this->load->library('Excel_Read_Operat');
$groups = array('purchaser', 'salesman', 'viewer','merchant');
        if ($this->ion_auth->in_group($groups))
{
$this->session->set_flashdata('message', $this->lang->line("access_denied"));
$data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
redirect('module=products', 'refresh');
}

$this->form_validation->set_rules('userfile', $this->lang->line("upload_file"), 'xss_clean');

if ($this->form_validation->run() == true)
{
    if ( isset($_FILES["userfile"])){
                $this->load->library('upload_photo');

$dest_dir = 'uploads/'.$memsn.'/';

$this->dest_dir_fortest = $dest_dir;

if($this->upload_photo->direct_is_exists($dest_dir)){

}else{
    redirect("module=products&view=upload_csv", 'refresh');
}

$config['upload_path'] = $dest_dir;
$config['allowed_types'] = 'csv|xls|xlsx';
$config['max_size'] = '2048';
$config['overwrite'] = TRUE;

$old_file_name = $_FILES["userfile"]["name"];
$new_file_name = $this->getSystemTime().$_FILES["userfile"]["name"];
$config['file_name'] = $new_file_name;

//Initialize
$this->upload_photo->initialize($config);

if( ! $this->upload_photo->do_upload()){

//echo the errors
$error = $this->upload_photo->display_errors();
$this->session->set_flashdata('message', $error.$dest_dir);
redirect("module=products&view=upload_csv", 'refresh');
}


if ($this->upload_photo->file_ext == '.csv') {

$csv = $this->upload_photo->file_name;


Excel_Read_Operat::initialized($dest_dir.$new_file_name);


$phpexcel_csv_arr_table = Excel_Read_Operat::GetArrTable_CVS();



if(!empty($phpexcel_csv_arr_table)){
                    $keys = array('code','name','category_id','STATUS','DESCRIPTION','DECDESCTION','CUSTPRICE','LENGTH','HEIGHT','WIDTH','STATUS');
    $final = array();

foreach ($phpexcel_csv_arr_table as $row_csv_value){

$final[] = array_combine($keys, $value);

foreach($final as $csv_pr) {
if($this->products_model->getProductByCode($csv_pr['code'])) {
     $this->session->set_flashdata('message', $this->lang->line("check_product_code")." (".$csv_pr['code']."). ".$this->lang->line("code_already_exist"));
redirect("module=products&view=upload_csv", 'refresh');
}

}

}

在libraries/下,有Excel_Read_Operat.php类文件,和Excel文件夹,文件夹下是PHPExcel.php和PHPExcel文件夹。Excel_Read_Operat.php类如下:

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

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!