Generating word documents with PHP

EL_W picture EL_W · Nov 11, 2010 · Viewed 78.6k times · Source

Do you know any way to generate doc and docx files with PHP and without COM component? I've tried PHPWord, which creates docx files, but these cannot be opened in OpenOffice because they cause it to crash. I've also tried PHPDocx, but it didn't generate any files at all.

Answer

edi9999 picture edi9999 · Sep 22, 2014

Generating word documents with JS:

I have created a simple open-source library that will replace tags by values.

For example Hi {name} with data={name:"John"} will be replaced by Hi John.

Here it is : https://github.com/edi9999/docxtemplater

Demo: https://docxtemplater.com/demo