PHPWord Multi ( Satu Value dan While )

<?php

require 'vendor/autoload.php';

$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('w.docx');


$values = [
    ['nim' => 001, 'nama' => 'a', 'alamat' => 'alamat a'],
    ['nim' => 002, 'nama' => 'b', 'alamat' => 'alamat b'],
    ['nim' => 003, 'nama' => 'c', 'alamat' => 'alamat c'],
    ['nim' => 004, 'nama' => 'd', 'alamat' => 'alamat d'],
];
$templateProcessor->cloneRowAndSetValues('nim', $values,);

$templateProcessor->setValues([
    'nimx' => 'fahri',
    'namax' => '31',
    'alamatx' => date('d-m-Y'),

]);

header("Content-Disposition: attachment; filename=template.docx");

$templateProcessor->saveAs('php://output');

 1,802 total views

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *