ñ in cell value

Topics: Developer Forum
Jul 23, 2009 at 12:43 AM



I need to display the actual character "ñ" instead of the "ñ" character.

$name = "Piña";


I wanted it to display as "Piña" in excel but it seems it cannot do so.

I am using PHPExcel/Writer/Excel5.php by the way.


Jul 23, 2009 at 7:07 AM

The best way is to do like this:

$name = 'Piña';
$sheet->setCellValue('A1', $name);

But make sure to save your PHP script as UTF-8 without BOM. Not all text editors can to this. Notepad++ can do it.

Jul 23, 2009 at 5:44 PM

$name = html_entity_decode("Piña",ENT_QUOTES,'UTF-8');