intergrate PHPWord and PHPExcel in ZF2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

intergrate PHPWord and PHPExcel in ZF2

ramy1988
This post has NOT been accepted by the mailing list yet.
hello,

I try to use both libraries  PHPWord and PHPExcel as two libraries in ZendFramework2
that is to say put them in /lib of ZF2 and load them into my controller with  use Zend/PHPExcel    for exeample

what I need to do? they are the steps to follow?

Thanks a lot
Reply | Threaded
Open this post in threaded view
|

Re: intergrate PHPWord and PHPExcel in ZF2

samsonasik
This post has NOT been accepted by the mailing list yet.
you can copy to your vendor folder. require it in index.php

     require './vendor/Classes/PHPExcel.php';

and you just call it everywhere :

     use PHPExcel;
     $objPHPExcel = new PHPExcel();

   
Reply | Threaded
Open this post in threaded view
|

Re: intergrate PHPWord and PHPExcel in ZF2

ramy1988
This post has NOT been accepted by the mailing list yet.
hi, thanks for your help
i did us you advise me but i get this error

( ! ) Fatal error: Class 'Auth\Controller\PHPExcel_Reader_Excel5' not found in C:\wamp\www\zend\module\Auth\src\Auth\Controller\AuthController.php on line 13


here is my controller.php


<?php
namespace Auth\Controller;
use Zend\Mvc\Controller\AbstractActionController;

use PHPExcel;
use PHPExcel\Reader\Excel5;

class AuthController extends AbstractActionController
{
public function LoginAction()
{

$objPHPExcel = new PHPExcel_Reader_Excel5();
$document = $objPHPExcel->load('example1.xls');

echo date('H:i:s') , " Données Ajoutées Avec Succés" ;
$document->setActiveSheetIndex(0)
            ->setCellValue('A1', 'Mike')
            ->setCellValue('B1', 'spils')
     
                        // Save Excel5 file



$objWriter = PHPExcel_IOFactory::createWriter($document, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__));


}
}
the location of my PHPExcel.php library is :

C:\wamp\www\zend\vendor\CodePlex\PHPExcel

belive me i did every thing to get this work but i still got no result

Reply | Threaded
Open this post in threaded view
|

Re: intergrate PHPWord and PHPExcel in ZF2

samsonasik
This post has NOT been accepted by the mailing list yet.
No, you can't do that, in deep folder, don't use 'use' statemen because phpexcel doesn't have namespace.

    $objPHPExcel = new \PHPExcel_Reader_Excel5();

add '\' before classname call.
Reply | Threaded
Open this post in threaded view
|

Re: intergrate PHPWord and PHPExcel in ZF2

ramy1988
This post has NOT been accepted by the mailing list yet.
thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnkyou very very very much !!

it wooooooooorks i'm really thankfull .  i did exactly us you said and it works. thank you .
Reply | Threaded
Open this post in threaded view
|

Re: intergrate PHPWord and PHPExcel in ZF2

jainikvora
This post has NOT been accepted by the mailing list yet.
In reply to this post by samsonasik
Hi,

I have done as mentioned above to integrate PHPExcel in ZF2 but I'm getting following error.

Fatal error: Cannot redeclare class PHPExcel in zf2\skeleton\vendor\PHPExcel\PHPExcel.php on line 44

The class is not present anywhere else in my Project. Please guide me.

Thanks,
Jainik
Reply | Threaded
Open this post in threaded view
|

Re: intergrate PHPWord and PHPExcel in ZF2

drigani
This post has NOT been accepted by the mailing list yet.
In reply to this post by ramy1988
For an easy integration of PHPOffice/PHPExcel library into zend framework 2, you can use the zf2 module MvlabsPHPExcel After that you need to enable the `MvlabsPHPExcel` module: [ // ... 'MvlabsPHPExcel', ], // ... ]; And after that you be able to use inside the controller. $phpExcelObject = $this->serviceLocator->get('mvlabs.phpexcel.service')->createPHPExcelObject();