PHP利用phpExcelReader讀取Excel錯誤總結如下:
錯誤一:Deprecated: Assigning the return value of new by reference is deprecated in Assigning the return value of new by reference is deprecated in E:\WebSite\htdocs\EXCEL2\Excel\reader.php on line 261
這個是php5.3以後版本的問題,php5.3以下版本不會出現
$this->_ole =& new OLERead();
改為:
$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 E:\WebSite\htdocs\EXCEL2\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
錯誤四:
Fatal error: Maximum execution time of 30 seconds exceeded in E:\WebSite\htdocs\EXCEL2\Excel\oleread.inc on line 172
下載的裡面的jxlrwtest.xls這個excel檔案有錯誤,請自己建立一個
下載地址:http://sourceforge.net/projects/phpexcelreader/