编程语言
首页 > 编程语言> > PHPWord – 我可以在一个表格单元格中连接多种字体样式吗?

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带有示例的文档

标签:php,phpword
来源: https://codeday.me/bug/20190703/1363429.html