gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 23:20:07 26 4
gpt4 key购买 nike

我正在尝试用 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带有示例的文档

关于PHPWord - 我可以在一个表格单元格中连接多种字体样式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25488731/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com