reading special characters from excel

Topics: User Forum
Nov 16, 2009 at 1:50 PM


I'm trying to read an excel file (with excel5 reader) that has characters like "ễ ề ọ ầ ậ ị ơ ư" and all I seem to get is question marks.

Do you have any idea what the problem is?



Nov 17, 2009 at 1:26 AM

Where do you see the question marks? What code are yo using?

Nov 17, 2009 at 4:40 AM
Edited Nov 17, 2009 at 4:45 AM

Something like:

$reader = PHPExcel_IOFactory::createReader('Excel5');
$excel = $reader->load('somefile.xls');
$sheet = $excel->getSheetByName('Import');
$value = $sheet->getCellByColumnAndRow(1, 1)->getValue();


In both cases I would see "?" whenever "ơ" or so is expected.

Nov 17, 2009 at 4:52 AM
Edited Nov 17, 2009 at 4:59 AM

Make sure that the correct encoding is selected in your browser when you view the output.

See screen shots in this post:

If this does not help, can you post a screen shot of what you are seeing?

Nov 17, 2009 at 5:40 AM

It seems i'm using the right encoding: Bellow is the result of printing twice the same string, first directly from the php file and then from the excel

var_dump('testing Đễươêậề');


what i see

Nov 17, 2009 at 5:46 AM

Do you have iconv extension enabled? Do you have mbstring extension enabled in PHP. Check using phpinfo().

You need at least one of them enabled. Maybe you don't have any of them?

Nov 17, 2009 at 5:02 PM

Both were enabled. iconv encoding was set to ISO-8859-1, but also when I set it to UTF-8 with iconv_set_encoding I get the same result

Nov 17, 2009 at 6:26 PM

Ah! I just found out that without being aware, I was using phpExcel162. I upgraded to 165 and now the letters are displayed correctly.

So I guess it's not such an urgent issue.

Many thanks for trying to help.