Categories > OpenTBS with DOCX >

2 dimensional array to docx table

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Walter
Date: 2014-11-18
Time: 02:18

2 dimensional array to docx table

Hello,

Is there any easy way to build a simple table in a docx document based on this array?
$raw = array(
    array('a', 'b', 'c'),
    array('d', 'e', 'f'),
    array('g', 'h', 'i')
);

Thanks in advance.
By: Skrol29
Date: 2014-11-19
Time: 10:09

Re: 2 dimensional array to docx table

Hi Walter,

Your array is totally equivalent to this one :
$raw = array(
    array(0 => 'a', 1 => 'b', 2 => 'c'),
    array(0 => 'd', 1 => 'e', 2 => 'f'),
    array(0 => 'g', 1 => 'h', 2 => 'i')
);
So you can use a normal TBS block merging with columns 0, 1 and 2.
Example :
| First col           | Second col|  Third col |
| [b.0;block=tbs:row] | [b.1]     | [b.2]      |
By: Walter
Date: 2014-11-24
Time: 02:41

Re: 2 dimensional array to docx table

Worked great!!

Thanks a lot!!