11-24 4,089 views
结合thinkphp 使用phpexcel读取excel文件
<?php
import('Lib.Excel.PHPExcel');
$object = new \PHPExcel();
//excel文件路径
$filePath = 'phone.xlsx';
// $data = $object->load($filePath);
$PHPReader = new \PHPExcel_Reader_Excel2007();
if(!$PHPReader->canRead($filePath)){
$PHPReader = new \PHPExcel_Reader_Excel5();
if(!$PHPReader->canRead($filePath)){
echo 'no Excel';
return ;
}
}
//载入文件,输出数组
$PHPExcel = $PHPReader->load($filePath);
$data = $PHPExcel->getActiveSheet()->toArray();
var_dump($data);
?>