I am dynamically creating a msword document in PHP using PHPDocx (free version).
I am having trouble get a table to centre align in the page. I have tried passing in the style parameters as stated in the documentation, but no joy.
Any ideas on how to fix this?
My current code is;
$docx = new CreateDocx();
$valuesTable = array(
array(
11,
12
),
array(
21,
22
),
);
$paramsTable = array(
'jc' => 'center',
'border' => 'single',
'border_sz' => 20
);
$docx->addTable($valuesTable, $paramsTable);
$docx->createDocx('example_table');
I had the same problem. If you looking at CreateTable source you can see that method for aligning generateJC() is never called so passing a ‘jc’ parameter has no effect (this is the same with most of the options).
You can override this creating a new class like:
and then calling: