Wednesday, October 5, 2022

[FIXED] how to use phpexcel in zend framework

Issue

I need to import data from excel,And the I decided to use PHPExcel,But when I require it in my web , a few warnings occured :

      Warning: 
    include_once(PHPExcel\Shared\ZipStreamWrapper.php) [<a href='function.include-once'>function.include-once</a>]: 
failed to open stream: No such file or directory in D:\www\LearningCenter\library\Zend\Loader.php on line 146

here is my code.:

public function getUserFromExcel($path){
    echo $path;
    require_once 'Excel/PHPExcel.php'; 
    echo $path;
}

and my webapp structre is :

library Zend Excel others-thirdpart-library

it seems that there is something wrong with the autoloader.

I read a few articles But did not find a solution.

My final aim is to read date from an excel file: can some one give me some sugestion on ether how to use phpexcel in zend or how to import data from excel useing zend itself.

thanks


Solution

copy the PHPExcel library into your /library directory, the structure should be as follows

/library
    /PHPExcel
    /PHPExcel.php

and then add this in your application.ini

autoloaderNamespaces[] = "PHPExcel_"
autoloaderNamespaces[] = "PHPExcel"

and it should work.



Answered By - Ibrahim Azhar Armar
Answer Checked By - Senaida (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.