Question

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

Était-ce utile?

La 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.

Autres conseils

Add your lib to library folder. (libarary/PHPExcel)

Add new autoloaderNamespaces.phpexcel = "PHPExcel_"

You can use library method using PHPExcel_IOFactory::createReader($inputFileType);

The problem is related to autoload PHPExcel classes. I suggest to avoid to have problems with autoload PHPExcel classes to use the zf2 module MvlabsPHPExcel that will give you an easy integration of [PHPOffice/PHPExcel][2] library into zend framework 2.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top