hi, i’m using phpword to export word templates but with little success, the problem is that i can’t get the document to download to the browse but i’ll save it on the server. can someone tell me where am i wrong?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/test.docx');
$ordine = $rs["ordine"];
$templateProcessor->setValue('ordine', $ordine);
$templateProcessor->saveAs('php://output');
}
furthermore I would like to convert the word model into pdf, is it possible according to you want or should I use a library only for pdf models? and if so which one?
As you can see, I stored the content into $_SESSION[“HTML_String”] variable. Make sure also to create the content header (see the 2 lines code of it), before saving it to the output file. To call the function, simply use: exportToExcel(true);.