【问题标题】:Create a table - phpword创建表 - phpword
【发布时间】: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 文档,似乎我遗漏了一些东西。

【问题讨论】:

标签: php laravel phpword


【解决方案1】:

表格网格不适用于仅使用单元格宽度来实现跨多列或多行的单元格;跨多列多行的单元格需要明确定义。

您可以在How to make the table in word using PHPWord which includes multiple rowspan and colspan?找到另一个类似的问题和答案示例

【讨论】:

    猜你喜欢
    • 2017-02-19
    • 1970-01-01
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 2023-03-03
    • 1970-01-01
    相关资源
    最近更新 更多