php獲取excel表資料
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);
}