How to use PHPExcel external library with Yii
Trying to learn and help some other programmers to find their solutions on the [Yii Forum](http://www.yiiframework.com/forum "Yii Forum") (I think is a superb way to learn the framework), I was facing one challenge with an external library that a fellow programmer wanted to use -quite good indeed: [PHPExcel](http://phpexcel.codeplex.com/
). And what is PHPExcel?
<h4>PHPExcel - OpenXML - Create Excel2007 documents in PHP - Spreadsheet engine</h4>
<blockquote>Project providing a set of classes for the PHP programming language, which allow you to write to and read from different file formats, like Excel 2007, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP.
Checkout the [Features](http://phpexcel.codeplex.com/wikipage?title=Features
"PHPExcel") this class set provides, such as setting spreadsheet meta data (author, title, description, ...), multiple worksheets, different fonts and font styles, cell borders, fills, gradients, adding images to your spreadsheet and much, much more!</blockquote>
The workaround to this problem (at least the one I know) is by making use of the [spl_autoload_register](http://php.net/manual/en/function.spl-autoload-register.php "spl_autoload_register") and [spl_autoload_unregister](http://www.php.net/manual/en/function.spl-autoload-unregister.php "spl_autoload_unregister") PHP's functions. The following code shows how we got the library working -I assume that you have [downloaded the PHPExcel](http://phpexcel.codeplex.com/ "PHPExcel") files, unzipped its contents and place them into a **phpexcel** folder within your application's **protected/extensions** folder:
This post is using PHPExcel external library as an example, but this procedure should be taken into account when we encounter a problem like this. Whenever you find a library that you wish to include in your Yii application, check out its autoloading functions first.