文件目錄
引入文件
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');