Home >Backend Development >PHP Tutorial >php gets excel table data
The content of this article is about php to obtain excel table data. It has a certain reference value. Now I share it with everyone. Friends in need can refer to it
/* 商户池导入*/ public function sellerpoolimport(){ import('Component/PHPExcel',APP_PATH,'.php'); // 引入Excel处理类 $PHPReader = new \PHPExcel_Reader_Excel2007(); $filePath = $_FILES['url']['tmp_name']; //获取上传文件临时目录 //判断文件类型 if (!$PHPReader->canRead($filePath)) { $PHPReader = new \PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($filePath)) { $this->error('请选择Excel文件',U('Seller/sellerpoolindex'),3); } } $PHPExcel = $PHPReader->load($_FILES['url']['tmp_name']); /**读取excel文件中的第一个工作表*/ //并且转成数组 $currentSheetArr = $PHPExcel->getSheet(0)->toArray(); $res = D('Seller')->sellerpoolimport(I('post.channeltype'),I('post.companycode'),$currentSheetArr); if(!is_array($res)) $this->error($res,U('Seller/sellerpoolindex'),6); $this->success('导入成功',U('Seller/sellerpoolindex'),3); }
Related recommendations:
The above is the detailed content of php gets excel table data. For more information, please follow other related articles on the PHP Chinese website!