Integrate PHPExcel in my YII application

Hi, I'm new in YII framework. I would like to create a project with it but I need to implement PHPExcel class (http://www.codeplex.com/PHPExcel ).

Is it possible to do it? How can I do that?

TIA

Danilo

Yes you can, you will need to wrap the classes into an extension that is declared in your main config file. Take a look at the extension documentation :)

Quote

Hi, I'm new in YII framework. I would like to create a project with it but I need to implement PHPExcel class (http://www.codeplex.com/PHPExcel ).

Is it possible to do it? How can I do that?

TIA

Danilo

I have written a tutorial about how to load the DOMIT! Parser. How to integrate PHPExcel into Yii will be much likely the same.

You can have a look at it http://www.yiiframew…0.html#msg17930.

Please don’t forget the official documentation about how to use the 3rd Party Libraries: http://www.yiiframew…ion.integration

hi, thanks for reply :)

I'm still having problems. I've put PHPExcel in myApplication/protected/vendors dir. PHPExcel is a file (PHPExcel.php) and another subdir that contains other files.

In myApplication/protected/config/main.php I've added:

  'import'=>array(

                'application.models.*',

                'application.components.*',

                'application.vendors.*'

        ),

and in my Controller I've added:

require_once ('PHPExcel/PHPExcel.php');

It doesn’t work… look at http://pastebin.com/m3a94d885 for errors

Based on your "import" setting, the Cell.php file should be located at:

/var/www/dibevit/dibevit/protected/vendors/PHPExcel/Cell.php

Quote

Based on your "import" setting, the Cell.php file should be located at:

/var/www/dibevit/dibevit/protected/vendors/PHPExcel/Cell.php

Yes! Adding  ‘application.vendors.PHPExcel.*’ it works, understand. Thanks to all :)

Hello zitter,

could you share this extension?

Thank you.

that still have some errors,

[color="#FF0000"]include(PHPExcel_Reader_Excel2007.php) [<a href=‘function.include’>function.include</a>]: failed to open stream[/color]

the “PHPExcel_Reader_Excel2007” is not a PHP file ,but it’s a class that exists in PHPExcel/PHPExcel/Writer/Excel2007.php

what is the reason of that? how to resolve it?

If the filename does not equals the classname you need to include them manually using ‘require_once’.

I also had to do so with the same library.

http://www.yiiframework.com/forum/index.php?/topic/5784-phpexcel-internal-server-error/

In the new version of PHPExcel (1.7.4) there is already something implemented for Yii. spl_unregister/spl_register YiiBase in PHPExcel.php file. So all you have to do now is to import the path where PHPExcel is stored and it will work.