import data from Excel sheet

hello guys,

i need help how to import data from Excel sheet.

i used php-excel-reader though but causes error:

iconv() [<a href=‘function.iconv’>function.iconv</a>]: Detected an incomplete multibyte character in input string

thanks in advance,

Hi Neil,

Just hacked the same problem a few days ago. Check out the following Link. Its pretty much self explanatory. Let me know if you have any issues so that I can help.

Thanks for the response kevin, but how can i read / get the data on excel?

Would you please post your code? I’m currently working with PHP-ExcelReader and have no problem so far. Here is what I do:

// import PHPExcelReader extension


$data = new JPhpExcelReader($location);


for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) 


  for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) 


    $content = $data->sheets[0]['cells'][$i][$j];




this is my code:


$data=new JPhpExcelReader(dirname(FILE).DIRECTORY_SEPARATOR.’../../../extensions/phpexcelreader/example.xls’);

echo $data->dump(true,true);

and getting this error:

iconv(): Detected an incomplete multibyte character in input string

Sorry for my late reply :).

How about:


$data=new JPhpExcelReader(Yii::getPathOfAlias('ext.phpexcelreader').'\example.xls');

echo $data->dump(true,true);


did oyu souve it?

I have the same problem.

In portuguese, words has special caracters (ex: João)

with this words, the application fail.

An idea?

thanks (Obrigado)

hello guys,

sorry for the late reply…

i was able to fix my problem by modifying this line:

case ‘iconv’ : $result = iconv(‘UTF-16LE’, $this->_defaultEncoding, $string);


case ‘iconv’ : $result = @iconv(‘UTF-16LE’, $this->_defaultEncoding, $string);

i just add ‘@’ sign on the iconv command…

by doing that my error did not appear anymore…

by the way that line is residing at the excel_reader2.php file


though i can import data from excel, the problem now is, it can only upload xls file type not xlsx.

need help on this issue…

thanks everyone,

I’m having the same issue… I think that this library is able only to parse .xls file… Remember that the format of the data form .xls to .xlsx is completely different…

I tried to use also phpexcel but it won’t work…

Does anyone have a clean solution to this problem?

Thank you


How do you iterate inside the spreadsheet? I get "Undefined offset" when there is an empty cell :confused:


i have other issue.

I used this code:



$data=new JPhpExcelReader('example.xls');

echo $data->dump(true,true);


and the error:

Assigning the return value of new by reference is deprecated

Does anyone have a clean solution to this problem? Thank you.

any ideas to solve my problem ???

It seems that JPhpExcelReader is very old and doesn’t compatible with PHP 5.3. Try to find something newer.

Thanks. but i can’t find other Yii extensions to import data from excel to mysql. Do you suggest an extension ? Thanks again.

Had a problem with iconv and incomplete multibyte characters today. It turned out, that i tried to read from a utf16 file (csv exported by google adwords) and the fgets-method from php crunched the line ending characters (it thought of a line ending after the first byte, but in utf16 the line ending character is also two bytes long)

this led to this incomplete multibyte character error. the solution is to use fread to read some bytes to a buffer, then use iconv to convert this buffer to utf8 and store it. after you have read the whole file you can split it into single lines.

maybe this is also the problem with this excel reader.