如何去除PhpWord表格中的边框?

问题描述 投票:0回答:1

我已经使用 phpword 创建表。我只想为特定单元格设置边框。为了测试,我创建了两种数组样式,

border=6
border=0
。我将 style1 设置为单元格 1,将 style2 设置为单元格 2。在生成的 Word 文件中,两个单元格都有边框。

<?php
 include_once '../vendor/autoload.php';
use PhpOffice\PhpWord\Element\Table;
use PhpOffice\PhpWord\TemplateProcessor;
use PhpOffice\PhpWord\ComplexType\TblWidth;

$styleCell1 = array('borderColor' =>'black', 'borderSize' => 6)
$styleCell2 = array('borderColor' =>'black', 'borderSize' => 0);
$table = new Table();

    $table->addRow();
    $table->addCell(700,$styleCell1)->addText('cell 1');
    $table->addCell(500,$styleCell2)->addText(cell 2);
 $phpWord = new TemplateProcessor('phpWordTableTemplate.docx');
 $phpWord->setComplexBlock('{table}', $table);
 $phpWord->saveAs('template_with_table_output.docx');
 ?>

如何去除 PhpWord 表格中的边框?

php border phpword
1个回答
0
投票

只能为表格单元格设置无边框:

use PhpOffice\PhpWord\SimpleType\Border;
$styleCell2 = array('borderColor'=>'black', 'borderSize'=> 0,  'borderStyle' => Border::NONE);
© www.soinside.com 2019 - 2024. All rights reserved.