PHP读取Excel里的文件

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

解压后得到以下这些文件


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

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

example.php


example2.php



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

错误一:Deprecated: Assigning the return value of new by reference is deprecated in D:wampwwwphpExcelReaderExcel eader.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:wampwwwphpExcelReaderExcel eader.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:wampwwwphpExcelReaderExcel eader.php on line 1056


改动办法:

将example.php里面的

$data->setOutputEncoding('CP1251');

改为:

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


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



原文地址:https://www.cnblogs.com/bhlsheji/p/5072519.html