I'm trying to add some tables to a document, which after lot of work, it's showing right. Generated with PHPWord. The issue is that whatever I add in the table,row or cell style, it doesn't modify the table.
I've already tried: $table->addRow(15)
, $table->addRow(array('height'=>15))
and as is shown in the code below.
Also, there is no documentation on how to add a cell with two lines of text, because below 'Sign' I have to add 'Name'.
//TABLE1
$table = $section->addTable(array('width'=>100, 'borderSize'=> 1, 'borderColor'=>'000000'));
$table->addRow(15,array('height'=>15));
$table->addCell(array('width'=>150))->addText('COMPANY', $smallBoldFont);
$table->addRow();
$table->addCell()->addText('');
$table->addRow();
$table->addCell()->addText('');
//TABLE1
$section->addTextBreak(2);
//TABLE2
$table2 = $section->addTable(array('borderSize'=> 1, 'borderColor'=>'000000'));
$table2->addRow(100,array('height'=>80));
$table2->addCell(150,array('width'=>800))->addText('Recibed', $smallFont8);
$table2->addRow();
$table2->addCell()->addText('Time:', $smallFont8);
$table2->addCell()->addText('Sign:', $smallFont8);
//TABLE2
Is there a reason why PHPWord ignores my format style to tables? Is there any other way of doing it better?
Desired output:
Actual output:
In documentation is all. Just to read it deeply. Here is section how to create tables, including creation of tables with multicolumn cells
I don't know if PHPWord has some pre-defined units for case if you miss to use them. But it seems you need to set units for width. But you should test units and numbers as you need.
Order to create multicolumn cell is gridSpan(). So line for creation of the first row of the second table (probably) should be:
$table2->addCell(150,array('width'=>800))->gridSpan(2) ->addText('Recibed', $smallFont8);
PHPWord uses twip as default unit. And all cells have to match its width. The smallest cell is taken for entire column.
For convertion from twips to other units may be used EndMemo (Topography Conversion Online).
250 pixels are 3750 twips.