使用PhpSpreadsheet在单元格中插入HTML代码

时间:2020-08-20 15:29:45

标签: php html phpspreadsheet

是否可以使用PhpSpreadsheet将HTML代码插入到单元格中? 例如此代码:

     X [ m ]  Y [ m ]  Z [ m ]  Z_2 [ m ]
0         1     1      0.0      0.0
1         2     0.5    0.1      0.0
2         3     2      0.3      0.5
3         4     1      0.4      0.5
4         5     3      0.5      0.5
5         1     4      0.6      0.5
6         2     1.5    0.8      1.0 
7         3     6      1.0      1.0
8         4     3      1.2      1.0
9         5     4      1.5      1.5 
...

此HTML已经为文本提供了一种样式,而无需通过预定义的PhpSpreadsheet的样式函数。

1 个答案:

答案 0 :(得分:0)

解决方案已存在: 您只需要添加以下内容:

$CODE="<font color="red">Hello World!</font>";
$html = new PhpOffice\PhpSpreadsheet\Helper\Html();
$HTMLCODE = $html->toRichTextObject($CODE);
相关问题