thinkphp 3.2 xlsxアップロードファイル、ファイルデータ読み出し

1440 ワード

    public function uploads(){
        if(IS_POST){
            $postData = I('post.');
            $upload = new \Think\Upload();//       
            $upload->maxSize   =     3145728 ;//         
//            $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');//         
            $upload->rootPath  =     './Uploads/'; //          
            $upload->savePath  =     ''; //       ( )  
            //     
            $info   =   $upload->upload();
            if(!$info) {//           
                $this->error($upload->getError());
            }
            $filename  = "Uploads/".$info['photo']["savepath"].$info['photo']["savename"];


            vendor('PHPExcel.PHPExcel');
            if( strstr($filename,'.xlsx'))
            {
                $PHPReader = new \PHPExcel_Reader_Excel2007();
            }
            else
            {
                $PHPReader = new \PHPExcel_Reader_Excel5();
            }
            //  excel  
            $PHPExcel = $PHPReader->load($filename);


            $sheet = $PHPExcel->getActiveSheet(0);//  sheet
            $highestRow = $sheet->getHighestRow(); //        
            $data=$sheet->toArray(); //         
            $array= array();
            unset($data[0]);//   
        }
    }