1
votes

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
but that set color for text inside cell, which make 1 cell color. but i want have more than 1 color inside 1 cell - Gabriel

1 Answers

3
votes

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);