ñ in cell value

Topics: Developer Forum
Jul 22, 2009 at 11:43 PM



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 6: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 4:44 PM

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