Euro Symbol in XLSX

Topics: Developer Forum, Project Management Forum, User Forum
Nov 10, 2008 at 8:15 AM
Hello,

i have problems adding the euro symbol to a text field like "abc 200 €!".
Everytime the euro symbol will be displayed as "?".

I have the latest PHPExcel version, PHP5.2.6 with mbstring.

Any ideas?

Regards,
freibeuter
Developer
Nov 10, 2008 at 9:43 AM
How are you adding the Euro symbol? Can you show some code? Did you remember to save your PHP script as UTF-8?
Nov 10, 2008 at 9:48 AM
Hi,

no problem:

$cell="A1";
$data=utf8_encode("abc 123 €!");

$objPHPExcel->getActiveSheet()->setCellValue($cell, $data);

Thx
Developer
Nov 10, 2008 at 10:17 AM
Why not just save file as UTF-8 (without BOM)? You can then insert Unicode characters directly. That is the elegant way... and faster too!

$cell="A1";
//$data=utf8_encode("abc 123 €!");
$data="abc 123 €!";

$objPHPExcel->getActiveSheet()->setCellValue($cell, $data);

Screenshot in Notepad++ :
http://img389.imageshack.us/img389/5811/nnscreenshotup7.png
 
May 7, 2009 at 12:34 PM
An easy way to handle the euro symbol in PHPExcel2007 :

$cell="A1";
//$data=utf8_encode("abc 123 €!");
$data=
str_replace(chr(0xC2).chr(0x80) , chr(0xE2).chr(0x82).chr(0xAC), utf8_encode("abc 123 €!") );
$objPHPExcel->getActiveSheet()->setCellValue($cell,
$data);

Or if you source file is already UTF8 encoded :

$cell="A1";
//$data=utf8_encode("abc 123 €!");
$data=
"abc 123 ".chr(0xE2).chr(0x82).chr(0xAC)."!";
$objPHPExcel->getActiveSheet()->setCellValue($cell,
$data);


This also works for number formats.