steven.su 发表于 2017-9-16 16:09:40

無法讀取excel

各位大大可以指點一下小弟嗎??
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Test extends CI_Controller{
public function __construct()
{
    parent::__construct();
    //Codeigniter : Write Less Do More
    // $this->load->library('Excel');
    $this->load->library('excel');
}

public function index()
{
    $this->load->view('index');
}

public function login()
{
    $file = require_once APPPATH.'ByfinDetail/BF_BondCustomer.xlsx';
    try {
      $objPHPExcel = PHPExcel_IOFactory::load($file);
    } catch(Exception $e) {
      die('Error loading file "'.pathinfo($file,PATHINFO_BASENAME).'": '.$e->getMessage());
    }

    $session_user = $this->session->userdata('user_name');
    $session_password = $this->session->userdata('user_password');
    $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
    //計算行數
    $arrayCount = count($sheetData);

    for ($i=2; $i <= $arrayCount ; $i++ ){

      if ($allDataInSheet[$i]["A"] == $session_user && $allDataInSheet[$i]["D"] == $session_password)
      {
      redirect('byfin');

      }else{

      echo "<h2>faild</h2>";
      // break;
      }
    }
}
public function byfin()
{
    $this->load->view('welcome_message');
}

}

以上是我的程式執行會出錯
An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected ''ao��Y��5-�����jX����' (T_CONSTANT_ENCAPSED_STRING)

Filename: /Applications/MAMP/htdocs/c/application/ByfinDetail/BF_BondCustomer.xlsx

Line Number: 74

Backtrace:

File: /Applications/MAMP/htdocs/c/index.php
Line: 315
Function: require_once

页: [1]
查看完整版本: 無法讀取excel