您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP 如何利用phpexcel导入数据库_PHP教程

2024/3/22 18:53:08发布25次查看
废话不多说,直接上代码吧
复制代码 代码如下:
load($inputfilename);
        /*
        $sheet = $objphpexcel->getsheet(0);
        $highestrow = $sheet->gethighestrow(); //取得总行数
        $highestcolumn = $sheet->gethighestcolumn(); //取得总列
        */   
        $objworksheet = $objphpexcel->getactivesheet();//取得总行数
        $highestrow = $objworksheet->gethighestrow();//取得总列数
echo 'highestrow='.$highestrow;
        echo
;
        $highestcolumn = $objworksheet->gethighestcolumn();
        $highestcolumnindex = phpexcel_cell::columnindexfromstring($highestcolumn);//总列数
        echo 'highestcolumnindex='.$highestcolumnindex;
        echo
;
        $headtitle=array();
        for ($row = 1;$row         {
            $strs=array();
            //注意highestcolumnindex的列数索引从0开始
            for ($col = 0;$col             { 
                $strs[$col] =$objworksheet->getcellbycolumnandrow($col, $row)->getvalue();
            } 
              $info = array(
                      'word1'=>$strs[0],
                    'word2'=>$strs[1],
                    'word3'=>$strs[2],
                    'word4'=>$strs[3],
              );
              //在这儿,你可以连接,你的数据库,写入数据库了
              print_r($info);
              echo '
';
        }
?>
http://www.bkjia.com/phpjc/328157.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/328157.htmltecharticle废话不多说,直接上代码吧 复制代码 代码如下: ?php error_reporting(e_all); //开启错误 set_time_limit(0); //脚本不超时 date_default_timezone_set('europe/lo...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product