【发布时间】:2015-05-04 06:17:14
【问题描述】:
我曾尝试使用 RichText,而且大多数情况下它都可以正常工作,但有时(一个案例到 20 个)Microsoft Offices 无法打开某些文档,说它们已损坏。
代码是:
$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);
如果我用普通文本替换 RichText,它在所有情况下都能 100% 正常工作。
代码是:
$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",
' Иванов Пётр Анатольевна');
我很高兴离开 RichText。但我不能,因为客户希望在同一个单元格中有不同格式的文本。
看起来它与https://github.com/PHPOffice/PHPExcel/issues/284 有共同之处 任何想法为什么会这样?
【问题讨论】:
-
有人投票关闭?请解释原因