Forum


Replies: 3   Views: 3094
How do i set table array value to word fragment, for addtable
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 indrakusmana  · 03-11-2016 - 10:54

Hello,

So, I'm reading in addTable api-document, that we can set value of tableData to word fragment, here the explanation:

value -> mixed -> The text to be inserted (string) or a Word fragment if we want to insert complex paragraphs, images, nested tables, ...

so, I try to make it, like this:

$wf = new WordFragment($docx, 'document');
$wfTable = new WordFragment($docx, 'document');
$text = array(
'text' => 'Hello',
'bold' => true
);
$prop = array(
'textAlign' => 'center'
);
$wfTable->addText($text, $prop);

$table[] = array(
array(
'value' => $wfTable,
'backgroundColor' => '0022cc'
),
array(
'value' => 'some text',
'backgroundColor' => '0022cc'
)
);

$wf->addTable($table);

assume that I already declare everything before.

But the result is corrupted document, I'm using free phpdocx, could anyone pell tell me what happend? or how could I fix it?

Posted by admin  · 03-11-2016 - 11:53

Hello,

We recommend you to check the included examples; there're examples that show how to do it.

For further support, after you have purchased a license, please contact us again.

Regards.

Posted by indrakusmana  · 03-11-2016 - 16:24

Hello Admin,

I already check all samples for addTable, but in the samples, it only show an addText wordfragment with only its paragraphContents, but not with its paragraphOptions (sample_3).
I need an addText WordFragment that have a paragraphOptions in it, in my code it has textAlign option, I need it to be in the center, alone,
not with the other cells. I simply cannot use textProperties in addTable tableProperties, because it will change all cells, and textAlign is not exist in addText paragraphContents. Or maybe did I miss something? Could you help me again with this?

Thank you admin,

 

Best regards.

Posted by indrakusmana  · 04-11-2016 - 02:16

Nevermind, I already found the answer. Thank you by the way.