紧急求助!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和PHPExce