reading special characters from excel

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

Hi,

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?

Thanks!

Itamar

Developer
Nov 17, 2009 at 12:26 AM

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

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

Something like:

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

var_dump($value);
var_dump(utf8_decode($value));

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

Developer
Nov 17, 2009 at 3:52 AM
Edited Nov 17, 2009 at 3:59 AM

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

See screen shots in this post: http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=68083#Post231591

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

Nov 17, 2009 at 4: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 Đễươêậề');

var_dump($value);

what i see

Developer
Nov 17, 2009 at 4: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 4: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 5: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.

 

Itamar