PHP读取Excel里的文件

时间:2023-03-09 18:16:37
PHP读取Excel里的文件

下载phpExcelReader  http://sourceforge.net/projects/phpexcelreader

解压后得到以下这些文件

PHP读取Excel里的文件

jxlrwtest.xls这个excel文件有错误。自己又一次建了个

example.php和example2.php两个文件的输出不一样

example.php

PHP读取Excel里的文件

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3p5MzYx/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

example2.php

PHP读取Excel里的文件

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3p5MzYx/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

另外。在执行example.php的时候可能报一些错误,以下是在网上找的解决的方法:

错误一:Deprecated: Assigning the return value of new by reference is deprecated in D:\wamp\www\phpExcelReader\Excel\reader.php on line 262

这个是php5.3以后版本号的问题,php5.3下面版本号不会出现

$this->_ole =& new OLERead();

php5.3開始后。废除了php中的”=&”符号,所以要想复制,直接用=引用就可以

错误二:Warning: require_once(Spreadsheet/Excel/Reader/OLERead.php) [function.require-once]: failed to open stream: No such file or directory in D:\wamp\www\phpExcelReader\Excel\reader.php on line 31

改动办法:

将require_once 'Spreadsheet/Excel/Reader/OLERead.php';

改为:require_once 'oleread.inc';

错误三:

Notice: iconv() [function.iconv]: Detected an illegal character in input string in D:\wamp\www\phpExcelReader\Excel\reader.php on line 1056

改动办法:

将example.php里面的

$data->setOutputEncoding('CP1251');

改为:

$data->setOutputEncoding('UTF-8');  //或者你的程序编码是gbk的就改为GB2312

错误四:下载的里面的jxlrwtest.xls这个excel文件有错误,请自己创建一个