ci excel导入
来源:互联网 发布:svgpath.js 编辑:程序博客网 时间:2024/05/21 17:18
//excel文件上传
$file=$_FILES['file_stu'];
$s_date=date("Y-m-d H:i:s",time());
$tmp_name=$file['tmp_name'];
$name=$file['name'];
$path='public/'.$file['name'];
$this->load->library('PHPExcel/IOFactory');
$objReader = IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load($path);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$excelData = array();
//循环把excel数据存在数组中
for($row = 1; $row <= $highestRow; $row++) {
for ($col = 0; $col < $highestColumnIndex; $col++) {
$excelData[$row][]=(string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
}
foreach($excelData as $key=>$val){
if($key!=1){
$sql = "insert into day17 values(null,'$val[1]','$val[2]','$val[3]')";
$this->db->query($sql);
}
}
$file=$_FILES['file_stu'];
$s_date=date("Y-m-d H:i:s",time());
$tmp_name=$file['tmp_name'];
$name=$file['name'];
$path='public/'.$file['name'];
move_uploaded_file($tmp_name,$path);
$this->load->library('PHPExcel/IOFactory');
$objReader = IOFactory::createReader('Excel5');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($path);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
$excelData = array();
//循环把excel数据存在数组中
for($row = 1; $row <= $highestRow; $row++) {
for ($col = 0; $col < $highestColumnIndex; $col++) {
$excelData[$row][]=(string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
}
}
foreach($excelData as $key=>$val){
if($key!=1){
$sql = "insert into day17 values(null,'$val[1]','$val[2]','$val[3]')";
$this->db->query($sql);
}
}
1 0
- ci excel导入
- CI框架Excel导入导出
- php框架ci中excel导入导出
- CI框架导入数据
- ci excel导出
- EXCEL导入
- 导入EXCEL
- Excel 导入
- Excel导入
- 导入Excel
- 导入Excel
- 导入Excel
- excel导入
- 导入EXCEL
- 导入excel
- 导入excel
- 导入Excel
- 导入excel
- 内网渗透中mimikatz的使用
- c# 精致时钟的代码
- 常用类String
- php中自带的内置函数
- java知识容易混淆的知识点总结
- ci excel导入
- 傅立叶分析导论-3 Convergence of Fourier Series
- Nofollow涵义
- js对象编程学习
- [原根 指标 模方程 BSGS] BZOJ 1420 Discrete Root & BZOJ 1319 Sgu261Discrete Roots
- php数组函数
- CodeForces 687A NP-Hard Problem
- 前缀、中缀、后缀表达式
- shiro-springmvc-mybatis登录认证 权限控制