Problem loading PHPExcel

I’ve downloaded the latest version of PHPExcel (http://phpexcel.codeplex.com/) and I unzipped and placed it in /protected/extensions/phpexcel. I am now trying to call PHPExcel from one of my controllers but I keep getting errors. Here is my code (from http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii/):




$phpExcelPath = Yii::getPathOfAlias('application.extensions.phpexcel.Classes');

spl_autoload_unregister(array('YiiBase','autoload'));

include($phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php');

$objPHPExcel = new PHPExcel();



I get

Fatal error: Class ‘CListIterator’ not found in /var/framework/collections/CList.php on line 87.

When I take out the spl_autoload line, I get

YiiBase::include(PHPExcel_Shared_ZipStreamWrapper.php) [<a href=‘yiibase.include’>yiibase.include</a>]: failed to open stream: No such file or directory.

It’s like no matter what I do I always get an error. Any help getting PhpExcel working for me is appreciated.

Try:




 spl_autoload_unregister(array('YiiBase','autoload'));

 Yii::import('ext.PHPExcel.Classes.PHPExcel', true);

 spl_autoload_register(array('YiiBase','autoload')); 


 $objPHPExcel = new PHPExcel();

            



You may want to directly use EExcelView, it’s a widget extending CGridView and wrapping for PHPExcel, it’s really great and works by the minute.