I've tried to use RichText and mostly it works fine but sometimes (one case to 20) Microsoft Offices fails to open certain documents saying that they are broken.
The code is:
$objRichText = new PHPExcel_RichText();
$objRichText->createTextRun("Руководитель ")
->getFont()->setSize($textSize);
$objRichText->createTextRun(" Иванов Петр Анатольевна ")
->getFont()->setSize($textSize)
->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
$sheet->mergeCells("B$i:F$i")
->setCellValue("B$i", $objRichText);
If I replace RichText with usual text it works 100% fine in all cases.
The code is:
$sheet->getStyle("B$i")->getFont()->setBold(true);
$sheet->setCellValue("B$i", 'Руководитель ');
$styleArray = array('font' => array('bold' => false, 'underline' => PHPExcel_Style_Font::UNDERLINE_SINGLE),);
$sheet->getStyle("C$i")->applyFromArray($styleArray);
$sheet->mergeCells("C$i:F$i")->setCellValue("C$i",
' Иванов Пётр Анатольевна');
I would be glad to leave RichText. But I can't because client would like to have differently formatted text in the same cell.
Looks like it has something in common with https://github.com/PHPOffice/PHPExcel/issues/284 Any ideas why it happens so?