doutun1362 2017-09-11 11:39
浏览 332

致命错误:找不到类'PHPExcel_IOFactory',消息:找不到类'PHPExcel_IOFactory',文件名:controllers / Welcome.php行号:62

Hi I am getting PHPExcel_IOFactory not found error for below-mentioned line

$objReader= PHPExcel_IOFactory::createReader('Excel2007');

//controller

function ExcelDataAdd() 
{  
     $configUpload['upload_path'] ='./uploads/';
     $configUpload['allowed_types'] = 'xls|xlsx|csv';
     $configUpload['max_size'] = '5000';
     $this->load->library('upload', $configUpload);
     $this->upload->do_upload('userfile');  
     $upload_data = $this->upload->data();  
     $file_name = $upload_data['file_name']; 
     $extension=$upload_data['file_ext'];

      $objReader= PHPExcel_IOFactory::createReader('Excel2007');
      $objReader->setReadDataOnly(true);
      $objPHPExcel=$objReader->load('./uploads/'.$file_name);     
      $totalrows=$objPHPExcel->setActiveSheetIndex(0)->getHighestRow();   
      $objWorksheet=$objPHPExcel->setActiveSheetIndex(0);      
      for($i=2;$i<=$totalrows;$i++)
      {
          $FirstName= $objWorksheet->getCellByColumnAndRow(0,$i)->getValue();     
          $LastName= $objWorksheet->getCellByColumnAndRow(1,$i)->getValue(); 

          $this->Excel_export_model->Add_stud($data_stud);     
      }
      unlink('./uploads/'.$file_name);                     
      redirect("Welcome");
    }

please tell me where am I going wrong

  • 写回答

2条回答 默认 最新

  • drrqwokuz71031449 2017-09-11 12:22
    关注

    Try This

    $this->load->library('PHPExcel');
    $objPHPExcel = PHPExcel_IOFactory::load($_FILES['file']['tmp_name']);
    $sheet1 = $objPHPExcel->getSheet(0)->toArray(null,true,true,true);
    echo "<pre>";print_r($sheet1);die;
    

    where file is the name of the file tag like <input type="file" name="file">

    Please Download PHPExcel from this link and paste into application/library/ folder

    [https://github.com/PHPOffice/PHPExcel/tree/1.8/Classes]

    评论

报告相同问题?