zoukankan      html  css  js  c++  java
  • php操作EXCLE(通过phpExcle实现读excel数据)

    <?php
    require_once('/PHPExcel/Reader/Excel2007.php');
    $objReader = new PHPExcel_Reader_Excel2007;
    $PHPExcel = $objReader->load('testExcel.xls');

    /**
     * 读取excel文件中的第一个工作表
     */
    $currentSheet = $PHPExcel->getSheet(0);
    /**
     * 取得最大的列号
     */
    $allColumn = $currentSheet->getHighestColumn();
    /**
     * 取得总行数
     */
    $allRow = $currentSheet->getHighestRow();

    /**
     * 从第2行开始输出
     */
    for($currentRow = 1; $currentRow<=$allRow;$currentRow++){
        //从第A列开始输出
        for($currentColumn="A";$currentColumn<=$allColumn;$currentColumn++){
            $val = $currentSheet->getCellByColumnAndRow(ord($currentColumn)-65,$currentRow)->getValue();
            if($currentColumn == 'A'){
                echo $val;
                //echo GetDate($val)." ";
            }else{
                //echo $val;
                //如果输出汉字有乱码,则需要将输出内容用iconv函数进行编码转换,如下将gb2312编码转换为utf8
                echo iconv('utf-8','gb2312',$val);
            }
            echo "   ";
        }
        echo "<br>";
    }

  • 相关阅读:
    spring mvc 建立下拉框并进行验证demo
    spring mvc 使用jsr-303进行表单验证的方法介绍
    复习
    练习
    复习
    计算机网络
    liunx 和网络
    按钮
    几天不见 就记得这个架子了。。。。
    只能输入汉字登录页面
  • 原文地址:https://www.cnblogs.com/tangchuanyang/p/3899261.html
Copyright © 2011-2022 走看看