Encoding error in Excel5 writer and RichText

Topics: Developer Forum, Project Management Forum
Sep 28, 2012 at 12:13 PM
Edited Sep 28, 2012 at 1:26 PM

I'm using PhpExcel 1.7.7. When I try to set cell value using this code

/* insert this code into Tests/30template.php, after line #40 */
$objRichText = new PHPExcel_RichText();
$objRichText->createText('nakład'); # polish word in UTF8
$objPHPExcel->getActiveSheet()->setCellValue('C1', $objRichText);

and save output as Excel5 then it's unreadable by Excel and OpenOffice shows random characters in row #20 (yes, value was set to A11).

Changing PHPExcel_Shared_String code from using iconv to mbstring didn't help.

When I set cell value without RichText, as below, then everything works fine.

$objPHPExcel->getActiveSheet()->setCellValue('C1', 'nakład'); # OK

PS When trying to save it as Excel2007, encoding works correct, but text formatting is wrong (text 'You have 2 errors: [red]some error[/red], [red]another error[/red]' becomes 'You have 2 errors: [red]some error, another error[/red]') so it's useless for me.

PS2 In 1.7.6 createText works OK (despite createTextRun doesn't)


Sep 28, 2012 at 1:17 PM

i think excel5 writer has some problem with richtext (i opened a 3ed some days ago with the same problem).

i had same problem (file broken) even with standard text (no strange encoding)

so maybe it's bugged? right now i've filtered the richtext part and I write richtext only with 2007 writer, otherwise i write plain text.

Feb 7, 2014 at 4:03 PM
I had the same issue with UTF - 8 Rich Text strings. I sorted this out using the latest stable release 1.7.9.

Earlier i was using 1.7.7 which had this issue.

So kindly make sure you have the latest stable release !