PHP has developed a lot, And now pear is very easy to use. There are related classes to read the content in the Excel file. If you don't want to use pear, you can consider using excel_class.php and google it, you can find the source code download for this class, and also find the basic example code, which is very convenient to use.
In PHP encoding conversion need to pay attention to is, read from the Excel is a UTF-16LE encoding, if the use of excel_class in mobile applications, you need to pay attention to, because the phone is usually support UTF-8 encoding, encoding conversion is involved.
For example
Echo $ return [Sheet2] [0] [0];
To display the content in the 1st rows and 1st columns. The original content is "start". When PHP is used to display the content on the web, it is indeed "start", but the source code of viewing the web page is
#24320 & #22987
Where & # is to display on the web page, the hexadecimal representation of 24320 and 22987 is the UTF-16LE code of "start.
So what we need to do is to convert this UTF-16LE code into a UTF-8 code.
First, open excel_class.php, find the uc2html function, comment out the code in the function, and directly return the parameter, that is, the function does not perform any operation.
Function uc2html ($ str ){
Return $ str;
}
Next, use the function mb_convert_encoding provided in PHP to convert the UTF-16LE to a UTF-8.
Echo mb_convert_encoding ($ return [Sheet2] [0] [0], 'utf-8', 'utf-16le ');
At this point, PHP Code Conversion from UTF-16LE to UTF-8 is completed.