當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Spreadsheet_Excel_Reader類代碼示例

本文整理匯總了PHP中Spreadsheet_Excel_Reader的典型用法代碼示例。如果您正苦於以下問題:PHP Spreadsheet_Excel_Reader類的具體用法?PHP Spreadsheet_Excel_Reader怎麽用?PHP Spreadsheet_Excel_Reader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Spreadsheet_Excel_Reader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: main

 public function main($UrlAppend = NULL, $get = NULL, $post = NULL)
 {
     if ($this->_isPost()) {
         $data = new Spreadsheet_Excel_Reader();
         $data->setOutputEncoding('utf-8');
         $file = $this->_upload();
         $data->read($file["path"]);
         $keyArr = array();
         for ($a = 1; $a < 1000; $a++) {
             if ($data->sheets[0]['cells'][1][$a] != "") {
                 array_push($keyArr, $data->sheets[0]['cells'][1][$a]);
             }
         }
         $dataList = array();
         for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
             $valueArr = array();
             for ($b = 0; $b < count($keyArr); $b++) {
                 if ($keyArr[$b] == "key") {
                     $key = $data->sheets[0]['cells'][$i][$b + 1];
                 } else {
                     $valueArr[$keyArr[$b]] = $data->sheets[0]['cells'][$i][$b + 1];
                 }
             }
             $dataList[$key] = $valueArr;
         }
         $this->_f($_POST["FileName"], $dataList);
     }
     return $this->_assign;
 }
開發者ID:huangwei2wei,項目名稱:kfxt,代碼行數:29,代碼來源:Default.class.php

示例2: excelreader

 public function excelreader()
 {
     $this->load->library('Spreadsheet_Excel_Reader.php');
     $data = new Spreadsheet_Excel_Reader("./data/example01.xls");
     //	$data = json_decode('{$data}',true);
     echo $data->dump(true, true);
 }
開發者ID:biao0102,項目名稱:local_gwadmin,代碼行數:7,代碼來源:mylib.php

示例3: getAll

 function getAll()
 {
     $reader = new Spreadsheet_Excel_Reader();
     $reader->setUTFEncoder('iconv');
     $reader->setOutputEncoding('UTF-8');
     $reader->read($this->filename);
     $data = array();
     $index_row = 1;
     if ($this->have_header) {
         $index_row = 2;
     }
     $iterator = -1;
     for ($i = $index_row; $i <= $reader->sheets[$this->sheet_index]['numRows']; $i++) {
         $iterator++;
         $data[$iterator] = array();
         for ($j = 1; $j <= $reader->sheets[$this->sheet_index]['numCols']; $j++) {
             if ($this->have_header) {
                 $data[$iterator][$this->headers[$j - 1]] = $reader->sheets[0]['cells'][$i][$j];
             } else {
                 $data[$iterator][$j - 1] = $reader->sheets[0]['cells'][$i][$j];
             }
         }
     }
     return $data;
 }
開發者ID:radityopw,項目名稱:zazzle-php,代碼行數:25,代碼來源:excel_reader.class.php

示例4: fileToArray

 /**
   Helper for xls files. See fileToArray()
 */
 public static function xlsToArray($filename, $limit)
 {
     if (!class_exists('Spreadsheet_Excel_Reader')) {
         include_once dirname(__FILE__) . '/../../src/Excel/xls_read/reader.php';
     }
     $data = new \Spreadsheet_Excel_Reader();
     $data->setOutputEncoding('ISO-8859-1');
     $data->read($filename);
     $sheet = $data->sheets[0];
     $rows = $sheet['numRows'];
     $cols = $sheet['numCols'];
     $ret = array();
     for ($i = 1; $i <= $rows; $i++) {
         $line = array();
         for ($j = 1; $j <= $cols; $j++) {
             if (isset($sheet['cells'][$i]) && isset($sheet['cells'][$i][$j])) {
                 $line[] = $sheet['cells'][$i][$j];
             } else {
                 $line[] = '';
             }
         }
         $ret[] = $line;
         if ($limit != 0 && count($ret) >= $limit) {
             break;
         }
     }
     return $ret;
 }
開發者ID:phpsmith,項目名稱:IS4C,代碼行數:31,代碼來源:FileData.php

