本文介绍了PHPExcel - 在导入时保留丰富的文本格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理的项目的一个组件是使用PHPExcel从Excel中导入单元格中的文本,作为填充MySQL数据库的更快捷方式。
如何实现保留单元格内容的富文本格式 Quick Brown Fox

A component of a project I am working on is to import text in cells from Excel using PHPExcel as a quicker way to populate the MySQL database.How can I achieve preserving the Rich Text formatting of the Cell Contents e.g. "The Quick Brown Fox".

我猜这需要将内容格式解析为匹配HTML标签?有没有办法在PHPExcel中实现这一点?

I am guessing it would require parsing the content-format somehow into matching HTML tags? Is there a way to achieve this in PHPExcel?

感谢!

Thanks!

推荐答案

在文档中提到它。



    $objRichText = new PHPExcel_RichText();
    $objRichText->createText('This invoice is ');

    $objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month');
    $objPayable->getFont()->setBold(true);
    $objPayable->getFont()->setItalic(true);
    $objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );

    $objRichText->createText(', unless specified otherwise on the invoice.');

    $objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);

这篇关于PHPExcel - 在导入时保留丰富的文本格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 18:57
查看更多