This project is read-only.

create .docx in php

Jun 5, 2014 at 8:00 AM
I want to create .docx file along with html controls like Textbox, radio buttons etc... on the fly.
I used PHPWord, which is showing text and tables properly but unable to show Textbox, radio buttons.
How can i create the HTML controls like Textbox, radio buttons in .docx file using PHP?

Please help me asap...

Jun 5, 2014 at 4:16 PM
There is ongoing development for PHPWord here:
Jun 6, 2014 at 4:33 AM
Edited Jun 6, 2014 at 11:45 AM
Hi JillElaine,
Thanks for your reply.

According to the above URL, possible to add Textbox and Checkbox to the .docx file from PHP.
How do we add Radi buttons and Drop boxes to .docx file?

And i tried to parse the Textbox and Checkbox data. But it is not posible to find which checked box is CHECKED.

This is most important issue for me.
Is there any way to add those HTML controls to .docx file from PHP?
And how can parse those HTML controls from .docx file?

Please help me asap..

Jun 6, 2014 at 3:06 PM
Edited Jun 6, 2014 at 3:07 PM
Hi Kiran.

The latest PHPWord version (0.11.0) only support writing CheckBox and no reading for any form elements. I've submitted an enhancement request here.

You're free to fork the script and enhance it for your need.
Jun 17, 2014 at 9:26 AM
Edited Jun 17, 2014 at 10:41 AM
Hi ivanlanin,
Great help from you and your support team. I cehcked the developer version. Now Checkbox, Textbox and Dropdown working great.

Is it possible to add radio buttons, hidden variables? I need to use hidden variables while parsing the .docx file data.    

I need to save that form elements data in Database. i used doc2txt.php file to parse .docx file, but it is unable to parse the SELECTED option from dropdown and unable to find which checkbox is CHECKED or not in the .docx file. 
So, how to parse those form elements from .docx file?

What are the steps i need to follow if latest PHPWORD files working for PHP5.1 and 5.2 versions?

Please help me asap.
Jun 17, 2014 at 10:53 AM
Hi Kiran,
  1. PHPWord doesn't support radio buttons nor hidden variables yet
  2. The file doc2txt.php is not part of PHPWord. Did you make it yourself? PHPWord doesn't support parsing form elements, yet.
  3. PHPWord requires 5.3 because we use namespaces. You can't use PHP version lower than that.
Jun 17, 2014 at 11:33 AM
Hi ivanlanin,
Thanks for your valuable response.

-> i am using the doc2txt.php file, which is taking from the below URL

->For hidden variables, is there any possibility to assign values to variables which are not showing in .docx file. While parsing the .docx file, we are able to getting those invisible values.