Hello,
Is posible set the horizontal aligment of just one cell using the addTable function. I see there is a 'vAlign' parameter but I can't find one for the horizontal aligment.
Thank you.
Hello,
Is posible set the horizontal aligment of just one cell using the addTable function. I see there is a 'vAlign' parameter but I can't find one for the horizontal aligment.
Thank you.
Done it!
I did it using the addText function with the 'jc' parameter.
Thanks anyway!
$text = '123'; $paragraphOptions = array( 'jc' => 'center' ); $par = $docx->addText($text, $paragraphOptions); $data[] = array( array( 'value' => $par, 'cellMargin' => 200, 'rowspan' => 2, ) );
not working :(
Hello,
This post is more than year old, and a lot changes were done to the library since the release of phpdocx 4.
For example the js was removed, and now you must use the textAlign parameter. Please take a look at the included examples and the documentation available on:
http://www.phpdocx.com/api-documentation/word-content/add-paragraph-text-Word-document-with-PHP
Regards.
Ok!.
How do I align text in a cell in the middle?
Example:
$docx = new CreateDocx();
$data[] = array( array( 'value' => 'text1', 'vAlign' => 'center' ), array( 'value' => 'text2', vAlign' => 'center' ) )
$paramsTable = array( 'border' => 'none', 'tableAlign' => 'center', 'textProperties' => array('font' => 'Arial', 'fontSize' => 10), ); $docx->addTable($data, $paramsTable, array( 0 => array('tableHeader' => TRUE), )); $docx->createDocxAndDownload('report.docx');
Hello,
This is a simple example to add centered text:
<?php
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$textFragment = new WordFragment($docx);
$text = array();
$text[] =
array(
'text' => 'Centered text',
'underline' => 'single'
);
$paragraphOptions = array(
'textAlign' => 'center',
);
$textFragment->addText($text, $paragraphOptions);
$valuesTable = array(
array(
$textFragment,
),
array(
'Other text',
),
array(
'Other text',
),
);
$docx->addTable($valuesTable);
$docx->createDocx('output');
Regards.