导入xlsx文件

<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++){

       }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值