Set different font-color inside 1 cell using PHPExcel

丶灬走出姿态 提交于 2020-01-05 07:49:22

问题


I want to make the text have different color inside 1 cell using PHPExcel, but i can't find the info about it. Is it possible?

I believe it can be done from the xls, but can it be done using programming, in PHPExcel?


回答1:


Yes it can be done in PHPExcel, using Rich Text objects.

They are described in the PHPExcel documentation and there are examples provided

$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/48277293/set-different-font-color-inside-1-cell-using-phpexcel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!