File.docx corrupt

Jun 5, 2014 at 1:54 PM
I'm developping a web page in which the users can download a word file.
I'm trying to do this with PHPWord. But the file .docx that outputs from the page is corrupt and I can't open it.
Here's the script:
require_once 'PHPWord.php';
$PHPWord = new PHPWord();

$template = $PHPWord->loadTemplate('Budget.docx');
$template->setValue('CLIENTE', $cliente);
$template->setValue('DATA', $data);
$template->setValue('INQUN', $inqun);
$template->setValue('PROGETTO', $progetto);
$template->setValue('LUOGO', $luogo);
$template->setValue('QUANTITA', $quantita);
$template->setValue('NOME', $nome);
$template->setValue('CODICEDESIGN', $codice);
$template->setValue('CERTIFICAZIONE', $certificazione);
$template->setValue('MATERIALE', $material);
$template->setValue('DIAMETRO', $diametro);
$template->setValue('SPESSORES', $spessore);
$template->setValue('SPESSOREF1', $spessoreF1);
$template->setValue('SPESSOREF2', $spessoreF2);
$template->setValue('UNITARIO', $unitario);
$template->setValue('TOTALE', $totale);
$template->setValue('PREZZOU', $prezzou);
$template->setValue('PREZZOT', $prezzot);

Where every value in the replace position is a string value.
What could be the problem that makes the file corrupt?
Jun 6, 2014 at 2:30 PM

Which version of PHPWord were you using? PHPWord development is continued in GitHub. Can you get the latest version (0.11.1) and run your code against it?

Oct 14, 2014 at 1:05 PM

I've came back to PHPWord after working with php header.
I'm trying to do it with the latest version but it gives me the same error.
Oct 16, 2014 at 7:47 AM
I've found the problem!

The template I want to edit was made with OpenOffice.
I've made it with Google Docs and I've exported it like a Microsoft Word docx and it works.