简体   繁体   English

创建一个表-phpword

[英]Create a table - phpword

I am trying to create a table with phpword. 我正在尝试用phpword创建一个表。 however I am struggling with the configuration syntax of this table. 但是,我正在为该表的配置语法苦苦挣扎。

Below is my code: 下面是我的代码:

    // 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('');

The picture below shows what I am trying to achieve: 下图显示了我要实现的目标: 在此处输入图片说明

and What I am getting is too different from the goad. 而且我得到的与山羊太不同了。 Please assist. 请协助。 I've going through the phpword documentation and seems like I missing something. 我已经遍历了phpword文档,似乎我缺少了一些东西。

The table grid doesn't work with just playing with cell widths to achieve cells that span multiple columns or rows; 表格网格不能仅通过播放单元格宽度来实现跨越多个列或行的单元格; the cells spanning multiple columns and multiple rows need to be explicitly defined. 需要明确定义跨越多列和多行的单元格。

You can find another similar question with answer example at How to make the table in word using PHPWord which includes multiple rowspan and colspan? 您可以在如何使用PHPWord在单词表中创建表格(包含多个rowpan和colspan)中找到另一个与答案示例类似的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM