eric.itzhak
eric.itzhak

Reputation: 16062

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?

Upvotes: 2

Views: 4159

Answers (2)

Apurv Chaudhary
Apurv Chaudhary

Reputation: 1795

you have not installed xml, just run below command in terminal

sudo apt-get install php-xml

and restart your apache2.

Upvotes: 1

eric.itzhak
eric.itzhak

Reputation: 16062

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.

Upvotes: 3

Related Questions