When im creating a simple table with PHPTable the rows seems to be a bit too height. I would like them to be the same heights as the font, and with no padding/spacing below or above the text in the cells.. but can't get it to work without any "padding"...
Code:
$styleTable = array('borderSize'=>0,
'borderColor'=>'eeeeee',
'cellMargin'=>0,
'spaceBefore' => 0,
'spaceAfter' => 0,
'spacing' => 0);
$PHPWord->addTableStyle('myOwnTableStyle', $styleTable);
$table = $section->addTable('myOwnTableStyle');
foreach($aryData['json_data'] as $data) {
$table->addRow();
$table->addCell(4000)->addText($data['label'] . ':', array('bold'=>true));
$table->addCell(8000)->addText($data['value']);
}
Found the answer. Had to add paragraph style on each element 'spaceAfter' => 0. See working code below:
// New Word Document
$PHPWord = new PHPWord();
// This is used to remove "padding" below text-lines
$noSpace = array('spaceAfter' => 0);
$section = $PHPWord->createSection();
$table = $section->addTable();
foreach($aryData['json_data'] as $data) {
$table->addRow();
$table->addCell(4000)->addText($data['label'] . ':', array('bold'=>true), $noSpace);
$table->addCell(8000)->addText($data['value'], array(), $noSpace);
}
This helped me. Hopes it helps you as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With