$filename="student.xlsx";//指定excel文件 $temp=substr($filename,strpos($filename,".")+1); if($temp=='xlsx' ){ $objReader = PHPExcel_IOFactory::createReader('excel2007'); //use excel2007 for 2007 format }else{ $objReader = PHPExcel_IOFactory::createReader('Excel5'); }
在 创建excel读取格式时,例如 $objReader = PHPExcel_IOFactory::createReader('Excel5'); 应先判断文件的扩展名,扩展名不同,文件的存储格式不同,所以读取文件的方法也就会有所不同。
如果只固定的使用一种方式读取,就会容易出现“PHPExcel_Reader_Exception: is not recognised as an OLE file in Classes”错误提示