问题
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".
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!
回答1:
It's mentioned in the documentation.
$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);
来源:https://stackoverflow.com/questions/23405525/phpexcel-preserve-rich-text-format-on-import