PhpWord完全忽略了单元格样式属性

时间:2018-05-02 09:06:44

标签: symfony phpword

在创建PDF或HTML文档时,PhpWord完全忽略addCell()方法的第二个参数。我正在使用symfony 3.5并更新了所有库。 PhpWord目前为0.14,dompdf为0.8.2。

我正在尝试将它们输出为PDF或HTML文档,但它们似乎都没有使用任何数组参数。

<?php

namespace AppBundle\Controller;

use AppBundle\Entity\ModProduct;
use AppBundle\Entity\ModProductsize;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\IOFactory;
use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\SimpleType\Jc;
use PhpOffice\PhpWord\Style\Language;
use PhpOffice\PhpWord\Shared\Converter;
use PhpOffice\PhpWord\Style\Table;
use PhpOffice\PhpWord\Shared\Html;
use PhpOffice\PhpWord\Style\Section;
use Symfony ...

public function listAction()
    {
    Settings::setPdfRenderer(Settings::PDF_RENDERER_DOMPDF, $this->get('kernel')->getProjectDir() . '/vendor/dompdf/dompdf/');

    ....

    $phpWord = new PhpWord();

    $section = $phpWord->addSection();

    $header1 = array('size' => 22, 'bold' => true, 'name' => 'Trebuchet MS');
    $header2 = array('size' => 14, 'name' => 'Trebuchet MS');
    $header3 = array('size' => 17, 'name' => 'Trebuchet MS');

    $section->addText('Supplier Name', $header1); // STYLING WORKS

    $table = $section->addTable();

    $row = $table->addRow();

    $w = array(
        Converter::cmToTwip(7.4),
        Converter::cmToTwip(2.8),
        Converter::cmToTwip(2.6),
        Converter::cmToTwip(1.5)
    );

    $fw = 0;
    foreach($w as $value){
        $fw += $value;
    }

    $row->addCell($w[0], ['bgColor' => '999999'])->addText('Produkt');
    $row->addCell($w[1], $header2)->addText('ArtNr');
    $row->addCell($w[2], ['align' => 'center'])->addText('EK-Preis');
    $row->addCell($w[3])->addText('Bestm.');

}

Stlying for text工作正常,但Cell完全被忽略。尝试了bgColor,align,gridSpan,...... PDF和HTML文件都没有改变。

0 个答案:

没有答案