set_time_limit(0); ini_set(‘memory_limit‘,‘512M‘); ini_set(‘max_execution_time‘,0); $search[‘doctorname‘] = I(‘get.doctorname‘); $search[‘mobile‘] = I(‘get.mobile‘); $search[‘state‘] = I(‘get.state‘); $search[‘type‘] = I(‘get.type‘); $search[‘regclass‘] = I(‘get.regclass‘); $search[‘regstarttime‘] = I(‘get.regstarttime‘); $search[‘regendtime‘] = I(‘get.regendtime‘); $search[‘cstarttime‘] = I(‘get.cstarttime‘); $search[‘cendtime‘] = I(‘get.cendtime‘); $search[‘prov‘] = I(‘get.prov‘); $search[‘city‘] = I(‘get.city‘); $search[‘dist‘] = I(‘get.dist‘); $search[‘patient_order‘] = I(‘get.patient_order‘); $search[‘datacheck‘] = I(‘get.datacheck‘); $search[‘remark‘] = I(‘get.remark‘); $where = ‘‘; if(!empty($search[‘doctorname‘])){ $where[‘doctor.m_doctorname‘] = [‘LIKE‘, ‘%‘ . $search[‘doctorname‘] . ‘%‘]; } if(!empty($search[‘mobile‘])){ $where[‘account.u_mobile‘] = [‘LIKE‘, ‘%‘ . $search[‘mobile‘] . ‘%‘]; } if(isset($search[‘state‘]) && strlen($search[‘state‘]) > 0 && $search[‘state‘] >= 0){ $where[‘account.u_state‘] = $search[‘state‘]; } if(isset($search[‘type‘]) && strlen($search[‘type‘]) > 0){ if($search[‘type‘] == 3){ $where[‘doctor.m_type‘] = 0; $where[‘doctor.m_doctortechnicalimg‘] = [‘NEQ‘, ‘‘]; }elseif($search[‘type‘] >= 0){ $where[‘doctor.m_type‘] = $search[‘type‘]; } } if(!empty($search[‘regclass‘]) && $search[‘regclass‘] >= 0){ $where[‘account.u_reg_class‘] = $search[‘regclass‘]; } if(isset($search[‘datacheck‘]) && strlen($search[‘datacheck‘]) > 0 && $search[‘datacheck‘] >= 0){ $where[‘doctor.m_datacheck‘] = $search[‘datacheck‘]; } if(!empty($search[‘regstarttime‘]) && empty($search[‘regendtime‘])){ $where[‘account.u_reg_datetime‘] = [‘gt‘, $search[‘regstarttime‘] . ‘ 00:00:00‘]; }elseif(empty($search[‘regstarttime‘]) && !empty($search[‘regendtime‘])){ $where[‘account.u_reg_datetime‘] = [‘lt‘, $search[‘regendtime‘] . ‘ 23:59:59‘]; }elseif(!empty($search[‘regstarttime‘]) && !empty($search[‘regendtime‘])){ $where[‘account.u_reg_datetime‘] = [‘BETWEEN‘, [$search[‘regstarttime‘] . ‘ 00:00:00‘, $search[‘regendtime‘] . ‘ 23:59:59‘], ‘and‘]; } if(!empty($search[‘cstarttime‘]) && empty($search[‘cendtime‘])){ $where[‘account.check_datetime‘] = [‘gt‘, $search[‘cstarttime‘] . ‘ 00:00:00‘]; }elseif(empty($search[‘cstarttime‘]) && !empty($search[‘cendtime‘])){ $where[‘account.check_datetime‘] = [‘lt‘, $search[‘cendtime‘] . ‘ 23:59:59‘]; }elseif(!empty($search[‘cstarttime‘]) && !empty($search[‘cendtime‘])){ $where[‘account.check_datetime‘] = [[‘gt‘, $search[‘cstarttime‘] . ‘ 00:00:00‘], [‘lt‘, $search[‘cendtime‘] . ‘ 23:59:59‘], ‘and‘]; } if(!empty($search[‘prov‘])){ $where[‘doctor.m_hdistrict‘] = [‘LIKE‘, ‘%‘ . trim($search[‘prov‘] . ‘ ‘ . $search[‘city‘] . ‘ ‘ . $search[‘dist‘]) . ‘%‘]; } if(!empty($search[‘remark‘]) && $search[‘remark‘] >= 0){ if($search[‘remark‘] == 1){ $where[‘doctor.m_remarks‘] = [‘NEQ‘, ‘‘]; }else{ $where[‘doctor.m_remarks‘] = [‘EQ‘, ‘‘]; } } $doctor = new DoctorModel(‘‘, ‘‘, C(‘MAMI_ADMIN_DB_MYCAT‘)); $data = $doctor->getDoctorList($where,$field="doctor.u_id,doctor.m_doctorname,doctor.m_sex,account.u_mobile,doctor.m_hdistrict,doctor.m_hname,doctor.m_dname,doctor.m_technicalname,doctor.createdatetime,account.check_datetime,doctor.m_remarks,doctor.d_extend,doctor.m_type"); // echo $data;exit; Vendor(‘phpexcel.PHPExcel‘); //新建 $resultPHPExcel = new \PHPExcel(); $datatype = new \PHPExcel_Cell_DataType(); $PHPExcel_Style_Alignment = new \PHPExcel_Style_Alignment(); $PHPExcel_Style_Alignment = new \PHPExcel_Style_Alignment(); $PHPExcel_Style_Border = new \PHPExcel_Style_Border(); $PHPExcel_IOFactory = new \PHPExcel_IOFactory(); $PHPExcel_CachedObjectStorageFactory = new \PHPExcel_CachedObjectStorageFactory(); $PHPExcel_Settings = new \PHPExcel_Settings(); $cacheMethod = $PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip; $cacheSettings = array(); $PHPExcel_Settings::setCacheStorageMethod($cacheMethod,$cacheSettings); //设置参数 //设值 $resultPHPExcel->getActiveSheet()->setCellValue(‘A1‘, ‘编号‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘B1‘, ‘医生姓名‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘C1‘, ‘性别‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘D1‘, ‘手机号‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘E1‘, ‘省市区‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘F1‘, ‘所属医院‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘G1‘, ‘科室‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘H1‘, ‘职称‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘I1‘, ‘创建时间‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘J1‘, ‘审核时间‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘K1‘, ‘维护‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘L1‘, ‘资质‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘M1‘, ‘二维码‘); //垂直/水平居中 $resultPHPExcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $resultPHPExcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $sex = array(‘女‘, ‘男‘); $tarr = array(‘未认证‘,‘认证‘,‘认证未通过‘); $i = 2; foreach ($data as $key =>&$item) { $d = json_decode($item[‘d_extend‘],JSON_UNESCAPED_UNICODE); $img = $d[‘wx_ewm‘]; $d[‘wx_ewm‘] = ‘‘; $item[‘m_type‘] = $tarr[$item[‘m_type‘]]; if(!empty($item[‘remarks‘])){ $item[‘remarks‘] = ‘已维护‘; }else{ $item[‘remarks‘] = ‘未维护‘; } $newim = imagecreate (150, 150); $img = imagecreatefromjpeg($img); $width = imagesx($img); $height = imagesy($img); imagecopyresized($newim,$img,0,0,0,0,150,150,$width,$height); $objDrawing = new \PHPExcel_Worksheet_MemoryDrawing(); $resultPHPExcel->getActiveSheet()->setCellValueExplicit(‘A‘ . $i, $item[‘u_id‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘B‘ . $i, $item[‘m_doctorname‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘C‘ . $i, $sex[$item[‘m_sex‘]]); $resultPHPExcel->getActiveSheet()->setCellValue(‘D‘ . $i, $item[‘u_mobile‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘E‘ . $i, $item[‘m_hdistrict‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘F‘ . $i, $item[‘m_hname‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘G‘ . $i, $item[‘m_dname‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘H‘ . $i, $item[‘m_technicalname‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘I‘ . $i, $item[‘createdatetime‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘J‘ . $i, $item[‘check_datetime‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘K‘ . $i, $item[‘remarks‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘L‘ . $i, $item[‘m_type‘]); $resultPHPExcel->getActiveSheet()->setCellValue(‘M‘ . $i, $d[‘wx_ewm‘]); $resultPHPExcel->getActiveSheet()->getDefaultColumnDimension()->setWidth(20); $objDrawing->setName(‘erweima‘); $objDrawing->setDescription(‘erweima‘); $objDrawing->setCoordinates(‘M‘.$i); $objDrawing->setImageResource($newim); $objDrawing->setOffsetX(10); $objDrawing->setOffsetY(10); $objDrawing->setRenderingFunction(\PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT); $objDrawing->setMimeType(\PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT); $resultPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(130); $objDrawing->setWorksheet($resultPHPExcel->getSheet()); $i++; } //设置表格宽度 $resultPHPExcel->getActiveSheet()->getColumnDimension(‘C‘)->setWidth(25); //垂直/水平居中 $resultPHPExcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setHorizontal($PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $resultPHPExcel->getActiveSheet()->getDefaultStyle()->getAlignment()->setVertical($PHPExcel_Style_Alignment::HORIZONTAL_CENTER); //设置导出文件名 $obj_Writer = $PHPExcel_IOFactory->createWriter($resultPHPExcel, ‘Excel5‘); $filename = "医生数据统计表.xls"; header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header(‘Content-Disposition:inline;filename="‘ . $filename . ‘"‘); header("Content-Transfer-Encoding: binary"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); $obj_Writer->save(‘php://output‘);
里面有如何将网络上的图片修改成指定大小,并导入phpexcel中
时间: 2024-10-31 01:41:14