2

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

v-joy
  • 25
  • 1
  • 5

3 Answers3

3

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.

Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207
  • I just solved the problem before I see your answer. But thanks. lol. by the way, the only thing I did is move the PHPExcel folder and PHPExcel.php file directly into Library. And I did not add autoloaderNamespaces[] in my application.ini . thanks again. – v-joy Jul 25 '12 at 09:55
1

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

Add new autoloaderNamespaces.phpexcel = "PHPExcel_"

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

Dinuka Thilanga
  • 4,220
  • 10
  • 56
  • 93
  • I just solved the problem before I see your answer. But thanks. lol. by the way, the only thing I did is move the PHPExcel folder and PHPExcel.php file directly into Library. And I did not add autoloaderNamespaces[] in my application.ini . thanks again. – v-joy Jul 25 '12 at 09:54
0

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.

drigani
  • 1
  • 3