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