Handling a degree symbol - °

Topics: User Forum
Jul 4, 2014 at 8:31 AM

Problem: I have a problem handling a degree symbol when converting into Excel 2007.

I export data from a SQL database and format some of it before exporting to Excel. The PHP page header is set to ISO-8859-1 so I can handle accented characters but one particular record is giving me problems. The text of the field is:
360° Feedback
The text displays on my page OK but when I export it to Excel the text becomes:

I added the ISO header because some accented characters did the same (hence mentioning it).

To set the cell I have:
->setCellValue('C1', '<value>')
I have tried to force the cell as a string type, like so:
->setCellValueExplicit('C1', '<value>', PHPExcel_Cell_DataType::TYPE_STRING)
but this causes the following error because of the degree symbol:
Detected an illegal character in input string in /var/www/html/scripts/Classes/PHPExcel/Shared/String.php on line 579
Is there a way I can get this character into Excel?
Jul 4, 2014 at 9:38 AM
PHPExcel expects UTF-8; if your string is ISO-8859-1, then convert it to UTF-8 using mb_* functions or iconv()
Jul 4, 2014 at 10:11 AM
Great that worked a treat.

Thanks Mark.