【问题标题】:How to use multiple style in PHPWord?如何在 PHPWord 中使用多种样式?
【发布时间】:2016-05-09 11:05:59
【问题描述】:

其实我在 PhpWord 中使用以下代码

$table->addCell(10500, $styleCell)->addText('<span style="background-color:#003300;">Test</span><span style="background-color:#00000;">Dinesh</span>');
$table->addRow();

请帮忙解决我的问题...

【问题讨论】:

    标签: php phpword


    【解决方案1】:

    您可以通过创建一个textrun并分别添加不同颜色的部分来实现改变单元格内容的颜色:

    $textrun = $table->addCell(10500, $styleCell)->addTextRun()
    $textrun->addText(htmlspecialchars("Test", ENT_COMPAT, 'UTF-8'), array('color' => '003300'));
    $textrun->addText(htmlspecialchars("Dinesh", ENT_COMPAT, 'UTF-8'), array('color' => '000000'));
    $table->addRow();
    

    【讨论】:

      猜你喜欢
      • 2010-09-06
      • 2013-08-06
      • 1970-01-01
      • 2020-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-27
      相关资源
      最近更新 更多