PHP读取Excel 之 Spreadsheet_Excel_Reader

<?php
      require_once('Excel/Spreadsheet_Excel_Reader');
      @$data = new Spreadsheet_Excel_Reader();
      @$data->setOutputEncoding('UTF-8');
      @$data->read($fileName);
      
      //$i = 2 开始循环 去除第一行
        for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++)
        {
            
            
            $sql = "INSERT INTO goods_temp (
            goods_type,goods_no,goods_name,sys,sys_name,area,area_name,sys_goods_no,market_price,profit_price,
            retail_price,add_time,last_update,add_user,batch_no
            )
            VALUES('0','".
            $data->sheets[0]['cells'][$i][1]."','".
            $data->sheets[0]['cells'][$i][2]."','".
            $result['sys_id']."','".
            $data->sheets[0]['cells'][$i][3]."','".
            $result['ma_id']."','".
            $data->sheets[0]['cells'][$i][4]."','".
            $data->sheets[0]['cells'][$i][5]."','".
            $data->sheets[0]['cells'][$i][6]."','".
            $data->sheets[0]['cells'][$i][7]."','".
            $data->sheets[0]['cells'][$i][8]."','".
            time()."','".
            time()."','".
            $session_array['ac_name']."','".
            $id."')";
            
            $result = $this->db->query($sql);
           
        }


你可能感兴趣的:(Excel)