一、PHPExcel 读取csv文件 和 excel文件(.xlsx)
https://github.com/PHPOffice/PHPExcel
$filePath = 'example.xlsx';
$inputFileType = \PHPExcel_IOFactory::identify($filePath);
$objReader = \PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($filePath);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$list = [];
for ($column = "A"; $column <= $highestColumn; $column++) {
for ($row = 2; $row <= $highestRow; $row++) {
$cell = $sheet->getCell($column . $row)->getValue();
if($cell instanceof \PHPExcel_RichText) {
$cell = $cell->__toString();
}
$list[$row][] = $cell;
}
}
var_dump($list);