Sms_customer_list_adminAction.class.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <?php
  2. /**
  3. * 导入客户信息,导出客户信息
  4. */
  5. require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
  6. require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
  7. class Sms_customer_list_adminAction extends Action{
  8. public function __construct(){
  9. parent::__construct();
  10. if(empty($_SESSION['mds_user'])){
  11. header("Location:/?a=index&m=admin_login");
  12. exit();
  13. }
  14. }
  15. //客户列表
  16. public function index(){
  17. require_once (ONU_ROOT . "frame/Page.class.php");
  18. $admin = new AdvertAdminAction();
  19. $uid = $_SESSION['user_infos']['id'];
  20. $info = $_REQUEST['info'];
  21. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  22. $pageSize = isset($_REQUEST['pagesize'])?$_REQUEST['pagesize']:20;
  23. $n = ($page-1)*$pageSize;
  24. $pa = "";//查询参数
  25. $pa='&pagesize='.$pageSize;
  26. $limit = " $n,$pageSize";
  27. $where = " where uid='$uid' ";
  28. $group_list = $admin->select_sms_user_group($where);
  29. $tel = trim($_REQUEST['tel']);
  30. $group_name = $_REQUEST['group_name'];
  31. if(!empty($tel)) {
  32. $where.=" and tel='$tel'";
  33. }
  34. if(!empty($group_name)){
  35. $where.=" and group_name='$group_name'";
  36. $pa .= "&group_name=$group_name";
  37. }
  38. $where.=" and is_block=0";
  39. $customer_list = $admin->selesctSmsCustomer($where,$limit);
  40. $all_total = $admin->selectSmsCustomerCount($where);
  41. $p = new Page($all_total,$pageSize,$pa);
  42. $pp = $p->fpage();
  43. $this->assign('tel',$tel);
  44. $this->assign('list',$customer_list);
  45. $this->assign('group_list',$group_list);
  46. $this->assign('group_name',$group_name);
  47. $this->assign('info',$info);
  48. $this->assign('page',$page);
  49. $this->assign('pagesize',$pageSize);
  50. $this->assign("show",$pp);
  51. $this->display("index.html");
  52. }
  53. public function blackList(){
  54. require_once (ONU_ROOT . "frame/Page.class.php");
  55. $admin = new AdvertAdminAction();
  56. $info = $_REQUEST['info'];
  57. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  58. $pageSize = isset($_REQUEST['pagesize'])?$_REQUEST['pagesize']:20;
  59. $n = ($page-1)*$pageSize;
  60. $pa = "";//查询参数
  61. $pa='&pagesize='.$pageSize;
  62. $limit = " $n,$pageSize";
  63. $where = " where 1=1 ";
  64. $tel = trim($_REQUEST['tel']);
  65. if(!empty($tel)) {
  66. $where.=" and tel='$tel'";
  67. }
  68. $where.=" and is_block=1";
  69. $customer_list = $admin->selesctSmsCustomer($where,$limit);
  70. $all_total = $admin->selectSmsCustomerCount($where);
  71. $p = new Page($all_total,$pageSize,$pa);
  72. $pp = $p->fpage();
  73. $this->assign('tel',$tel);
  74. $this->assign('list',$customer_list);
  75. $this->assign('info',$info);
  76. $this->assign('page',$page);
  77. $this->assign('pagesize',$pageSize);
  78. $this->assign("show",$pp);
  79. $this->display("blacklist.html");
  80. }
  81. public function nosendList(){
  82. require_once (ONU_ROOT . "frame/Page.class.php");
  83. $admin = new AdvertAdminAction();
  84. $info = $_REQUEST['info'];
  85. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  86. $pageSize = isset($_REQUEST['pagesize'])?$_REQUEST['pagesize']:20;
  87. $n = ($page-1)*$pageSize;
  88. $pa = "";//查询参数
  89. $pa='&pagesize='.$pageSize;
  90. $limit = " $n,$pageSize";
  91. $where = " where 1=1 ";
  92. $tel = trim($_REQUEST['tel']);
  93. if(!empty($tel)) {
  94. $where.=" and tel='$tel'";
  95. }
  96. $where.=" and is_send=2";
  97. $customer_list = $admin->selesctSmsCustomer($where,$limit);
  98. $all_total = $admin->selectSmsCustomerCount($where);
  99. $p = new Page($all_total,$pageSize,$pa);
  100. $pp = $p->fpage();
  101. $this->assign('tel',$tel);
  102. $this->assign('list',$customer_list);
  103. $this->assign('info',$info);
  104. $this->assign('page',$page);
  105. $this->assign('pagesize',$pageSize);
  106. $this->assign("show",$pp);
  107. $this->display("nosendList.html");
  108. }
  109. public function remove(){
  110. $admin = new AdvertAdminAction();
  111. $uid = $_SESSION['user_infos']['id'];
  112. $info = $_REQUEST['info'];
  113. $where = " where uid='$uid' ";
  114. $group_list = $admin->select_sms_user_group($where);
  115. $this->assign('group_list',$group_list);
  116. $this->assign('info',$info);
  117. $this->display("remove.html");
  118. }
  119. //添加客户
  120. public function add(){
  121. $admin = new AdvertAdminAction();
  122. $uid = $_SESSION['user_infos']['id'];
  123. $where = "where uid='$uid' ";
  124. $group_list = $admin->select_sms_user_group($where);
  125. if($_POST['tel']){
  126. $data['uname'] = $_POST['username'];
  127. $data['tel'] = $_POST['tel'];
  128. $data['group_name'] = $_POST['group_name'];
  129. $data['country'] = $_POST['country'];
  130. $data['uid'] = $uid;
  131. $is_exist = $admin->selectCustomerByTel($data['tel'], $data['uid']);
  132. if(empty($is_exist)){
  133. $add = $admin->add_sms_customer($data);
  134. if($add){
  135. $info = "添加手机号成功";
  136. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  137. exit();
  138. }else{
  139. $info = "添加手机号失败";
  140. $this->assign('info',$info);
  141. }
  142. }else{
  143. $info = "您之前已经添加过此用户";
  144. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  145. exit();
  146. }
  147. }
  148. $this->assign('group_list',$group_list);
  149. $this->display('add.html');
  150. }
  151. //添加黑名单
  152. public function addBlack(){
  153. $admin = new AdvertAdminAction();
  154. if($_POST['tel']){
  155. $info = '添加失败';
  156. $uname = $_POST['username'];
  157. $tel = $_POST['tel'];
  158. $country = $_POST['country'];
  159. $group_name ='黑名单';
  160. $user = $admin->selectOneCustomerBymobile($tel);//查询手机号是否存在
  161. if($user){
  162. $add =$admin->updateSmsCustomerBlcak($user);
  163. }else{
  164. $uid =99;
  165. $values = "('{$uname}', '{$country}', '{$tel}', {$uid}, '{$group_name}', 1, 2)";
  166. $add =$admin->import_sms_customer($values);
  167. }
  168. if($add){
  169. $info = "添加成功";
  170. header("Location:/?a=sms_customer_list_admin&m=blacklist&info=$info");
  171. exit();
  172. }else{
  173. $this->assign('info',$info);
  174. }
  175. }
  176. $this->display('addBlack.html');
  177. }
  178. //编辑客户
  179. public function edit(){
  180. $admin = new AdvertAdminAction();
  181. $uid = $_SESSION['user_infos']['id'];
  182. $where = "where uid='$uid' ";
  183. $group_list = $admin->select_sms_user_group($where);
  184. $id = $_REQUEST['id'];
  185. $one_info = $admin->selectOneSmsCustomer($id);
  186. if($_POST['tel']){
  187. $id = $_POST['id'];
  188. $data['uname'] = $_POST['username'];
  189. $data['group_name'] = $_POST['group_name'];
  190. $data['country'] = $_POST['country'];
  191. $data['tel'] = $_POST['tel'];
  192. $update = $admin->updateSmsCustomer($data,$id);
  193. if($update){
  194. $info = "编辑客户资料成功";
  195. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  196. exit();
  197. }else{
  198. $info = "编辑客户资料失败";
  199. $this->assign('info',$info);
  200. }
  201. }
  202. $this->assign('id',$id);
  203. $this->assign('one_info',$one_info);
  204. $this->assign('group_list',$group_list);
  205. $this->display('edit.html');
  206. }
  207. //删除客户
  208. public function delete(){
  209. $admin = new AdvertAdminAction();
  210. $uid = $_SESSION['user_infos']['id'];
  211. $id = $_REQUEST['id'];
  212. if($_REQUEST['id']){
  213. $delete = $admin->deleteSmsCustomer($id,$uid);
  214. $info = "删除成功";
  215. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  216. exit();
  217. }
  218. }
  219. //批量删除客户
  220. public function batch_delete(){
  221. $admin = new AdvertAdminAction();
  222. $uid = $_SESSION['user_infos']['id'];
  223. $id_array = $_POST['id_array'];
  224. $count = count($id_array);
  225. if($count==1){
  226. $id = $id_array[0];
  227. $delete = $admin->deleteSmsCustomer($id,$uid);
  228. $info = "删除成功";
  229. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  230. exit();
  231. }else if($count>1){
  232. $in_array = implode(',',$id_array);
  233. $delete = $admin->deleteBatchSmsCustomer($in_array,$uid);
  234. $info = "删除成功";
  235. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  236. exit();
  237. }
  238. }
  239. public function import(){
  240. $admin = new AdvertAdminAction();
  241. $city_code =$admin->selectCityCode();
  242. $new=array();
  243. foreach ($city_code as $v){
  244. $new[]=$v['code'];
  245. }
  246. $is_send=1;
  247. $uid = $_SESSION['user_infos']['id'];
  248. if($_POST['to_import_user']=='yes'){
  249. $filename = $_FILES['inputExcel']['name'];
  250. $tmp_name = $_FILES['inputExcel']['tmp_name'];
  251. $excel_array = $this->uploadFile($filename,$tmp_name);
  252. if(!empty($excel_array['error'])){
  253. $info = $excel_array['error'];
  254. }else{
  255. unset($excel_array[0]);//若第一排的数据是字段名的话,删除
  256. header("Content-type: text/html; charset=utf-8");
  257. $blackList = $admin->selectSmsBlackList();
  258. $blackListArr = array_column($blackList, 'tel');
  259. $values = '';
  260. foreach($excel_array as $array){
  261. if(!empty($array[2])){
  262. $uname = str_replace("'", '', $array[0]);
  263. $tel = trim($array[1]);
  264. $country = trim($array[2]);
  265. $groupName = trim($array[3]);
  266. if(in_array($tel, $blackListArr)) {
  267. continue;
  268. }
  269. if($country=='United States'||$country=='Canada'){
  270. $code = substr($tel , 0 , 3);
  271. if (in_array($code, $new)) {
  272. $is_send=1;
  273. }else{
  274. $is_send=2;
  275. }
  276. }
  277. $values .= "('{$uname}', '{$country}', '{$tel}', {$uid}, '{$groupName}', 0, '{$is_send}'),";
  278. }
  279. }
  280. if($values) {
  281. $values = trim($values, ",");
  282. $insert = $admin->import_sms_customer($values);
  283. var_dump($insert); exit;
  284. $info = '导入数据成功';
  285. }
  286. }
  287. header("Location:/?a=sms_customer_list_admin&m=index&info=$info");
  288. exit();
  289. }
  290. }
  291. public function importBlackList(){
  292. $admin = new AdvertAdminAction();
  293. $uid = $_SESSION['user_infos']['id'];
  294. if($_POST['to_import_user']=='yes'){
  295. $filename = $_FILES['inputExcel']['name'];
  296. $tmp_name = $_FILES['inputExcel']['tmp_name'];
  297. $excel_array = $this->uploadFile($filename,$tmp_name);
  298. if(!empty($excel_array['error'])){
  299. $info = $excel_array['error'];
  300. }else{
  301. unset($excel_array[0]);//若第一排的数据是字段名的话,删除
  302. header("Content-type: text/html; charset=utf-8");
  303. $blackList = $admin->selectSmsBlackList($uid);
  304. $blackListArr = array_column($blackList, 'tel');
  305. $values = '';
  306. foreach($excel_array as $array){
  307. if(!empty($array[1])){
  308. $uname = str_replace("'", '', $array[0]);
  309. $tel = trim($array[1]);
  310. $country = trim($array[2]);
  311. $groupName = trim($array[3]);
  312. if(in_array($tel, $blackListArr)) {
  313. continue;
  314. }
  315. $telsArr[] = $tel;
  316. $values .= "('{$uname}', '{$country}', '{$tel}', 99, '{$groupName}', 1, 2),";
  317. }
  318. }
  319. if($telsArr) {
  320. $telsStr = implode(',', $telsArr);
  321. $result = $admin->deleteSmsCustomerByTel($telsStr);
  322. $values = trim($values, ",");
  323. $insert = $admin->import_sms_customer($values);
  324. $info = '导入数据成功';
  325. }
  326. }
  327. header("Location:/?a=sms_customer_list_admin&m=blacklist&info=$info");
  328. exit();
  329. }
  330. }
  331. public function deleteByExcel(){
  332. $admin = new AdvertAdminAction();
  333. $uid = $_SESSION['user_infos']['id'];
  334. if($_POST['to_import_user']=='yes'){
  335. $filename = $_FILES['inputExcel']['name'];
  336. $tmp_name = $_FILES['inputExcel']['tmp_name'];
  337. $excel_array = $this->uploadFile($filename,$tmp_name);
  338. if(!empty($excel_array['error'])){
  339. $info = $excel_array['error'];
  340. }else{
  341. unset($excel_array[0]);//若第一排的数据是字段名的话,删除
  342. header("Content-type: text/html; charset=utf-8");
  343. $telsArr = array();
  344. foreach($excel_array as $array){
  345. if(!empty($array[2])){
  346. $uname = str_replace("'", '', $array[0]);
  347. $tel = trim($array[1]);
  348. $country = trim($array[2]);
  349. $groupName = trim($array[3]);
  350. $telsArr[] = $tel;
  351. }
  352. }
  353. if($telsArr) {
  354. $telsStr = implode(',', $telsArr);
  355. $result = $admin->deleteSmsCustomerByExcel($telsStr, $uid);
  356. $info = '删除数据成功';
  357. }
  358. }
  359. header("Location:/?a=sms_customer_list_admin&m=remove&info=$info");
  360. exit();
  361. }
  362. }
  363. public function deleteByGroup() {
  364. $admin = new AdvertAdminAction();
  365. $uid = $_SESSION['user_infos']['id'];
  366. $groupName = $_POST['group_name'];
  367. if($groupName) {
  368. $delete_c = $admin->deleteSmsCustomerByGroup($groupName, $uid);
  369. $info = '删除 ' . $groupName . ' 客户分组成功';
  370. } else {
  371. $error = "删除失败";
  372. }
  373. header("Location:/?a=sms_customer_list_admin&m=remove&info=$info&error=$error");
  374. exit();
  375. }
  376. public function export(){
  377. $admin = new AdvertAdminAction();
  378. $uid = $_SESSION['user_infos']['id'];
  379. $group_name = $_REQUEST['group_name'];
  380. $where = " where uid='$uid' ";
  381. if(!empty($group_name)){
  382. $where.=" and group_name='$group_name'";
  383. }
  384. $where.=" and is_block=0";
  385. $list = $admin->selesctSmsCustomer($where);
  386. $d = date('Y-m-d',time());
  387. $this->generateEXCEL($d."导出客户数据",$list);
  388. }
  389. function generateEXCEL($filename = 'report',$data = ''){
  390. //引入PHPExcel相关文件
  391. require_once( ONU_ROOT . 'phpexcel/PHPExcel.php');
  392. require_once( ONU_ROOT . 'phpexcel/PHPExcel/IOFactory.php');
  393. require_once( ONU_ROOT . 'phpexcel/PHPExcel/Writer/Excel5.php');
  394. //新建
  395. $resultPHPExcel = new PHPExcel();
  396. //设置参数
  397. //设值
  398. $resultPHPExcel->getActiveSheet()->setCellValue('A1', 'Name');
  399. $resultPHPExcel->getActiveSheet()->setCellValue('B1', 'Tel');
  400. $resultPHPExcel->getActiveSheet()->setCellValue('C1', 'Country');
  401. $resultPHPExcel->getActiveSheet()->setCellValue('D1', 'Group');
  402. //设置水平居中
  403. $resultPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  404. $resultPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  405. $resultPHPExcel->getActiveSheet()->getStyle('C1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  406. $resultPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  407. //设置水平居中
  408. $resultPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  409. $resultPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  410. $resultPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  411. $resultPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  412. $i = 2;
  413. foreach($data as $item){
  414. $resultPHPExcel->getActiveSheet()->setCellValue('A' . $i, $item['uname']);
  415. $resultPHPExcel->getActiveSheet()->setCellValue('B' . $i, $item['tel']);
  416. $resultPHPExcel->getActiveSheet()->setCellValue('C' . $i, $item['country']);
  417. $resultPHPExcel->getActiveSheet()->setCellValue('D' . $i, $item['group_name']);
  418. //设置单元格宽度
  419. $resultPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(40);
  420. $resultPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
  421. $resultPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
  422. $resultPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
  423. //设置水平居中
  424. $resultPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  425. $resultPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  426. $resultPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  427. $resultPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  428. //设置行高度
  429. $resultPHPExcel->getActiveSheet()->getRowDimension("1")->setRowHeight(20);
  430. $resultPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(20);
  431. $i ++;
  432. }
  433. //设置导出文件名
  434. $xlsWriter = new PHPExcel_Writer_Excel5($resultPHPExcel);
  435. ob_end_clean();//清除缓冲区,避免乱码
  436. //ob_start(); ob_flush();
  437. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  438. header("Content-Type: application/force-download");
  439. header("Content-Type: application/octet-stream");
  440. header("Content-Type: application/download");
  441. //header('Content-Disposition:inline;filename="'.$outputFileName.'"');
  442. header('Content-Disposition:attachment;filename='.'"'.$filename.'.xls"'); //可以对文件名进行处理
  443. header("Content-Transfer-Encoding: binary");
  444. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  445. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  446. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  447. header("Pragma: no-cache");
  448. $xlsWriter->save('php://output');
  449. exit;
  450. }
  451. //导入Excel文件
  452. function uploadFile($file,$filetempname)
  453. {
  454. //自己设置的上传文件存放路径
  455. $filePath = 'static/upload/';
  456. $str = "";
  457. //下面的路径按照你PHPExcel的路径来修改
  458. require_once ONU_ROOT . 'phpexcel/PHPExcel.php';
  459. require_once ONU_ROOT . 'phpexcel/PHPExcel/IOFactory.php';
  460. require_once ONU_ROOT . 'phpexcel/PHPExcel/Reader/Excel5.php';
  461. require_once ONU_ROOT . 'phpexcel/PHPExcel/Reader/Excel2007.php';
  462. //require_once ONU_ROOT . 'phpexcel/PHPExcel/Reader/CSV.php';
  463. //注意设置时区
  464. $time=date("y-m-d-H-i-s");//去当前上传的时间
  465. //获取上传文件的扩展名
  466. $extend=strrchr ($file,'.');
  467. //上传后的文件名
  468. $name=$time.$extend;
  469. $uploadfile=$filePath.$name;//上传后的文件名地址
  470. //move_uploaded_file() 函数将上传的文件移动到新位置。若成功,则返回 true,否则返回 false。
  471. $result=move_uploaded_file($filetempname,$uploadfile);//假如上传到当前目录下
  472. //echo $result;
  473. if($result) { //如果上传文件成功,就执行导入excel操作
  474. $objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
  475. $objPHPExcel = $objReader->load($uploadfile);
  476. $sheet = $objPHPExcel->getSheet(0);
  477. $highestRow = $sheet->getHighestRow(); //取得总行数
  478. $highestColumn = $sheet->getHighestColumn(); //取得总列数
  479. /* 第二种方法*/
  480. $objWorksheet = $objPHPExcel->getActiveSheet();
  481. $highestRow = $objWorksheet->getHighestRow();
  482. echo 'highestRow='.$highestRow;
  483. echo "<br>";
  484. $highestColumn = $objWorksheet->getHighestColumn();
  485. $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);//总列数
  486. echo 'highestColumnIndex='.$highestColumnIndex;
  487. echo "<br>";
  488. $headtitle=array();
  489. //获取到的excel数据
  490. $excel_array = array();
  491. for ($row = 1;$row <= $highestRow;$row++)
  492. {
  493. $strs=array();
  494. //注意highestColumnIndex的列数索引从0开始
  495. for ($col = 0;$col < $highestColumnIndex;$col++)
  496. {
  497. $strs[$col] =$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
  498. if($strs[$col] instanceof PHPExcel_RichText){ //富文本转换字符串
  499. $strs[$col] = $strs[$col]->__toString();
  500. }
  501. }
  502. array_push($excel_array, $strs);
  503. }
  504. } else {
  505. $excel_array['error'] = "导入失败!";
  506. }
  507. return $excel_array;
  508. }
  509. }