示例5: import

 public function import($file)
 {
     try {
         $users = array();
         $params = array(1 => 'user_name', 'user_password', 'user_first_name', 'user_last_name', 'user_email', 'user_group', 'user_vhost');
         $excel = new Spreadsheet_Excel_Reader($file);
         $rows = $excel->rowcount($sheet_index = 0);
         $cols = $excel->colcount($sheet_index = 0);
         for ($row = 2; $row <= $rows; $row++) {
             if ($cols == 7) {
                 for ($col = 1; $col <= $cols; $col++) {
                     $users[$row][$params[$col]] = $excel->val($row, $col);
                     $users[$row]['user_vhost'] = explode(',', $excel->val($row, 7));
                     $users[$row]['user_group'] = '';
                 }
             }
         }
         $this->userimport = new userimport();
         $users = $this->userimport->import($users);
         $_SESSION['message'] = $this->userimport->get_message();
         return $users;
     } catch (Exception $e) {
         display_page_error();
     }
 }
開發者ID:jabouzi,項目名稱:projet,代碼行數:25,代碼來源:xlsimportadapter.php

示例6: import

 /**
  * Importa la nomina de estudiantes desde una hoja excel
  */
 public function import($archivo)
 {
     include_once 'system/application/libraries/excel_reader2.php';
     $excel = new Spreadsheet_Excel_Reader("system/excel/alumnos/{$archivo}");
     $i = 2;
     $this->db->trans_start();
     while (intval($excel->val($i, 1))) {
         $codigo = intval($excel->val($i, 1));
         $arr = array();
         foreach ($this->columnas as $col => $pos) {
             $arr[$col] = $excel->val($i, $pos);
         }
         $arr['sexo'] = intval($arr['sexo']) == 1 ? 'M' : 'F';
         if ($alumno = $this->alumnoExiste($codigo)) {
             // Actualizar
             $arr['id'] = $alumno['id'];
             $this->update($arr);
         } else {
             // Crear
             $this->create($arr);
         }
         $i++;
     }
     $this->db->trans_complete();
 }
開發者ID:boriscy,項目名稱:san_lorenzo,代碼行數:28,代碼來源:alumno_model.php

示例7: do_upload

 function do_upload()
 {
     $config['upload_path'] = './upload/';
     $config['allowed_types'] = 'php|txt|xls|xml';
     $config['max_size'] = '1000000';
     //$config['max_width']  = '1024';
     //$config['max_height']  = '768';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload()) {
         $error = array('error' => $this->upload->display_errors());
         //$this->load->view('header');
         $this->load->view('upload_view', $error);
         //$this->load->view('footer');
     } else {
         $data = array('upload_data' => $this->upload->data());
         $this->load->library('Excel/spreadsheet_Excel_Reader');
         //require_once 'Excel/reader.php';
         // ExcelFile($filename, $encoding);
         $excel = new Spreadsheet_Excel_Reader();
         // Set output Encoding.
         $excel->setOutputEncoding('CP1251');
         //lecture du fichier excel
         //chmod('./upload/' . $data['upload_data']['file_name'], 0777);
         $excel->read('./upload/' . $data['upload_data']['file_name']);
         //$liste = array($excel->sheets[0]['numRows'],2);
         $array = $excel->sheets[0]['cells'];
         $temp = array_shift($array);
         var_dump($array);
         //$this->data_model->insert_entry($array);
         $this->load->view('upload_success', $data);
     }
 }
開發者ID:jabouzi,項目名稱:3b,代碼行數:32,代碼來源:upload.php

示例8: ABSSAV

function ABSSAV()
{
    $inFile = $_REQUEST['inFile'];
    echo "Filename is: {$inFile}<br>";
    require_once 'Excel/reader.php';
    $data = new Spreadsheet_Excel_Reader();
    $data->setOutputEncoding('CP1251');
    $data->read($inFile);
    error_reporting(E_ALL ^ E_NOTICE);
    $Target_Database = 'binawan';
    $Target_Table = $Target_Database . '.ruang';
    $Target_KodeID = "BINAWAN";
    $s = "TRUNCATE TABLE {$Target_Table}";
    $r = _query($s);
    for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
        $w = array();
        $w['RuangID'] = trim($data->sheets[0]['cells'][$i][2]);
        $w['Nama'] = trim($data->sheets[0]['cells'][$i][3]);
        $w['Kapasitas'] = trim($data->sheets[0]['cells'][$i][4]);
        $w['KapasitasUjian'] = trim($data->sheets[0]['cells'][$i][4]);
        $w['KolomUjian'] = trim($data->sheets[0]['cells'][$i][5]);
        $w['KampusID'] = trim($data->sheets[0]['cells'][$i][6]);
        $w['Lantai'] = trim($data->sheets[0]['cells'][$i][7]);
        $w['RuangKuliah'] = trim($data->sheets[0]['cells'][$i][8]);
        $s = "insert into {$Target_Table}\r\n          (RuangID, Nama, Kapasitas, KapasitasUjian, KolomUjian, KampusID, Lantai, KodeID, RuangKuliah, UntukUSM\r\n\t      )\r\n          values\r\n          ('{$w['RuangID']}', '{$w['Nama']}', '{$w['Kapasitas']}', '{$w['KapasitasUjian']}', '{$w['KolomUjian']}', '{$w['KampusID']}', '{$w['Lantai']}', 'BINAWAN', '{$w['RuangKuliah']}', '{$w['RuangKuliah']}'\r\n\t      )";
        $r = _query($s);
    }
    echo "<script>window.location = '?{$mnux}={$_SESSION['mnux']}'</script>";
}
開發者ID:anggadjava,項目名稱:mitra_siakad,代碼行數:29,代碼來源:_exceltosql.php

