PHPWord – 我可以在一个表格单元格中连接多种字体样式吗?

我正在尝试在
PHPWord中编写一个表,在一个单元格中有多种文本格式,例如在HTML中:

<table>
 <tr>
  <td><b>L</b><sub>1</sub> = 999</td>
 </tr>
 <tr>
  <td>Blah</td>
 </tr>
</table>

我会写这样的东西:

$table = $section->addTable('myOwnTableStyle');

$table->addRow();
$table->addCell(5000)->addText("HOW WOULD I STRING MULTIPLE TEXT FORMATS IN HERE WITH BOLD AND SUBSCRIPTS IN THIS CELL?  IS THERE A CONCATENATE?");
$table->addRow();
$table->addCell(5000)->addText("Blah");

最佳答案 试试这个:

 $table -> addRow();
 $table -> addCell() -> addText("normal text"); 
 $cell = $table -> addCell();
 $cellRun = $cell->addTextRun($style); 
 $cellRun -> addText("one ");
 $cellRun -> addText("text concat");            

Here you can find带有示例的文档

点赞