前言:
现时你们对“ajax上传excel到后台”可能比较注重,看官们都想要学习一些“ajax上传excel到后台”的相关知识。那么小编在网摘上收集了一些有关“ajax上传excel到后台””的相关知识,希望朋友们能喜欢,朋友们一起来了解一下吧!<?php/*** composer 安装 composer require phpoffice/phpexcel*//** * 导入绑定 * @throws \PHPExcel_Exception * @throws \PHPExcel_Reader_Exception * User: Dh106 * Date: 2018/8/9 * Time: 16:14 */public function importBind(){ $name = request()->file('file'); $info = $name->move(ROOT_PATH . 'public' . DS . 'uploads'. DS . 'file'); $file = $info->getPathname(); $objPHPExcel = \PHPExcel_IOFactory::load($file); $objPHPExcel->setActiveSheetIndex(0); $sheet=$objPHPExcel->getSheet(0); $highrow = $sheet->getHighestRow(); for ($i=2;$i<=$highrow;$i++) { $userteamtitle = (string)$sheet->getCellByColumnAndRow(3,$i)->getValue(); if(empty($userteamtitle)) { break; } $cardsn = trim((string)$sheet->getCellByColumnAndRow(1,$i)->getValue(),' '); $cardsnONE = substr($cardsn,0,1); $cardsn = $cardsnONE=='y'?$cardsn:substr($cardsn,2); $username = (string)$sheet->getCellByColumnAndRow(2,$i)->getValue(); $teamid = $this->logicIdentityTeam->getTeamIdByName($userteamtitle); $data = [ 'user_name' => $username, 'user_team' => $teamid, 'bind_time' => time(), 'update_time' => time(), ]; $this->logicIdentityCard->bindCardByImport($cardsn,$data); } $this->ajaxJump([RESULT_SUCCESS,'导入成功',url('identitycard/cardList')]);}
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。
标签: #ajax上传excel到后台