示例9: doimport

 function doimport()
 {
     $file_name = $_GET['province_id'] . ".xls";
     if ($file_name != '') {
         //$ext = pathinfo($_FILES['filename']['name'], PATHINFO_EXTENSION);
         //echo $file_name = 'nursery.'.$ext;
         $uploaddir = 'import/tmp/';
         $fpicname = $uploaddir . $file_name;
         ///move_uploaded_file($_FILES['filename']['tmp_name'], $fpicname);
         require_once 'include/Excel/reader.php';
         $data = new Spreadsheet_Excel_Reader();
         $data->setOutputEncoding('UTF-8');
         $data->read($fpicname);
         error_reporting(E_ALL ^ E_NOTICE);
         $index = 0;
         for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
             $amphur = new Amphur();
             $amphur = $amphur->where(" amphur_name ='" . trim($data->sheets[0]['cells'][$i][1]) . "'")->get();
             $import[$index]['province_id'] = $_POST['province_id'];
             $import[$index]['amphur_id'] = $amphur->id;
             $import[$index]['name'] = trim($data->sheets[0]['cells'][$i][2]);
             $index++;
             if ($amphur->id > 0) {
                 $_POST['province_id'] = $_GET['province_id'];
                 $_POST['amphur_id'] = $amphur->id;
                 $_POST['name'] = trim($data->sheets[0]['cells'][$i][2]);
                 $nursery = new Nursery_Tmp();
                 $nursery->from_array($_POST);
                 $nursery->save();
             }
         }
     }
 }
開發者ID:unisexx,項目名稱:thaigcd2015,代碼行數:33,代碼來源:nurseries.php

示例10: insertUpdateNotas

 /**
  * Realiza la inserción o actualización de notas de un estudiante
  * @param string
  * @param integer
  */
 function insertUpdateNotas($archivo, $anio)
 {
     include_once 'system/application/libraries/excel_reader2.php';
     $excel = new Spreadsheet_Excel_Reader("system/excel/notas/{$archivo}");
     $alumnos = $this->loadModel('Alumno_model')->getList(array('labelField' => 'id', 'valueField' => 'codigo'));
     $materias = $this->loadModel('Materia_model')->getList(array('labelField' => 'id', 'valueField' => 'nombre'));
     $i = 2;
     $this->errors = array();
     $this->db->trans_start();
     while (trim($excel->val($i, 1)) != '') {
         $codigo = trim($excel->val($i, 1));
         if (!isset($alumnos[$codigo])) {
             array_push($this->errors, "No existe un alumno con código \"{$codigo}\" fila {$i} del archivo excel");
             $i++;
             continue;
         }
         $alumno_id = $alumnos[$codigo];
         $materia_nombre = trim($excel->val($i, 2));
         if (!isset($materias[$materia_nombre])) {
             array_push($this->errors, "No existe la materia \"{$materia_nombre}\" en la fila {$i} del archivo excel");
             $i++;
             continue;
         }
         $materia_id = $materias[$materia_nombre];
         $this->setNota($alumno_id, $materia_id, $excel, $anio, $i);
         $i++;
     }
     $this->db->trans_complete();
     return $this->errors;
 }
開發者ID:boriscy,項目名稱:san_lorenzo,代碼行數:35,代碼來源:nota_model.php

