当前位置:首页 > PHP教程 > php高级应用 > 列表

phpexcel导入xlsx文件报错xlsx is not recognised as an OLE file 怎么办

发布:smiling 来源: PHP粉丝网  添加日期:2018-10-22 17:35:24 浏览: 评论:0 

最初的做法:

  1. include 'classes/PHPExcel/IOFactory.php'
  2.     $inputFileName = $target
  3.      
  4. $objReader = new PHPExcel_Reader_Excel5();  
  5.     $objPHPExcel = $objReader->load($inputFileName); 
  6.  
  7. $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); 
  8.  
  9. $count = count($sheetData); 
  10.  
  11. for($i=1;$i<=$count;$i++) 
  12.  
  13.  
  14.  echo (iconv('utf-8','gbk',$sheetData[$i]['A'])).'<hr />'
  15.  

报错:

PHPExcel_Reader_Exception: The filename .1443578799.xlsx is not recognised as an OLE file in Classes\PHPExcel\Shared\OLERead.php on line 89

( ! ) Fatal error: Uncaught exception 'PHPExcel_Reader_Exception' with message 'The filename 1443578799.xlsx is not recognised as an OLE file' in Classes\PHPExcel\Shared\OLERead.php on line 89

( ! ) PHPExcel_Reader_Exception: The filename 1443578799.xlsx is not recognised as an OLE file in Classes\PHPExcel\Shared\OLERead.php on line 89

Call Stack

碰到这个问题我们是因为xlsx出错了,可能通过类型判断 解决办法如下:

  1. if$extension =='xlsx' ){ 
  2. $objReader = new PHPExcel_Reader_Excel2007(); 
  3. }else
  4.  $objReader = new PHPExcel_Reader_Excel5(); 

这样再操作会发现问题已经解决了。

Tags: 导入xlsx recognised

分享到: