how can I integrate the PHPExcel into my Zend app.
My actual folder structure is the following:
/application
controllers
views
etc...
/library
My
Zend
PHPExcel
/public
index.php
I already include 'My' libs by using (in index.php):
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('My_');
Now I also want to use PHPExcel inside one of my controllers like:
$exc = PHPExcel_IOFactory::load('test.xls');
$excelWorksheet = $exc->getActiveSheet();
What do I have to do to make it work and get rid of the Class 'PHPExcel_IOFactory' not found
Exception?
Thank you.
-lony
P.S.: A simple $autoloader->registerNamespace('PHPExcel_');
is not working. I tested it.
PHP Excel was officially deprecated in 2017 and permanently archived in 2019. PHP Excel has not be maintained for years and must not be used anymore. All users must migrate to its direct successor PhpSpreadsheet, or another alternative.
The Zend framework makes web development easy, and can complete tasks quickly and efficiently. The ZF doesn't come as a whole unit that doesn't budge at all. It is decoupled, meaning the components come as an individual library , so the developers need to load only the required components.
Zend Framework is a collection of professional PHP packages with more than 570 million installations. It can be used to develop web applications and services using PHP 5.6+, and provides 100% object-oriented code using a broad spectrum of language features.
Place the PHPExcel library into the /library folder, like this:
/application
...
/library
/PHPExcel
/PHPExcel.php
Next, in your application.ini config file, add the following:
autoloaderNamespaces[] = "PHPExcel_"
autoloaderNamespaces[] = "PHPExcel"
That should do it. Autoloader takes care of the rest, and you can just start using the example code to read an Excel file.
Update: Added the extra autoloaderNamespace as suggested by commenters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With