后端开发|php教程
CodeIgniter,导出,导入
后端开发-php教程在libraies中引用PHPExcel这个类(phpexcel.php)
方维 app源码,vscode电脑同步,ubuntu配,聚合工程tomcat,sqlite3写操作,dede织梦支付插件,进销存前端用什么框架,网络爬虫出不来的原因,php 数组顺序打乱,舟山seo推广咨询,美丽说网站模版,网盘 网页源码,app布局模板 下载lzw
public function excel_put(){ //先做一个文件上传,保存文件 $path=$_FILES[file]; $filePath = "uploads/".$path["name"]; move_uploaded_file($path["tmp_name"],$filePath); //$data=array(B=> ame,C=>pwd,D=>money1,E=>salt); $data=array(B=> ame,C=>pid); $tablename=city2;//表名字 $this->excel_fileput($filePath,$data,$tablename);}
private function excel_fileput($filePath,$data,$tablename){ $this->load->library("phpexcel");//ci框架中引入excel类 $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel(); if(!$PHPReader->canRead($filePath)){ $PHPReader = new PHPExcel_Reader_Excel5(); if(!$PHPReader->canRead($filePath)){echo o Excel;return ; } } // 加载excel文件 $PHPExcel = $PHPReader->load($filePath); // 读取excel文件中的第一个工作表 $currentSheet = $PHPExcel->getSheet(0); // 取得最大的列号 $allColumn = $currentSheet->getHighestColumn(); // 取得一共有多少行 $allRow = $currentSheet->getHighestRow(); // 从第二行开始输出,因为excel表中第一行为列名 for($currentRow = 2;$currentRow <= $allRow;$currentRow++){ /**从第A列开始输出*/ //echo $allColumn; for($currentColumn= A;$currentColumngetCellByColumnAndRow(ord($currentColumn) - 65,$currentRow)->getValue();//print_r($val);//die;if($currentColumn == A){ //echo $val."\t";}else if($currentColumn $val){$data2[$val]=$data1[$key]; } $this->db->insert($tablename,$data2); //print_r($data2); //echo ""; } //echo "\n"; echo "导入成功";}
导出数据:
站长之家工具源码,vscode用什么替代vim,ubuntu+绿色~,tomcat在idea部署,爬虫抓取行为,php 某月最后一天,上街区seo优化报价,网站后台多少钱,bootstrap google风格模板lzw
public function excel_out(){ header("Content-type:text/html"); header("Content-Disposition:attachment;filename=123.xls"); $array=$this->db->get("city")->result_array(); $str="id\t"."name\t"."pid\n"; foreach($array as $val){ $str.=$val[id]."\t".$val[ ame]."\t".$val[pid]."\n"; } echo $str;}
发送邮件php源码下载,ubuntu键盘灯驱动,tomcat端口号映射,起点爬虫被封,php技术导向网站教程,seo 省钱技巧lzw