示例11: add_in_mysql

 public function add_in_mysql()
 {
     if (!empty($_FILES['efile']['name'])) {
         $exname = strtolower(substr($_FILES['efile']['name'], strrpos($_FILES['efile']['name'], '.') + 1));
         $uploadfile = $this->getnames($exname);
         //上傳後文件所在的路徑
         @move_uploaded_file($_FILES['efile']['tmp_name'], $uploadfile);
     }
     $data = new Spreadsheet_Excel_Reader();
     $data->setOutputEncoding('utf-8');
     $data->read($uploadfile);
     //讀取要導入數據庫的文件
     error_reporting(E_ALL ^ E_NOTICE);
     $Stu = D("Stu");
     //$User->startTrans();//啟動事務;
     $filed = C("excle");
     //獲取字段對應的列
     for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
         $col = $data->sheets[0]['cells'][$i];
         $arr = array("stuno" => $col[$filed["stuno"]], "stuname" => $col[$filed["stuname"]], "password" => $col[$filed["password"]], "sex" => $col[$filed["sex"]], "idcard" => $col[$filed["idcard"]], "classno" => $col[$filed["classno"]], "college" => "1");
         $Stu->create($arr);
         echo $Stu->getError() . "<br/>";
         if (!$Stu->add()) {
             $Stu->rollback();
             //不成功,回滾
             echo "導入失敗回滾";
             return;
         }
         echo $arr["stuno"] . "導入成功<br/>";
     }
     $Stu->commit();
     //成功提交
 }
開發者ID:zhujunxxxxx,項目名稱:zzadmin,代碼行數:33,代碼來源:ImportAction.class.php

示例12: readRoom

function readRoom($file, $table, $pos)
{
    require_once "conn.php";
    $sql = "TRUNCATE TABLE {$table}";
    if ($mysqliObj->query($sql)) {
        echo "truncate success" . "</br>";
    }
    require_once 'Excel/reader.php';
    // ExcelFile($filename, $encoding);
    $data = new Spreadsheet_Excel_Reader();
    // Set output Encoding.
    // $data->setOutputEncoding('CP936');
    $data->setOutputEncoding('gbk');
    $data->read($file);
    error_reporting(E_ALL ^ E_NOTICE);
    //$data->sheets[0]['numRows']
    for ($i = $pos; $i <= $data->sheets[0]['numRows']; $i++) {
        $msg1 = $data->sheets[0]['cells'][$i][1];
        $msg2 = $data->sheets[0]['cells'][$i][2];
        $msg3 = $data->sheets[0]['cells'][$i][3];
        $sql = "INSERT INTO  {$table} (`roomId` ,`type` ,`price` )\n\t\t\t\tVALUES ('{$msg1}',  '{$msg2}',  '{$msg3}')";
        if (!is_null($data->sheets[0]['cells'][$i][1])) {
            $mysqliObj->query($sql);
        }
    }
    $mysqliObj->close();
}
開發者ID:kongsicong,項目名稱:HotelManageSystem,代碼行數:27,代碼來源:RoomInfo.php

示例13: ABSSAV

function ABSSAV()
{
    $inFile = $_REQUEST['inFile'];
    require_once 'Excel/reader.php';
    $data = new Spreadsheet_Excel_Reader();
    $data->setOutputEncoding('CP1251');
    $data->read($inFile);
    error_reporting(E_ALL ^ E_NOTICE);
    $Target_Database = 'binawan';
    $Target_Table = $Target_Database . 'mhsw';
    $Target_KodeID = "BINAWAN";
    $s = "TRUNCATE TABLE ";
    $r = _query($s);
    for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
        $w = array();
        $w['MhswID'] = trim($data->sheets[0]['cells'][$i][1]);
        $w['TahunID'] = trim($data->sheets[0]['cells'][$i][2]);
        $w['Nama'] = trim($data->sheets[0]['cells'][$i][3]);
        $w['Kelamin'] = trim($data->sheets[0]['cells'][$i][4]);
        $w['TempatLahir'] = trim($data->sheets[0]['cells'][$i][5]);
        $w['TanggalLahir'] = trim($data->sheets[0]['cells'][$i][6]);
        $w['Agama'] = trim($data->sheets[0]['cells'][$i][7]);
        $w['Alamat'] = trim($data->sheets[0]['cells'][$i][8]);
        $s = "insert into {$Target_Database}\r\n          (MhswID, Login, LevelID, Password, PMBID, \r\n\t\t   TahunID, KodeID, Nama, \r\n\t\t   Foto, StatusMhswID, ProgramID, ProdiID, KelasID,\r\n\t\t   Kelamin, TempatLahir, TanggalLahir, Agama, Alamat, \r\n\t\t   Kota, RT, RW, KodePos, Propinsi, Negara, \r\n\t\t   Telepon, Handphone \r\n\t      )\r\n          values\r\n          ('{$w['MhswID']}', '{$w['Login']}', '120', '{$w['Password']}', '{$w['PMBID']}', \r\n\t\t   '{$w['TahunID']}', '{$Target_KodeID}', '{$w['Nama']}', \r\n\t\t   '{$w['Foto']}', '{$w['StatusMhswID']}', '{$w['ProgramID']}', '{$w['ProdiID']}', '{$w['KelasID']}',\r\n\t\t   '{$w['Kelamin']}', '{$w['TempatLahir']}', '{$w['TanggalLahir']}', '{$w['Agama']}', '{$w['Alamat']}', \r\n\t\t   '{$w['Kota']}', '{$w['RT']}', '{$w['RW']}', '{$w['KodePos']}', '{$w['Propinsi']}', '{$w['Negara']}', \r\n\t\t   '{$w['Telepon']}', '{$w['Handphone']}' \r\n\t      )";
        $r = _query($s);
    }
    echo "<script>window.location = '?{$mnux}={$_SESSION['mnux']}'</script>";
}
開發者ID:anggadjava,項目名稱:mitra_siakad,代碼行數:28,代碼來源:_exceltosql-ori.php

