1

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?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Tebe
  • 3,176
  • 8
  • 40
  • 60

1 Answers1

0

Problem was solved by switching to Excel2007 instead of Excel5.

Still looking for solution with Excel5

Tebe
  • 3,176
  • 8
  • 40
  • 60