Search code examples
phpcodeignitercodeigniter-2phpexcel

How to load PHPExcel inside a library?


somewhen back i followed this tutorial to implement PHPExcel in CI.

Now everything worked fine with that snippet but i tried creating my library that loads the PHPExcel and encoutred a problem.

I've created a CI instance :

$CI =& get_instance();
$CI->load->library('excel');

Which works great and i am building my excel file but in the metnioned tutorial, to save it the following command is being used :

$objWriter = PHPExcel_IOFactory::createWriter($CI->excel, 'Excel2007'); 

Which worked great when i used it inside the controller, but in a library i get an error of : Fatal error: Class 'XMLWriter' not found in /path/to/application/third_party/PHPExcel/Shared/XMLWriter.php on line 44

Now i guess it has something to do with the way this is being called, can anyone tell me how can i get rid of it?


Solution

  • Well i solved it, the problem was i havn't checked my server has the requirements of PHPExcel, and i'm missing php_xml. When i got it to work i worked on localhost (XAMPP) which did have those extensions enabled.