【发布时间】:2018-12-10 15:57:52
【问题描述】:
我正在尝试使用 phpword 创建一个表。但是我正在为这个表的配置语法而苦苦挣扎。
下面是我的代码:
// Define table style arrays
$styleTable = array('borderSize'=>2, 'cellMargin'=>10);
$styleFirstRow = array('borderBottomSize'=>5, 'bgColor'=>'#D3D3D3');
// Define cell style arrays
$styleCell = array('valign'=>'center', 'bgColor'=>'#D3D3D3');
$styleCellBTLR = array('valign'=>'center');
// Define font style for first row
$fontStyle = array('bold'=>true, 'align'=>'center');
// Add table style
$wordTest->addTableStyle('CoverLine', $styleTable, $styleFirstRow);
// Add table
$table = $newSection->addTable('CoverLine');
// Add row
// $table->addRow(200);
// Add cells
// $table->addCell(10000, $styleCell)->addText('Employer Details ', $fontStyle);
//$table->addCell(1800)->addText($curriculum->curriculum_code);
$table->addRow(500);
$table->addCell(2200, $styleCell)->addText(' Code', $fontStyle);
$table->addCell(5000, $styleCell)->addText(' Title', $fontStyle);
$table->addRow(500);
$table->addCell(2200)->addText('', $fontStyle);
$table->addCell(5000)->addText('', $fontStyle);
$table->addRow(500);
$table->addCell(2200, $styleCell)->addText('', $fontStyle);
$table->addCell(1200, $styleCell)->addText(' Name', $fontStyle);
$table->addCell(2500, $styleCell)->addText(' Email', $fontStyle);
$table->addCell(2000, $styleCell)->addText(' Phone', $fontStyle);
$table->addCell(2000, $styleCell)->addText(' Logo', $fontStyle);
$table->addRow(600);
$table->addCell(700, $styleCell)->addText(' Development Quality Partner', $fontStyle);
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
而且我得到的与刺激太大不同。 请协助。我已经浏览了 phpword 文档,似乎我遗漏了一些东西。
【问题讨论】:
-
你的目标/期望的输出是什么?
-
问题所附图片是想要的输出@Phil
-
那么您检查/尝试了我的答案吗?
-
您的示例代码非常少,但不完整和/或可验证。请参阅How to create a Minimal, Complete, and Verifiable example