示例14: updateDB

function updateDB($startIndex, $endIndex)
{
    //need to copy the code that does the excel reading
    $analysisData = new Spreadsheet_Excel_Reader();
    // Set output Encoding.
    $analysisData->setOutputEncoding('CP1251');
    $inputFileName = 'ReverseGeoCodingForStopsVerification.xls';
    $analysisData->read($inputFileName);
    error_reporting(E_ALL ^ E_NOTICE);
    $numRows = $analysisData->sheets[0]['numRows'];
    $numCols = $analysisData->sheets[0]['numCols'];
    //echo $numRows.",".$numCols;
    $strRoute = '<Routes>';
    for ($i = $startIndex; $i <= $endIndex; $i++) {
        $stopId = $analysisData->sheets[0]['cells'][$i][1];
        $StopName = $analysisData->sheets[0]['cells'][$i][2];
        $Buses = $analysisData->sheets[0]['cells'][$i][3];
        $latitude = $analysisData->sheets[0]['cells'][$i][4];
        $longitude = $analysisData->sheets[0]['cells'][$i][5];
        $strRoute = $strRoute . '<Route>';
        $routeDetails = htmlentities(trim($StopName)) . ":" . $latitude . ":" . $longitude;
        //echo $routeDetails."<br/>";
        $strRoute = $strRoute . '<RouteDetails>' . $routeDetails . '</RouteDetails>';
        $strRoute = $strRoute . '</Route>';
    }
    $strRoute = $strRoute . '</Routes>';
    echo $strRoute;
}
開發者ID:rohdimp24,項目名稱:test,代碼行數:28,代碼來源:ReverseGeoCodingForStopsVerification.php

示例15: getDataFromExcel

 function getDataFromExcel($filename)
 {
     $uimap = new Spreadsheet_Excel_Reader();
     $uimap->read($this->path . "\\data\\uimap\\" . $filename . ".xls");
     $s = 0;
     foreach ($uimap->boundsheets as $ar) {
         $i = 2;
         while ($i <= $uimap->sheets[$s]['numRows']) {
             if (!empty($uimap->sheets[$s]['cells'][$i][2]) && !empty($uimap->sheets[$s]['cells'][$i][3]) && strtolower($ar['name']) != 'datamap') {
                 $this->sheets[strtolower($ar['name'])][strtolower($uimap->sheets[$s]['cells'][$i][2])] = $uimap->sheets[$s]['cells'][$i][3];
             } elseif (!empty($uimap->sheets[$s]['cells'][$i][2]) && strtolower($ar['name']) == 'datamap') {
                 $datafile = new Spreadsheet_Excel_Reader();
                 $datafile->read($this->path . "\\" . $uimap->sheets[$s]['cells'][$i][3]);
                 $j = 2;
                 while ($j <= $datafile->sheets[0]['numRows']) {
                     if (!empty($datafile->sheets[0]['cells'][$j][2])) {
                         if (empty($datafile->sheets[0]['cells'][$j][4])) {
                             $this->datamap[strtolower($datafile->sheets[0]['cells'][$j][2])] = $datafile->sheets[0]['cells'][$j][3];
                         } else {
                             $y = 3;
                             while (!empty($datafile->sheets[0]['cells'][$j][$y])) {
                                 $this->datamap[strtolower($datafile->sheets[0]['cells'][$j][2])][] = $datafile->sheets[0]['cells'][$j][$y];
                                 $y++;
                             }
                         }
                     }
                     $j++;
                 }
             }
             $i++;
         }
         $s++;
     }
     $this->uimap = $this->sheets;
 }
開發者ID:erlendfh,項目名稱:Bromine,代碼行數:35,代碼來源:Dataparser.php


注:本文中的Spreadsheet_Excel_Reader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。