Forum


Replies: 6   Views: 4898
Replace table variable
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 neiron  · 31-05-2016 - 08:52

Can I make a table https://cloud.mail.ru/public/LU3f/XATebEGak ?

Those. values in cells through affix substitutes, but in some areas is the union of cells, both vertically and horizontally

Posted by admin  · 31-05-2016 - 09:33

Hello,

Yes, phpdocx allows to do tables such as the indicated. You could do that using the embedHtml method or templates.

Regards.

Posted by neiron  · 31-05-2016 - 11:37

I need to use the templates as It planned that the user will create a template and specify which fields he wants in the table. 

Example table (template docx-file):

____________________________________________
|_____________$header$___________________|
|___$val1$___|___$val2$___|___ $val3$___|

 

$docx = new CreateDocxFromTemplate('../../files/TemplateSimpleTable.docx');
$data = array(
                array(
                'val1' => '1',
                'val2' => '2',   
                'val3' => '3',            
                ),
                array(
                'val1' => '4',
                'val2' => '5',   
                'val3' => '6',            
                ),
                array(
                'val1' => '7',
                'val2' => '8',   
                'val3' => '9',            
                ),
        );
$docx->replaceTableVariable($data, array('parseLineBreaks' => true));
$docx->createDocx('example_replaceTableVariable_1');

The number of rows I do not know in advance. Those. is N-lines. Then he will go again connected cells, then again a lot of lines, etc.

 

Posted by admin  · 31-05-2016 - 15:53

Hello,

What license and version of phpdocx are you using?

Regards.

Posted by General research Computer Center  · 01-06-2016 - 08:12

Neiron my colleague. We use Pro version 5.5

It is clear that we can automatically generate a table. But we need to get the user himself can define a template for the table, he needed columns and styles for them.

Posted by admin  · 01-06-2016 - 09:29

Hello,

The method replaceTableVariable allows to add any values in a table; but it doesn't allow to add values then a header in the same table then values again... and so on.

You'll need to generated distinct tables for each set of values or generate the tables dynamically (using addTable or embedHtml or replaceVariableByHTML).

The next version of phpdocx will include, only for Corporate and Enterprise licenses, a new class called DOCXPATH that will ease tasks that the one you need.

Regards.