首页 > 开发 > PHP > 正文

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

2024-05-04 21:50:29
字体:
来源:转载
供稿:网友

最初的做法:

  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(); 

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表