excel.php
<?php
$file = '1.xlsx';
if(!file_exists($file)){
return "文件不存在";
}
require_once "./PHPExcel/IOFactory.php";
//引入excel文件
$excel = PHPExcel_IOFactory::load($file);
//设置为默认表
$excel -> setActiveSheetIndex(0);
//获取表格数量
$sheetCount = $excel->getSheetCount();
//获取行数
$row = $excel->getActiveSheet()->getHighestRow();
//获取列数
$col = $excel->getActiveSheet()->getHighestColumn();
echo '表格数量:'.$sheetCount.';行数:'.$row.';列数:'.$col;
$data = [];
for ($i=1;$i<=$row;$i++){
for ($c = 'A';$c<=$col;$c++){
$data[]=$excel->getActiveSheet()->getCell($c.$i)->getValue();
}
echo '<pre>';
print_r($data);
}
效果图: