Forum


Replies: 3   Views: 3321
Html in table
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by llouis  · 02-02-2012 - 16:15

I saw your example where it's possible to replace a tag by HTML in template with a table including this tag.

But I would like to know if it's possible to create dynamically a table (with an undefined number of rows) and adding HTML content in some cells.
I notice it's possible to add in a table, different types of content, like a link for example, with the function addElement.But I don't know if it's possible for HTML content. It seems that the function addElement doesn't accept HTML content type.
Or is there another way ?

Kind regards

Posted by llouis  · 11-04-2013 - 12:13

We tried to find a workaround to add HTML content in a table through the template mechanism.

We wrote a script to generate dynamically a template with a table including tags to replace.
And then in a second time the script created another document with the previously created template and replaced the tags with the function addTemplateVariable that accepts HTML content.

Unfortunately, when we open the final document, Word says that the document is corrupted. It comes from the template dynamically generated. We replaced the template by a template created manually and the problem disappears.

The second point is that the template mechanism can't solve our problem because after some tries I think a template can be add only once in a document.

As we want to generate a document with several tables with different numbers of rows for each ones, it seems the only one solution is that the function addElement could accept HTML content and this element could be added to an array of values in a table.

Could you confirm ?

Posted by admin  · 11-04-2013 - 12:13

Hello,

You can use a first docx as a template to create tables, and after open this file as a new template an replace placeholders within HTML or other content.
Phpdocx can create as many DOCX files as needed and use them as templates to do complex documents.

Regards.