教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 phpexcel导入xlsx文件报错xlsx is not recognised as an OLE file 怎么办

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

发布时间:2017-12-12   编辑:jiaochengji.com
教程集为您提供phpexcel导入xlsx文件报错xlsx is not recognised as an OLE file 怎么办等资源,欢迎您收藏本站,我们将为您提供最新的phpexcel导入xlsx文件报错xlsx is not recognised as an OLE file 怎么办资源
phpexcel是一款php读写excel的插件了,小编有一个这样的功能要来实现,但是在导入xlsx时发现xlsx is not recognised as an OLE file 了,但是导入xls是没有问题了,碰到这种问题我们来看小编的解决办法。

最初的做法

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy7931')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy7931>

include 'classes/PHPExcel/IOFactory.php';

$inputFileName = $target;


$objReader = new PHPExcel_Reader_Excel5(); 

$objPHPExcel = $objReader->load($inputFileName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$count = count($sheetData);
for($i=1;$i<=$count;$i )
{
 echo (iconv('utf-8','gbk',$sheetData[$i]['A'])).'<hr />';
}

</td></tr></table>

报错

 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出错了,可能通过类型判断 解决办法如下

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2974')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2974>

if( $extension =='xlsx' )
{
 $objReader = new PHPExcel_Reader_Excel2007();
}
else
{
 $objReader = new PHPExcel_Reader_Excel5();
}

</td></tr></table>

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

您可能感兴趣的文章:
phpexcel导入xlsx文件报错xlsx is not recognised as an OLE file 怎么办
PHP导出EXCEL的简单范例 使用phpexcel类库导出excel
phpexcel导入excel到数据库的代码
php语言怎么做表格
phpExcel导出excel加超级链接的实例代码
TP5(layui)excel导入
【PHP】利用phpspreadsheet将数据输出到Excel文件
TP5.0 PHPExcel 数据表格导出导入
phpExcel类的使用方法分享
phpexcel导出数据的实例代码

[关闭]
~ ~