<form id="uploadform" enctype="multipart/form-data" method="post" action="__URL__/importExcel">
<input id="bnn" value="选择文件" type="button" class="btn"/>
<input id="excel_upload" name="import" type="file" style="position:absolute;width:140px; height:32px;bottom:25px; left:65px;opacity:0;cursor:pointer;">
</form>
//导入数据
public function importExcel()
{
$aFileInfo=uploadfile("import",'import/goods',5242880,array('xls','xlsx'));
if($aFileInfo["status"]==1)
{
$this->importData($aFileInfo['file_path']);
echo $this->ajaxReturn(array("res"=>1,"info"=>"导入成功"),"json");
}
else{
echo $this->ajaxReturn($aFileInfo,"json");
}
}
/**
* 导入功能
* @param 文件名
*/
public function importData($filename){
import("Org.Util.PHPExcel");
import("Org.Util.PHPExcel.Reader.Excel2007");
$PHPReader=new \PHPExcel_Reader_Excel2007();
if(!$PHPReader->canRead($filename)){
$PHPReader = new \PHPExcel_Reader_Excel5();
$PHPReader->canRead($filename);
//if(!$PHPReader->canRead($filePath)){
//echo 'no Excel';
//return ;
//}
}
$PHPExcel=$PHPReader->load($filename);
$currentSheet=$PHPExcel->getSheet(0);
$allColumn=$currentSheet->getHighestColumn();
$allRow=$currentSheet->getHighestRow();
for($currentRow=2;$currentRow<=$allRow;$currentRow++){
}
}