yiiexcel Wrapper for PHPExcel

  1. Requirements
  2. Installation
  3. Usage
  4. Resources

This is a class with an autoloader and few steps for use PHPExcel inside a Yii application.


  • Yii 1.1 or above
  • PHPExcel 1.7.8


  • Copy yiiexcel directory to protected/extensions.
  • Download PHPExcel.
  • Create a phpexcel directory on protected/vendors.
  • Unzip PHPExcel and copy Classes directory content to protected/extensions/phpexcel.
  • Edit PHPExcel.php file and comment the autoload inclusion:
/** PHPExcel root directory */
    /*if (!defined('PHPEXCEL_ROOT')) {
        define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
        require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  • Edit index.php file and register the YiiExcel autoloader:
    //do not run app before register YiiExcel autoload
    $app = Yii::createWebApplication($config);
    Yii::import('ext.yiiexcel.YiiExcel', true);
    Yii::registerAutoloader(array('YiiExcel', 'autoload'), true);
    // Optional:
    //	As we always try to run the autoloader before anything else, we can use it to do a few
    //		simple checks and initialisations
    if (ini_get('mbstring.func_overload') & 2) {
        throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
    //Now you can run application
  • Edit main.php config file to import PHPExcel main class:
// autoloading model and component classes


Just create a PHPExcel instance:

$objPHPExcel = new PHPExcel();

Read the SiteController.php example file located inside example directory.


3 3
5 716 downloads
Yii Version: 1.1
License: GPL-2.0
Category: Others
Developed by: Yeye
Created on: Jan 23, 2013
Last updated: 5 years ago


show all

Related Extensions