Categories > OpenTBS with DOCX >

Data generation doesn't work

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: lena
Date: 2016-09-15
Time: 11:58

Data generation doesn't work

Hi,

I try to implement the tbs bundle, but can not understand how to work with blocks (table)

my code example:


        $TBS = $this->container->get('opentbs');
        $TBS->setOption('noerr', true);
        // load your template
        $TBS->LoadTemplate('template.docx');
        // replace variables
        $TBS->MergeField('order', array('office' => 'office name',
        ));
        $data = array(
                array('date' => '2013-10-13', 'thin' => 156, 'heavy' => 128, 'total' => 284),
                array('date' => '2013-10-14', 'thin' => 233, 'heavy' =>  25, 'total' => 284),
                array('date' => '2013-10-15', 'thin' => 110, 'heavy' => 412, 'total' => 130),
                array('date' => '2013-10-16', 'thin' => 258, 'heavy' => 522, 'total' => 258),
        );
        $TBS->MergeBlock('b', $data);

        $TBS->Show(OPENTBS_DOWNLOAD, 'file.docx');


docx template (in table):

Category    [b.date]
Thin    [b.thin;block=td;parallel=tbs:table]
Heavy    [b.heavy]
Total    [b.total]

and as result i become or  only the first row, or the same:

Category    [b.date]
Thin    [b.thin;block=td;parallel=tbs:table]
Heavy    [b.heavy]
Total    [b.total]


Could somebody help me? what make i wrong?
By: lena
Date: 2016-09-15
Time: 12:32

Re: Data generation doesn't work

I have found the antwort,  all works with tbs:cell, but i do not understand, why i can not  use simple block=td  instead block=tbs:cell
By: Skrol29
Date: 2016-09-15
Time: 18:00

Re: Data generation doesn't work

Hi lena,

> i do not understand, why i can not  use simple block=td  instead block=tbs:cell

This is because there is no <td> element in the XML of a DOCX.
"tbs:cell" is a TBS alias that refers the convenient XML entity depending to the current document. For a DOCX, the element is <w:tc>, but its' always better to use the alias.