2015-11-05 48 views

回答

1

您可以在笨添加PHPExcel到庫,如:

application > libraries > PHPExcel.php 

讓我們說PHPExcel.php lib rary文件:

<?php 

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

class PHPExcel 
{ 
    public function __construct() 
    { 
      // 
    } 

    public function some_function() 
    { 
     return 'some_function'; 
    } 

} 

要在Controller中調用PHPExcel庫。讓說,我把它命名爲 My_controller.php

<?php 

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

class My_controller extends CI_Controller 
{ 
    public function __construct() 
    { 
      parent::__construct(); 
      //Call PHPExcel class 
      $this->load->library('PHPExcel'); 
    } 

    public function index() 
    { 
      echo $this->PHPExcel->some_function(); 
    } 


} 
+0

我看到你做了什麼,我有一些問題,然後我嘗試這樣做: 第一:我應該將PHPExcel文件夾移動到哪個目錄?第二:如何在編輯我的問題後應用此功能,因爲您現在知道這是一個包含文件的整個文件夾,而不僅僅是一個文件夾。 –

+0

那麼你可以創建一個文件夾並將其命名爲PHPExcel並將所有文件移入它。你只需要調用主文件作爲你提到 - IOFactory.php欲瞭解更多信息...只需去http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html – Nere

相關問題