当我使用PHPTable创建一个简单的表时,行似乎有点太高了.我希望它们与字体具有相同的高度,并且在单元格中文本的下方或上方没有填充/间距..但是没有任何"填充"就无法使它工作...
码:
$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']);
}
Run Code Online (Sandbox Code Playgroud)
Vid*_*nes 10
找到了答案.必须在每个元素'spaceAfter'=> 0上添加段落样式.请参阅下面的工作代码:
// 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);
}
Run Code Online (Sandbox Code Playgroud)
这对我有帮助.希望它也能帮到你.