Row_Export is fired for every row, you should not output file there, or only one row is exported, so your code only works (if it works) for the View page.
Make sure you provide the correct path of the template, if you just use ‘cliente.docx’, that means the ‘cliente.docx’ is placed in the same folder as the script.
Always enable Debug during development and check PHP errors in the log file.
I practically managed to generate the docx file but I only managed to save it on my server it doesn’t download me directly from the browserthis is my code:
function Page_Exporting()
{
//$this->ExportDoc->Text = "my header"; // Export header
//return false; // Return false to skip default export and use Row_Export event
return false; // Return true to use default export and skip Row_Export event
}
function Row_Export($rs)
{
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('templates/cliente.docx');
$cliente = $rs["cliente"];
$templateProcessor->setValue('cliente', $cliente);
$templateProcessor->saveAs('php://output');
}