samedi 20 octobre 2018

how to looping array data in docxtemplate word using php laravel

i have word template like this its my template word

and then i want give looping in my template because i have data in array, i want be like this :

its tempalte after looping

and code in my function is :

$docx = new \App\Helpers\DOCXTemplateHelpers('assets/word_template/loops.docx');
    $a = array(array('name' => 'john doe1',
                'addres' => 'address1'),
            array('name' => 'john doe2',
                'addres' => 'address2'),
            array('name' => 'john doe3',
                'addres' => 'address3'));

$docx->set($a);
    $docx->saveAs('halo.docx');
    header("Content-type: application/vnd.ms-word");
    header("Content-Disposition: attachment;Filename=looping.doc");
    readfile('halo.docx');

its defined veriable in word for single variable or not looping : defined variable templated not looping

and my question is how to do looping data in word template base on data array??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire