Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template not working #397

Open
Mella91 opened this issue Oct 15, 2014 · 3 comments
Open

Template not working #397

Mella91 opened this issue Oct 15, 2014 · 3 comments

Comments

@Mella91
Copy link

Mella91 commented Oct 15, 2014

Hi,

I'm new to PHPWord and I'm trying to allow in my website the download of a document .docx.
I've started doing a simple test with the code below:

require_once 'PHPWord.php';
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('Template.docx');
$template->setValue('Name', 'Somebody someone');
$template->setValue('Street', 'Coming-Undone-Street 32');
$template->save('helloWorld.docx');

This gives me a corrupt file helloWorld.docx that I can't open.

I've tried to add the lines:

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('helloWorld.docx');

And in this way the script outputs me 2 file: one helloWorld.docx empty and another equal to the template.

What could be the problem?
Thanks.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Mella91
Copy link
Author

Mella91 commented Oct 16, 2014

I've found the problem!

I have made the template with OpenOffice and then it isn't a Microsoft Word document.
Now I've made it with Google Docs and exported like a Microsoft Word docx and it works.

Thnx Google!

@iqbalmalik89
Copy link

I am facing same problem. I tried your solution but still no luck.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@github-actions github-actions bot added the Stale label Nov 18, 2022
@Progi1984 Progi1984 removed the Stale label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants