Using PHPExcel class with CodeIgniter

I’ve recently had to create some Excel reports for an e-commerce site that I’ve been working on and googling a php Excel Writer class I got to the PHPExcel website.

It was all looking great and all but I needed to integrate it with CodeIgniter.

Here’s how to do it:

  1. Download the code and unarchive it.
  2. In the folder where you have unpacked the code there should be a folder “Classes”. Upload it’s contents to your server in the “application/third_party” folder.
  3. Create a file named “Excel.php” in the “application/libraries” folder and add the following code:
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     *  ======================================= 
     *  Author     : Muhammad Surya Ikhsanudin 
     *  License    : Protected 
     *  Email      : 
     *  Dilarang merubah, mengganti dan mendistribusikan 
     *  ulang tanpa sepengetahuan Author 
     *  ======================================= 
    require_once APPPATH."/third_party/PHPExcel.php"; 
    class Excel extends PHPExcel { 
        public function __construct() { 
  4. Use it like this in your controller:
    // load the library
    // set active sheet

For more usage instructions read the PHPExcel Documentation.


There are no comments yet, add one below.

Leave a Comment

Your email address will not be published. Required fields are marked *