thinkphp5 PHPExcel 引入與報錯解決


文件目錄

 

 

 

引入文件

use think\facade\App;
require_once App::getRootPath().'/extend/PHPExcel/PHPExcel.php';

 

 

 

 

報錯:

PHPExcel報錯ZipArchive::locateName():

Excel版本問題。
解決方法:判斷當前版本。
//   \PHPExcel_IOFactory  前面缺少斜杠會報錯  找不到類
$objReader = \PHPExcel_IOFactory::createReader('Excel2007'); 

if(!$objReader->canRead($file_name)){
  $objReader = \PHPExcel_IOFactory::createReader('Excel5'); }   $objPHPExcel = $objReader->load($file,$encode='utf-8'); 
親試,有效。

 

PHPExcel_IOFactory' not found

//   \PHPExcel_IOFactory  前面缺少斜杠會報錯  找不到類

$objReader = \PHPExcel_IOFactory::createReader('Excel5');


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM