$file = '';//文件名称

$file_ext = explode('.',$file);
$file_ext = $file_ext[1];
$data['file_ext'] = $file_ext;
require '../application/helpers/PHPExcel.php';

//判断后缀
if($file_ext === 'xls'){
      $objReader = new PHPExcel_Reader_Excel5();
}
if($file_ext === 'xlsx'){
      $objReader = new PHPExcel_Reader_Excel2007();
}
$candfile_name = "./canddata/".$time."/".time()."/cand_picture/cands/".$file;
$data['cand_file'] = $candfile_name;
$objPHPExcel = $objReader->load($candfile_name); //指定的文件
$sheet = $objPHPExcel->getSheet(0);     //指定的表
$highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数
//从第2行开始读起
for( $i=2; $i <= $highestRow; $i++ ){
       //显示各列
       for( $j='A'; $j<='I'; $j++ ){
               if($j=='I'){
                      $arr[$i][$j] = $sheet->getCell($j.$i)->getValue();
               }else{
                      $arr[$i][$j] = replace_special_char($sheet->getCell($j.$i)->getValue());
               }
       }
}
foreach ( $arr as $key => $value ) {
       $cands[$key]['bank_one'] = trim(replace_special_char($value['B']));
       $cands[$key]['bank_two'] = trim(replace_special_char($value['C']));
       $cands[$key]['cand_name'] = trim(replace_special_char($value['D']));
       $cands[$key]['sex'] = trim(replace_special_char($value['E']));
       $cands[$key]['cand_card'] = trim(replace_special_char($value['F']));
       $cands[$key]['cand_iphone'] = trim(replace_special_char($value['G']));
       $cands[$key]['logname'] = trim(replace_special_char($value['H']));
       $cands[$key]['card'] = trim(replace_special_char($value['I']));
       $cands[$key]['creat_time'] = date('Y-m-d H:i:s');
}

PHP读取excel的更多相关文章

  1. java的poi技术读取Excel数据到MySQL

    这篇blog是介绍java中的poi技术读取Excel数据,然后保存到MySQL数据中. 你也可以在 : java的poi技术读取和导入Excel了解到写入Excel的方法信息 使用JXL技术可以在 ...

  2. poi读取excel模板,填充内容并导出,支持导出2007支持公式自动计算

    /** * 版权所有(C) 2016 * @author www.xiongge.club * @date 2016-12-7 上午10:03:29 */ package xlsx; /** * @C ...

  3. C#读取Excel,或者多个excel表,返回dataset

    把excel 表作为一个数据源进行读取 /// <summary> /// 读取Excel单个Sheet /// </summary> /// <param name=& ...

  4. PHP读取EXCEL时间

    在使用php读取excel表格中的时间时得到一串数字而不是时间:40359.58333333334 excel 中的时间值是自1900年以来的天数,注意是格林威治时间php 中的时间值是自1970年以 ...

  5. Open Xml 读取Excel中的图片

      在我的一个项目中,需要分析客户提供的Excel, 读出其中的图片信息(显示在Excel的第几行,第几列,以及图片本身). 网络上有许多使用Open Xml插入图片到Word,Excel的文章, 但 ...

  6. 使用Open xml 操作Excel系列之一-读取Excel

    一. 安装Open Xml SDK 从微软网站下载Open xml SDK,安装SDK. 二. 在项目中添加对DocumentFormat.OpenXml库的引用

  7. 使用NPOI读取Excel报错ICSharpCode.SharpZipLib.Zip.ZipException:Wrong Local header signature

    写了一个小程序利用NPOI来读取Excel,弹出这样的报错: ICSharpCode.SharpZipLib.Zip.ZipException:Wrong Local header signature ...

  8. C#读取Excel设置(亲测可用)

    OpenFileDialog openFD = new OpenFileDialog(); openFD.FileName = ""; openFD.Filter = " ...

  9. 使用Aspose.Cells读取Excel

      最新更新请访问: http://denghejun.github.io Aspose.Cells读取Excel非常方便,以下是一个简单的实现读取和导出Excel的操作类: 以下是Aspose.Ce ...

  10. 使用LinqToExcel读取Excel

    我们读取和写入Excel 经常使用NPOI工具,如果我们的需求只是需要读取Excel,可以考虑使用LinqToExcel这个组件.这个组件用起来简单,实用,操作方便,而且结合了Linq的查询特性,ex ...

随机推荐

  1. WebRequest的get及post提交

    static string get_html(string url) { var request = WebRequest.Create(url); var response = request.Ge ...

  2. notepad ++ 编辑 powershell profile 文件时的诡异问题

    使用notepad 编辑 C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 时,记事本打开和用notepad++打开显示的内容居然不一样. ...

  3. Web API 2 入门——创建ASP.NET Web API的帮助页面(谷歌翻译)

    在这篇文章中 创建API帮助页面 将帮助页面添加到现有项目 添加API文档 在敞篷下 下一步 作者:Mike Wasson 创建Web API时,创建帮助页面通常很有用,以便其他开发人员知道如何调用A ...

  4. 【Leetcode】【Medium】Construct Binary Tree from Inorder and Postorder Traversal

    Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  5. VSTO 开发中 应用ActionPane、CustomTaskPane

    以Excel插件为例: 1. ActionPane 创建 ThisWorkbook 项目 private void ThisWorkbook_Startup(object sender, System ...

  6. 【jQuery】jQuery中的事件捕获与事件冒泡

    在介绍之前,先说一下JavaScript中的事件流概念.事件流描述的是从页面中接受事件的顺序.   一.事件冒泡( Event Bubbling)            IE 的事件流叫做事件冒泡,即 ...

  7. SAP Cloud for Customer Account和individual customer的区别

    在SAP Cloud for Customer的Customers工作中心里,有三个视图:Accounts,Contacts和Individual Customers. 这三种主数据的区别是什么?我们 ...

  8. 深入理解PHP传参原理(PHP5.2)

    首先说下今天想到的一个问题.在编写php扩展的时候,似乎参数(即传给zend_parse_parameters的变量)是不需要free的.举例: PHP_FUNCTION(test) { char* ...

  9. Posix多线程编程学习笔记

    Blaise Barney, Lawrence Livermore National Laboratory )标准制订了这一标准接口.依赖于该标准的实现就称为POSIX threads 或者Pthre ...

  10. 理解Underscore的设计架构

    在一个多月的毕业设计之后,我再次开始了Underscore的源码阅读学习,断断续续也写了好些篇文章了,基本把一些比较重要的或者个人认为有营养的函数都解读了一遍,所以现在学习一下Underscore的整 ...