问题
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