zoukankan      html  css  js  c++  java
  • 导入excel表格的数据--->到mysql中

    01下载excel类,将Classes文件夹放入ThinkPHPExtendVendor位置

    下载地址 http://phpexcel.codeplex.com/releases/view/26478,

    02

    public function uploadFile(){
    $filetmpname = WEB_PATH.'abc.xls';
    Vendor('Classes.PHPExcel');
    $objPHPExcel = PHPExcel_IOFactory::load($filetmpname);
    $arrExcel = $objPHPExcel->getSheet(0)->toArray();
    echo '<meta http-equiv="Content-type" content="text/html:charset=utf-8">';
    echo '<pre>';
    var_dump($arrExcel);exit;

    //删除不要的表头部分,我的有三行不要的,删除三次
    array_shift($arrExcel);
    array_shift($arrExcel);
    array_shift($arrExcel);//现在可以打印下$arrExcel,就是你想要的数组啦

    
    
    

    echo '<meta http-equiv="Content-type" content="text/html:charset=utf-8">';
    echo '<pre>';
    // var_dump($arrExcel);exit;

    $model = M('account');
    foreach($arrExcel as $k=>$v){

    $add['account_name'] = $v[0];
    $add['account_mobile'] = $v[1];
    $add['account_createtime'] = date('Y-m-d H:i:s',time());
    $model->add($add);
    echo M()->getLastSql();
    echo '<br/>';

  • 相关阅读:
    AddParent
    AddChild
    贝塞尔曲线代码
    顶点纹理shader
    抽象方法与抽象类
    Application类
    布局组件
    C#单例和Unity单例
    Unity&UGUI
    Json解析
  • 原文地址:https://www.cnblogs.com/bj-tony/p/5730367.html
Copyright © 2011-2022 走看看