コード例 #1
0
ファイル: xlsimportadapter.php プロジェクト: jabouzi/projet
 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();
     }
 }
コード例 #2
0
ファイル: helper.php プロジェクト: pancamedia/Marlina-Sabil
/**
 * Method untuk membaca data pada file excel
 *
 * @param  string  $path_file           path file excel
 * @param  integer $baris_mulai_data
 * @return array
 */
function data_excel($path_file, $baris_mulai_data = 2)
{
    include 'excel_reader2.php';
    $file_excel = new Spreadsheet_Excel_Reader($path_file);
    # membaca jumlah baris dari data excel
    $baris = $file_excel->rowcount($sheet_index = 0);
    $kolom = $file_excel->colcount($sheet_index = 0);
    $data_return = array();
    for ($i = $baris_mulai_data; $i <= $baris; $i++) {
        $row_data = array();
        for ($k = 1; $k <= $kolom; $k++) {
            $row_data[] = $file_excel->val($i, $k);
        }
        $data_return[] = $row_data;
    }
    return $data_return;
}
コード例 #3
0
 public function import($file)
 {
     try {
         $users = array();
         $params = array(1 => 'username', 'password', 'first_name', 'last_name', 'email', 'admin', 'active');
         $excel = new Spreadsheet_Excel_Reader($file);
         $rows = $excel->rowcount($sheet_index = 0);
         $cols = $excel->colcount($sheet_index = 0);
         for ($row = 2; $row <= $rows; $row++) {
             for ($col = 1; $col <= $cols; $col++) {
                 $users[$row][$params[$col]] = $excel->val($row, $col);
             }
         }
         $this->userimport = new userimport();
         $users = $this->userimport->import($users);
         $_SESSION['message'] = $this->userimport->get_message();
         return $users;
     } catch (Exception $e) {
         display_page_error();
     }
 }
コード例 #4
0
function importToExistingTable($file, $tableName)
{
    $data = new Spreadsheet_Excel_Reader($file);
    $colcount = $data->colcount();
    $rowcount = $data->rowcount();
    //This gets the field names in the database so that they can be confirmed as matching those in the spreadsheet:
    $sql = mysql_query("SELECT * FROM `{$tableName}`");
    for ($no = 0; $no <= $colcount; $no++) {
        $tableColsArray[$no] = mysql_field_name($sql, $no);
    }
    //This goes through the spreadsheet and compares the columns with those in the database:
    for ($colno = 1; $colno <= $colcount; $colno++) {
        $cell = $data->value(1, $colno);
        if ($tableColsArray[$colno] != $cell) {
            die("Column {$colno} does not match its counterpart in the database");
        } else {
            echo "spreadsheet part ({$cell}) perfectly matches db part ({$tableColsArray[$colno]})<br />";
        }
    }
    //This goes through the whole sheet building the insert statement from the data:
    $actualInserts = 0;
    for ($rowno = 2; $rowno <= $rowcount; $rowno++) {
        $sql = "INSERT INTO `{$tableName}` (";
        for ($no = 1; $no < count($tableColsArray); $no++) {
            $sql = $sql . "`{$tableColsArray[$no]}`,";
        }
        $sql = substr($sql, 0, -1) . ") VALUES (";
        for ($colno = 1; $colno <= $colcount; $colno++) {
            $sql = $sql . "'" . mysql_real_escape_string($data->value($rowno, $colno)) . "',";
        }
        $sql = substr($sql, 0, -1) . ")";
        //This executes the insert and counts the successful inserts:
        if (!mysql_query($sql)) {
            echo mysql_error();
        } else {
            $actualInserts++;
        }
    }
    echo "<br />" . $actualInserts . " rows inserted";
}
コード例 #5
0
	vertical-align:bottom;
}
table.excel tbody td {
    padding: 0 3px;
	border: 1px solid #EEEEEE;
}
</style>
</head>

<body>
<?php 
echo "DATA BERHASIL TERSIMPAN KE DALAM DATABASE<br/>";
echo "STATISTIK DATA FILE<br/>";
echo "=============================<br/>";
echo "Jumlah Baris  : " . $data->rowcount(0) . "<br/>";
echo "Jumlah Kolom  : " . $data->colcount(0) . "<br/><br/>";
echo "<table border='1' cellpadding='3' cellspacing='1' style='width:100%;'>";
echo "<tr>";
echo "<td>No</td>";
echo "<td>No Persetujuan BKN</td>";
echo "<td>TGL Persetujuan BKN</td>";
echo "<td>NIP</td>";
echo "<td>Pendidikan</td>";
echo "<td>TMT Lama</td>";
echo "<td>MKG Lama (Tahun)</td>";
echo "<td>MKG Lama (Bulan)</td>";
echo "<td>Gaji Pokok Lama</td>";
echo "<td>Jabatan</td>";
echo "<td>TMT Baru</td>";
echo "<td>MKG Baru (Tahun)</td>";
echo "<td>MKG Baru (Bulan)</td>";
コード例 #6
0
ファイル: roster.php プロジェクト: boombaw/masterwoow
 public function importexcel()
 {
     $fileupload = $_FILES['fileexcel']['tmp_name'];
     $namafile = $_FILES['fileexcel']['name'];
     $path = 'assets/resources/data/';
     $pathfile = $path . $namafile;
     $orgid = $this->my_usession->userdata('user_dept') != '' ? $this->employe_model->deptonall(explode(',', $this->my_usession->userdata('user_dept'))) : array();
     $holiday = $this->roster_model->holiday($orgid);
     $holarray = array();
     foreach ($holiday->result() as $hol) {
         $tglmulai = strtotime($hol->startdate);
         $tglselesai = strtotime($hol->enddate);
         $selisih = $tglselesai - $tglmulai;
         if ($selisih == 0) {
             $holarray[] = $hol->startdate;
         } else {
             $jarak = $selisih / 86400;
             for ($k = 0; $k <= $jarak; $k++) {
                 $holarray[] = date('Y-m-d', strtotime($hol->startdate) + $k * 86400);
             }
         }
     }
     if (move_uploaded_file($fileupload, $pathfile)) {
         include_once APPPATH . "libraries/excelreader.php";
         $data = new Spreadsheet_Excel_Reader($pathfile);
         $blth = $data->val(2, 2) . '-' . date('m', strtotime($data->val(1, 2)));
         $usernik = $this->roster_model->getuseridfromnik();
         foreach ($usernik->result() as $useridfromnik) {
             $array[$useridfromnik->userid] = array('name' => $useridfromnik->name, 'group' => $useridfromnik->deptid);
         }
         $a = array();
         $datagagal = '';
         $nonik = 0;
         for ($i = 5; $i <= $data->rowcount($sheet_index = 0); $i++) {
             $nik = $data->val($i, 1);
             if ($nik != '') {
                 if (isset($array[$nik])) {
                     $userid = $nik;
                     $name = $array[$nik]['name'];
                     $group = $array[$nik]['group'];
                     $data_arr = array('userid' => $userid, 'name' => $name, 'group' => $group);
                     $tgla = '';
                     $tanggal = strtotime($blth . '-' . $data->val(3, 3));
                     for ($j = 3; $j <= $data->colcount($sheet_index = 0); $j++) {
                         $tgla .= $tanggal + ($j - 3) * 86400 . "\t";
                         $tglan = $tanggal + ($j - 3) * 86400;
                         $shift[$j] = $data->val($i, $j);
                         if ($shift[$j] != '') {
                             $savedata = array('userid' => $userid, 'rosterdate' => date('Y-m-d', $tglan), 'absence' => $shift[$j]);
                             $data_arr[$tglan] = $shift[$j];
                         } else {
                             $data_arr[$tglan] = $shift[$j];
                         }
                     }
                     $fieldarr[] = $data_arr;
                 } else {
                     $datagagal = $datagagal . $nik . ', ';
                 }
             } else {
                 $nonik++;
             }
         }
         $fp = fopen('assets/js/template/roster_' . $this->my_usession->userdata('user_id') . '.json', 'w');
         fwrite($fp, json_encode(array('data' => $fieldarr)));
         fclose($fp);
         if (strpos($datagagal, ',') !== false) {
             $datagagal = substr($datagagal, 0, -2);
         }
         $tgl = "userid\tname\t";
         $tglan = explode("\t", $tgla);
         $count = count($tglan);
         for ($i = 0; $i < $count - 1; $i++) {
             if (in_array(date('Y-m-d', $tglan[$i]), $holarray)) {
                 $tgl .= $tglan[$i] . "#\t";
             } else {
                 $tgl .= $tglan[$i] . "\t";
             }
         }
         $actionlog = array('user' => $this->my_usession->userdata('username'), 'ipadd' => $this->ipaddress->get_ip(), 'logtime' => date("Y-m-d H:i:s"), 'logdetail' => 'Import roster', 'info' => $this->lang->line('message_success'));
         $this->db->insert('actionlog', $actionlog);
         $hasil = array("responseText" => "success", "success" => true, "tglawal" => $tglan[0], "tglakhir" => $tglan[$count - 2], "datagagal" => $datagagal, "nonik" => $nonik, "field" => $tgl);
         echo json_encode($hasil);
     } else {
         $hasil = array("responseText" => $this->lang->line('message_failimport'), "success" => false);
         echo json_encode($hasil);
     }
 }
コード例 #7
0
ファイル: import-verify.php プロジェクト: jonashauge/phpipam
                /* get file to string */
                $filehdl = fopen('upload/data_import.csv', 'r');
                $data = fgets($filehdl);
                fclose($filehdl);
                /* format file */
                $data = str_replace(array("\r\n", "\r"), "", $data);
                //remove line break
                $data = preg_split("/[;,]/", $data);
                //split by comma or semi-colon
                foreach ($data as $col) {
                    $firstrow[] = $col;
                }
            } elseif (strtolower($filetype) == "xls") {
                # get excel object
                require_once dirname(__FILE__) . '/../../../functions/php-excel-reader/excel_reader2.php';
                //excel reader 2.21
                $data = new Spreadsheet_Excel_Reader('upload/data_import.xls', false);
                $sheet = 0;
                $row = 1;
                for ($col = 1; $col <= $data->colcount($sheet); $col++) {
                    $firstrow[] = $data->val($row, $col, $sheet);
                }
            }
            echo '{"status":"success","expfields":' . json_encode($expfields, true) . ',"impfields":' . json_encode($firstrow, true) . ',"filetype":' . json_encode($filetype, true) . '}';
            exit;
        }
    }
}
/* default - error */
echo '{"status":"error","error":"Empty file"}';
exit;
コード例 #8
0
     replay_move_uploaded_file($filename);
     $html = file_get_html("../uploadstand/" . $filename);
     $standtable = $html->find("table.monitor", 0);
     $nprob = sizeof($standtable->find("tr", 0)->children()) - 5;
     if ($nprob != $pnum) {
         $ret["msg"] = "Expected " . $nprob . " problems, got {$pnum} . Add failed.";
         die(json_encode($ret));
     }
     replay_add_contest();
     replay_deal_ural($standtable);
 } else {
     if ($_POST["ctype"] == "zju") {
         $filename = "replay_cid_" . $mcid . ".xls";
         replay_move_uploaded_file($filename);
         $data = new Spreadsheet_Excel_Reader("../uploadstand/" . $filename);
         if ($pnum != $data->colcount() - 5) {
             $ret["msg"] = "Expected " . ($data->colcount() - 5) . " problems, got {$pnum} . Add failed.";
             die(json_encode($ret));
         }
         replay_add_contest();
         replay_deal_zju($data);
     } else {
         if ($_POST["ctype"] == "jhinv") {
             $filename = "replay_cid_" . $mcid . ".html";
             replay_move_uploaded_file($filename);
             $html = file_get_html("../uploadstand/" . $filename);
             $standtable = $html->find("#standings", 0);
             $nprob = sizeof($standtable->find("tr", 0)->children()) - 7;
             if ($nprob != $pnum) {
                 $ret["msg"] = "Expected " . $nprob . " problems, got {$pnum} . Add failed.";
                 die(json_encode($ret));
コード例 #9
0
                # read each row into a dictionary with expected fields as keys
                $record[$fieldmap[$col]] = trim($val);
            }
        }
        $data[] = $record;
    }
    fclose($filehdl);
} elseif (strtolower($filetype) == "xls") {
    # get excel object
    require_once dirname(__FILE__) . '/../../../functions/php-excel-reader/excel_reader2.php';
    //excel reader 2.21
    $xls = new Spreadsheet_Excel_Reader('upload/data_import.xls', false);
    $sheet = 0;
    $row = 1;
    # map import columns to expected fields as per previous window
    for ($col = 1; $col <= $xls->colcount($sheet); $col++) {
        $fieldmap[$col] = $impfields[$xls->val($row, $col, $sheet)];
        $hcol = $col;
    }
    # read each remaining row into a dictionary with expected fields as keys
    for ($row = 2; $row <= $xls->rowcount($sheet); $row++) {
        $record = array();
        for ($col = 1; $col <= $xls->colcount($sheet); $col++) {
            $record++;
            if ($col > $hcol) {
                $Result->show('danger', _("Extra column found on line ") . $row . _(" in XLS file. Please check input file."), true);
            } else {
                $record[$fieldmap[$col]] = trim($xls->val($row, $col, $sheet));
            }
        }
        $data[] = $record;
コード例 #10
0
ファイル: uploadSubQuiz.php プロジェクト: tush241191/elearn
 if (in_array($extension, $allowed_extensions)) {
     $source = $_FILES['file']['tmp_name'];
     $t = "Subjective" . time() . "" . date('Ymd') . ".xls";
     $target = $upload_path . "/" . $t;
     $tempUploadedValue = move_uploaded_file($source, $target);
     if ($tempUploadedValue) {
         /*    echo "<script type='text/javascript'> alert('test1'); </script>";  */
         if (($handle = fopen($upload_path . '/' . $t, "r")) !== false) {
             $_FILES['file']['name'];
             $expiryDate = $_POST['expiryDate'];
             $data = new Spreadsheet_Excel_Reader($upload_path . '/' . $t);
             $data->dump(true, true);
             $data_array = array();
             for ($i = 1; $i <= $data->rowcount(); $i++) {
                 $data_array[$i] = array();
                 for ($j = 1; $j <= $data->colcount(); $j++) {
                     $data_array[$i][$j] = $data->val($i, $j);
                 }
                 // inner For
             }
             // outer For
             $myFile = $t;
             $url = "./excelfiles/" . $t;
             $newUploadedQuizURL = $newBaseURL . "/excelfiles/" . str_replace(' ', '%20', $myFile);
             $newQuizName = $_POST['questionFileName'];
             $newQuizFileName = $myFile;
             $duration = $_POST['hours'] * 3600 + $_POST['minutes'] * 60;
             $questionWeightage = $_POST['questionWeightage'];
             $questionQty = $_POST['questionQty'];
             $re_exam_date = $_POST['re_exam_date'];
             $cut_off = $_POST['cut_off'];
コード例 #11
0
ファイル: extract.php プロジェクト: asavagar/EU-data-cloud
function _handleDataset($fileName)
{
    global $startYear;
    global $endYear;
    global $vocab;
    global $regions;
    global $subRegions;
    global $countries;
    global $propURIs;
    $data = new Spreadsheet_Excel_Reader($fileName);
    $datasetName = str_replace('data/', '', $fileName);
    $datasetName = str_replace('.xls', '', $fileName);
    $datasetComment = null;
    $datasetURI = URI_BASE . 'dataset/' . urlencode($datasetName);
    $slices = array();
    $rdfData = array();
    $sheetCount = count($data->boundsheets);
    for ($i = 0; $i < $sheetCount; ++$i) {
        $rowCount = $data->rowcount($i);
        $colCount = $data->colcount($i);
        $sheetTitle = $data->boundsheets[$i]['name'];
        $currentRow = 0;
        $currentRegion = null;
        $currentSubRegion = null;
        $sliceTitle = null;
        // Search for slice title
        for ($row = 0; $row < $rowCount; ++$row) {
            for ($col = 0; $col < $colCount; ++$col) {
                $cellValue = $data->val($row, $col, $i);
                if ($cellValue !== '') {
                    $sliceTitle = trim($cellValue);
                    $currentRow = $row + 1;
                    break 2;
                }
            }
        }
        // Search for dataset definition
        for ($row = $currentRow; $row < $rowCount; ++$row) {
            for ($col = 0; $col < $colCount; ++$col) {
                $cellValue = $data->val($row, $col, $i);
                if ($cellValue !== '') {
                    if (strpos(strtolower($cellValue), 'definition:') !== false) {
                        $datasetComment = trim($cellValue);
                        $currentRow = $row + 1;
                        break 2;
                    }
                }
            }
        }
        // Search for start of data
        for ($row = $currentRow; $row < $rowCount; ++$row) {
            $cellValue = $data->val($row, 1, $i);
            if ($cellValue !== '') {
                $currentRow = $row + 1;
                break;
            }
        }
        $sheetInstances = array();
        for ($row = $currentRow; $row < $rowCount; ++$row) {
            if ($data->val($row, 3, $i) === '') {
                // We break, if col 3 is empty (country), since all data rows have a country!
                break;
            }
            $region = $data->val($row, 1, $i);
            if ($region === '') {
                $region = $currentRegion;
            } else {
                // new region... store it
                $regions[$region] = $region;
            }
            $subRegion = $data->val($row, 2, $i);
            if ($subRegion === '') {
                $subRegion = $currentSubRegion;
            } else {
                // new subregion... store it
                $subRegions[$subRegion] = $currentRegion;
            }
            $country = $data->val($row, 3, $i);
            $countries[$country] = $subRegion;
            $countValues = array();
            // Now the values for count
            $currentCol = 4;
            for ($j = $startYear; $j <= $endYear; ++$j) {
                $val = $data->val($row, $currentCol++, $i);
                if ($val != '-1' && $val != '') {
                    $countValues[$j] = floatval(str_replace(',', '.', $val));
                }
            }
            $rateValues = array();
            $currentCol++;
            for ($j = $startYear; $j <= $endYear; ++$j) {
                $val = $data->val($row, $currentCol++, $i);
                if ($val != '-1' && $val != '') {
                    $rateValues[$j] = floatval(str_replace(',', '.', $val));
                }
            }
            $regionURI = URI_BASE . 'region/' . urlencode($region);
            $subRegionURI = URI_BASE . 'subregion/' . urlencode($subRegion);
            $countryURI = URI_BASE . 'country/' . urlencode($country);
            $countPropURI = $vocab['unodc'] . strtolower($datasetName) . urlencode(ucfirst(strtolower($sheetTitle))) . 'Count';
            $propURIs[$countPropURI] = $datasetName . ' ' . $sheetTitle . ' count';
            foreach ($countValues as $year => $val) {
                $yearURI = URI_BASE . 'year/' . $year;
                $instanceURI = URI_BASE . 'observation/' . strtolower($datasetName) . urlencode(ucfirst(strtolower($sheetTitle))) . 'Count' . urlencode($country) . $year;
                $sheetInstances[] = $instanceURI;
                $label = $datasetName . ' ' . $sheetTitle . ' count of ' . $country . ' in ' . $year;
                $rdfData[$instanceURI] = array(RDF_TYPE => array(array('type' => 'uri', 'value' => $vocab['qb'] . 'Observation')), $vocab['rdfs'] . 'label' => array(array('value' => $label, 'type' => 'literal')), $countPropURI => array(array('value' => $val, 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#float')), $vocab['unodc'] . 'country' => array(array('type' => 'uri', 'value' => $countryURI)), $vocab['unodc'] . 'subregion' => array(array('type' => 'uri', 'value' => $subRegionURI)), $vocab['unodc'] . 'region' => array(array('type' => 'uri', 'value' => $regionURI)), $vocab['unodc'] . 'year' => array(array('type' => 'uri', 'value' => $yearURI)), $vocab['qb'] . 'dataSet' => array(array('type' => 'uri', 'value' => $datasetURI)));
            }
            $ratePropURI = $vocab['unodc'] . strtolower($datasetName) . urlencode(ucfirst(strtolower($sheetTitle))) . 'Rate';
            $propURIs[$ratePropURI] = $datasetName . ' ' . $sheetTitle . ' rate';
            foreach ($rateValues as $year => $val) {
                $yearURI = URI_BASE . 'year/' . $year;
                $instanceURI = URI_BASE . 'observation/' . strtolower($datasetName) . urlencode(ucfirst(strtolower($sheetTitle))) . 'Rate' . urlencode($country) . $year;
                $sheetInstances[] = $instanceURI;
                $label = $datasetName . ' ' . $sheetTitle . ' rate of ' . $country . ' in ' . $year;
                $rdfData[$instanceURI] = array(RDF_TYPE => array(array('type' => 'uri', 'value' => $vocab['qb'] . 'Observation')), $vocab['rdfs'] . 'label' => array(array('value' => $label, 'type' => 'literal')), $countPropURI => array(array('value' => $val, 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#float')), $vocab['unodc'] . 'country' => array(array('type' => 'uri', 'value' => $countryURI)), $vocab['unodc'] . 'subregion' => array(array('type' => 'uri', 'value' => $subRegionURI)), $vocab['unodc'] . 'region' => array(array('type' => 'uri', 'value' => $regionURI)), $vocab['unodc'] . 'year' => array(array('type' => 'uri', 'value' => $yearURI)), $vocab['qb'] . 'dataSet' => array(array('type' => 'uri', 'value' => $datasetURI)));
            }
        }
        // sheet metadata
        $sheetURI = URI_BASE . 'sheet/' . urlencode(strtolower($datasetName)) . urlencode(ucfirst(strtolower($sheetTitle)));
        $slices[] = $sheetURI;
        $rdfData[$sheetURI] = array(RDF_TYPE => array(array('type' => 'uri', 'value' => $vocab['qb'] . 'Slice')), $vocab['rdfs'] . 'label' => array(array('type' => 'literal', 'value' => $sheetTitle)));
        $oArray = array();
        foreach ($sheetInstances as $inst) {
            $oArray[] = array('value' => $inst, 'type' => 'uri');
        }
        $rdfData[$sheetURI][$vocab['qb'] . 'observation'] = $oArray;
    }
    // write dataset metadata
    $rdfData[$datasetURI] = array(RDF_TYPE => array(array('type' => 'uri', 'value' => $vocab['qb'] . 'DataSet')), $vocab['rdfs'] . 'label' => array(array('type' => 'literal', 'value' => $datasetName)), $vocab['rdfs'] . 'comment' => array(array('type' => 'literal', 'value' => $datasetComment)));
    $oArray = array();
    foreach ($slices as $slice) {
        $oArray[] = array('value' => $slice, 'type' => 'uri');
    }
    $rdfData[$sheetURI][$vocab['qb'] . 'slice'] = $oArray;
    return $rdfData;
}
コード例 #12
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new PhoneModel();
     $message = "";
     $errorList = array();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['source_name'], $_POST['group_id'])) {
         $fileName = _APP_PATH_ . DS . "data" . DS . "tmp" . DS . $_POST['source_name'];
         $group_id = $_POST['group_id'];
         //$fileName = "D:\\chacha_cloud\\src\\trunk\chacha\data\\tmp\\20120713170547_phone_list.xls";
         try {
             require_once 'excel_reader2.php';
             $data = new Spreadsheet_Excel_Reader($fileName, true, "UTF-8");
             // khoi tao doi tuong doc file excel
             $rowsnum = $data->rowcount($sheet_index = 0);
             // lay so hang cua sheet
             $colsnum = $data->colcount($sheet_index = 0);
             // lay so cot cua sheet
             for ($i = 2; $i <= $rowsnum; $i++) {
                 // doc tu hang so 2 vi hang 1 la tieu de roi!
                 $phoneNum = $data->val($i, 1);
                 // xuat cot so 1 va cot so 2 tren cung 1 hang
                 // check so dien thoai xem co dung cua Vinaphone ko
                 try {
                     $phoneNum = Formatter::formatPhone($phoneNum);
                     if (Formatter::isVinaphoneNumber($phoneNum)) {
                         $model->phone = "{$phoneNum}";
                         $model->group_id = $group_id;
                         $model->status = 0;
                         $model->created_time = date("Y-m-d H:i:s");
                         var_dump($model->phone);
                         try {
                             if ($model->save()) {
                                 $message = yii::t('SpamModule', 'Upload thành công');
                             } else {
                                 print_r($model->getErrors());
                                 exit;
                             }
                         } catch (Exception $exc) {
                             echo $exc->getTrace();
                         }
                     } else {
                         //echo so dien thoai ko dung
                         $errorList[] = $phoneNum;
                     }
                 } catch (Exception $exc) {
                     echo $exc->getMessage();
                 }
             }
         } catch (Exception $exc) {
             echo $exc->getMessage();
         }
     }
     $uploadModel = new XUploadForm();
     $tmpArr = GroupModel::model()->findAll();
     $smsGroup = array();
     foreach ($tmpArr as $smsG) {
         $smsGroup[$smsG->id] = $smsG->name;
     }
     $this->render('create', array('model' => $model, 'uploadModel' => $uploadModel, 'message' => $message, 'smsGroup' => $smsGroup, 'errorList' => $errorList));
 }
コード例 #13
0
ファイル: index.php プロジェクト: omusico/home365
if (mysql_select_db("home365_ios", $useradmin)) {
} else {
    echo "Error selecting database, exited.";
    exit;
}
function null_2_default($string, $default)
{
    return isset($string) && $string != '' ? $string : $default;
}
$current_timestamp = get_GMT(microtime(true));
$current_time = date("Y-m-d H:i:s", $current_timestamp);
$data = new Spreadsheet_Excel_Reader("mls.xls");
$sheet_count = $data->sheetcount();
for ($sheet_index = 0; $sheet_index < $sheet_count; $sheet_index++) {
    $row_count = $data->rowcount($sheet_index);
    $col_count = $data->colcount($sheet_index);
    echo "Sheet:{$sheet_index}<br/>";
    echo "Row Count:" . $row_count . "<br/>";
    echo "Column Count:" . $col_count . "<br/>";
    for ($row_index = 1; $row_index <= $row_count; $row_index++) {
        for ($col_index = 1; $col_index <= $col_count; $col_index++) {
            if ($row_index > 1 && $col_index <= 3) {
                if ($col_index == 1) {
                    $month = $data->val($row_index, $col_index, $sheet_index) === '' ? $month : $data->val($row_index, $col_index, $sheet_index);
                }
                if ($col_index == 2) {
                    $year = $data->val($row_index, $col_index, $sheet_index) === '' ? $year : $data->val($row_index, $col_index, $sheet_index);
                }
                if ($col_index == 3) {
                    $property_type = $data->val($row_index, $col_index, $sheet_index) === '' ? $property_type : $data->val($row_index, $col_index, $sheet_index);
                }
コード例 #14
0
            $data[$keys[$col]] = $book->val($row, $col);
        }
    }
    $data['rownumber'] = $row;
    print_r($data);
    if ($data['DATE'] != 'DATE' && $data['DATE'] && $data['FLEET NO']) {
        $data['DATE'] = DateTime::createFromFormat('d/m/y', $data['DATE'])->format('Y-m-d');
        scraperwiki::save(array('rownumber'), $data);
    }
}
require_once 'scraperwiki/excel_reader2.php';
$url = "http://www.whatdotheyknow.com/request/82804/response/208592/attach/2/ACCIDENTS%20TRAMS%20Laurderdale.xls";
file_put_contents("/tmp/spreadsheet.xls", scraperWiki::scrape($url));
$book = new Spreadsheet_Excel_Reader("/tmp/spreadsheet.xls");
print $book->rowcount() . "\n";
print $book->colcount() . "\n";
print $book->val(3, 1) . "\n";
print $book->val(3, 'A') . "\n";
for ($col = 1; $col <= $book->colcount(); $col++) {
    print $book->val(3, $col) . ",";
}
$keys = array('dummy');
for ($col = 1; $col <= $book->colcount(); $col++) {
    $keys[] = str_replace(".", "", $book->val(3, $col));
}
print_r($keys);
for ($row = 1; $row <= $book->rowcount(); $row++) {
    for ($col = 1; $col <= $book->colcount(); $col++) {
        if ($keys[$col]) {
            $data[$keys[$col]] = $book->val($row, $col);
        }
コード例 #15
0
ファイル: save.php プロジェクト: hoangnhonline/vinawatch
<div class="row">
	<div class="col-md-12">
		<div class="box-header">
            <h3 class="box-title">Kết quả Import Excel</h3>
        </div><!-- /.box-header -->
<?php 
$arrColumn = array('product_code', 'product_name', 'cate_type_id', 'cate_id', 'trangthai', 'price', 'price_saleoff', 'deal_amount', 'start_date', 'end_date', 'da_ban', 'meta_title', 'meta_description', 'meta_keyword');
require_once 'controller/ExcelReader.php';
$dataArr = array();
if ($_FILES['file']['tmp_name']) {
    $data = new Spreadsheet_Excel_Reader($_FILES['file']['tmp_name'], true, "UTF-8");
    $numCol = $data->colcount();
    $rowCol = $data->rowcount();
    for ($j = 1; $j <= $numCol; $j++) {
        for ($i = 2; $i <= $rowCol; $i++) {
            $dataArr[$arrColumn[$j - 1]][] = $data->val($i, $j);
        }
    }
}
if (!empty($dataArr)) {
    $count = count($dataArr['product_code']);
    for ($k = 0; $k <= $count; $k++) {
        foreach ($arrColumn as $value) {
            $dataInsert[$value] = $dataArr[$value][$k];
            $dataInsert['name_en'] = $model->stripUnicode($dataArr['product_name'][$k]);
            $dataInsert['product_alias'] = $model->changeTitle($dataArr['product_name'][$k]);
            $id = $model->getProductIdByCode($dataArr['product_code'][$k]);
            if ($id > 0) {
                $dataInsert['id'] = $id;
            }
        }
コード例 #16
0
        if ($keys[$col]) {
            $data[$keys[$col]] = $book->val($row, $col);
        }
    }
    $data['rownumber'] = $row;
    print_r($data);
    if ($data['DATE'] != 'DATE' && $data['DATE'] && $data['FLEET NO']) {
        $data['DATE'] = DateTime::createFromFormat('d/m/y', $data['DATE'])->format('Y-m-d');
        scraperwiki::save(array('rownumber'), $data);
    }
}
require_once 'scraperwiki/excel_reader2.php';
$url = "http://www.whatdotheyknow.com/request/82804/response/208592/attach/2/ACCIDENTS%20TRAMS%20Laurderdale.xls";
file_put_contents("/tmp/spreadsheet.xls", scraperWiki::scrape($url));
$book = new Spreadsheet_Excel_Reader("/tmp/spreadsheet.xls");
for ($col = 1; $col <= $book->colcount(); $col++) {
    print $book->val(3, $col) . ",";
}
$keys = array('dummy');
for ($col = 1; $col <= $book->colcount(); $col++) {
    $keys[] = str_replace(".", "", $book->val(3, $col));
}
print_r($keys);
for ($row = 1; $row <= $book->rowcount(); $row++) {
    for ($col = 1; $col <= $book->colcount(); $col++) {
        if ($keys[$col]) {
            $data[$keys[$col]] = $book->val($row, $col);
        }
    }
    $data['rownumber'] = $row;
    print_r($data);
コード例 #17
0
ファイル: example.php プロジェクト: judiel23/-sc
<?php

error_reporting(E_ALL ^ E_NOTICE);
require_once 'excel_reader2.php';
require_once '../../modelo/conexion.php';
$con = new Connex();
$data = new Spreadsheet_Excel_Reader("tw.xls");
for ($i = 1; $i <= $data->colcount(); $i++) {
    //for ($j=0; $j< $data->rowcount(); $j++) {
    # code...
    $col = $data->val(1, $i) . ',';
    //$query="ALTER TABLE twitter_temp ADD ".$col."  varchar(200)";
    //$c=$con->query($query);
    //}
    //$c=$con->query($query);
}
$query = "insert into twitter_temp ('{$col}') values('{$col}')";
?>

コード例 #18
0
						<td style="text-align: right;">Lista Colonne:</td>
						<td>
							<input name="col_list" type="text"
								value="<?php 
if ($_POST['col_list']) {
    echo $_POST['col_list'];
}
?>
" />
								
								<?php 
if (isset($data)) {
    ?>
 
									<label>Colonne totali: <?php 
    echo $data->colcount($_POST['sheet']);
    ?>
</label>
								<?php 
}
?>
						</td>
					</tr>

					<tr>
						<td style="text-align: right;">Offset Iniziale:</td>
						<td>
							<input name="top_offset" type="text"
								value="<?php 
if ($_POST['top_offset']) {
    echo $_POST['top_offset'];
コード例 #19
0
ファイル: actions.class.php プロジェクト: noikiy/qdpm
 public function executeXlsTasksImport(sfWebRequest $request)
 {
     app::setPageTitle('Import Spreadsheet', $this->getResponse());
     if ($request->isMethod(sfRequest::PUT)) {
         if ($request->hasParameter('import_file')) {
             if (is_file($import_spreadsheet_file = sfConfig::get('sf_upload_dir') . '/' . $request->getParameter('import_file'))) {
                 $import_fields = $this->getUser()->getAttribute('import_fields');
                 $data = new Spreadsheet_Excel_Reader($import_spreadsheet_file);
                 $projects_id = $request->getParameter('projects_id');
                 if ($request->getParameter('import_first_row') == 1) {
                     $first_row = 1;
                 } elseif ($data->rowcount() > 2) {
                     $first_row = 2;
                 } else {
                     $first_row = 1;
                 }
                 for ($i = $first_row; $i <= $data->rowcount(); $i++) {
                     $t = new Tasks();
                     $t->setCreatedBy($this->getUser()->getAttribute('id'))->setCreatedAt(date('Y-m-d H:i:s'))->setProjectsId($request->getParameter('projects_id'));
                     $extra_fields = array();
                     for ($j = 1; $j <= $data->colcount(); $j++) {
                         if (isset($import_fields[$j])) {
                             $v = $data->val($i, $j);
                             if (strlen(trim($v)) == 0) {
                                 continue;
                             }
                             switch ($import_fields[$j]) {
                                 case 'TasksGroups':
                                     if ($id = app::getProjectCfgItemIdByName($v, 'TasksGroups', $projects_id)) {
                                         $t->setTasksGroupsId($id);
                                     } else {
                                         $cfg = new TasksGroups();
                                         $cfg->setName($v);
                                         $cfg->setProjectsId($projects_id);
                                         $cfg->save();
                                         $t->setTasksGroupsId($cfg->getId());
                                     }
                                     break;
                                 case 'Versions':
                                     if ($id = app::getProjectCfgItemIdByName($v, 'Versions', $projects_id)) {
                                         $t->setVersionsId($id);
                                     } else {
                                         $cfg = new Versions();
                                         $cfg->setName($v);
                                         $cfg->setProjectsId($projects_id);
                                         $cfg->save();
                                         $t->setVersionsId($cfg->getId());
                                     }
                                     break;
                                 case 'ProjectsPhases':
                                     if ($id = app::getProjectCfgItemIdByName($v, 'ProjectsPhases', $projects_id)) {
                                         $t->setProjectsPhasesId($id);
                                     } else {
                                         $cfg = new ProjectsPhases();
                                         $cfg->setName($v);
                                         $cfg->setProjectsId($projects_id);
                                         $cfg->save();
                                         $t->setProjectsPhasesId($cfg->getId());
                                     }
                                     break;
                                 case 'TasksPriority':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksPriority')) {
                                         $t->setTasksPriorityId($id);
                                     } else {
                                         $cfg = new TasksPriority();
                                         $cfg->setName($v);
                                         $cfg->save();
                                         $t->setTasksPriorityId($cfg->getId());
                                     }
                                     break;
                                 case 'TasksLabels':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksLabels')) {
                                         $t->setTasksLabelId($id);
                                     } else {
                                         $cfg = new TasksLabels();
                                         $cfg->setName($v);
                                         $cfg->save();
                                         $t->setTasksLabelId($cfg->getId());
                                     }
                                     break;
                                 case 'name':
                                     $t->setName($v);
                                     break;
                                 case 'TasksStatus':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksStatus')) {
                                         $t->setTasksStatusId($id);
                                     } else {
                                         $cfg = new TasksStatus();
                                         $cfg->setName($v);
                                         $cfg->save();
                                         $t->setTasksStatusId($cfg->getId());
                                     }
                                     break;
                                 case 'TasksTypes':
                                     if ($id = app::getCfgItemIdByName($v, 'TasksTypes')) {
                                         $t->setTasksTypeId($id);
                                     } else {
                                         $cfg = new TasksTypes();
                                         $cfg->setName($v);
                                         $cfg->save();
                                         $t->setTasksTypeId($cfg->getId());
                                     }
                                     break;
                                     break;
                                 case 'assigned_to':
                                     $assigned_to = array();
                                     foreach (explode(',', $v) as $n) {
                                         if ($user = Doctrine_Core::getTable('Users')->createQuery()->addWhere('name=?', trim($n))->fetchOne()) {
                                             $assigned_to[] = $user->getId();
                                         }
                                     }
                                     $t->setAssignedTo(implode(',', $assigned_to));
                                     break;
                                 case 'estimated_time':
                                     $t->setEstimatedTime($v);
                                     break;
                                 case 'start_date':
                                     $t->setStartDate(date('Y-m-d', strtotime($v)));
                                     break;
                                 case 'due_date':
                                     $t->setDueDate(date('Y-m-d', strtotime($v)));
                                     break;
                                 case 'progress':
                                     $t->setProgress($v);
                                     break;
                             }
                             if (strstr($import_fields[$j], 'extra_field_')) {
                                 $extra_fields[str_replace('extra_field_', '', $import_fields[$j])] = $v;
                             }
                         }
                     }
                     $t->save();
                     foreach ($extra_fields as $id => $v) {
                         $f = new ExtraFieldsList();
                         $f->setBindId($t->getId());
                         $f->setExtraFieldsId($id);
                         $f->setValue($v);
                         $f->save();
                     }
                 }
                 $this->getUser()->setFlash('userNotices', t::__('Spreadsheet imported'));
                 $this->redirect('tasks/index?projects_id=' . $request->getParameter('projects_id'));
             }
         } elseif (($projects_id = $request->getParameter('projects_id')) > 0) {
             $f = $request->getFiles();
             if ($f['import_file']) {
                 $this->getUser()->setAttribute('import_fields', array());
                 move_uploaded_file($f['import_file']['tmp_name'], sfConfig::get('sf_upload_dir') . '/' . $f['import_file']['name']);
                 $this->import_file = $f['import_file']['name'];
                 if (is_file($import_spreadsheet_file = sfConfig::get('sf_upload_dir') . '/' . $this->import_file)) {
                     $this->data = new Spreadsheet_Excel_Reader($import_spreadsheet_file);
                     $this->setTemplate('xlsTasksImportBind');
                 } else {
                     $this->getUser()->setFlash('userNotices', array('type' => 'error', 'text' => t::__('There is an error with uploading file. Please try again with less file size.')));
                     $this->redirect('tools/xlsTasksImport');
                 }
             }
         }
     }
 }
コード例 #20
0
ファイル: m_grup.php プロジェクト: nickohappy7/sister
		if(isset($_GET['upload'])){
			$tipex    = substr($_FILES[0]['type'],6);
			$namaAwal = $_FILES[0]['name'];
			$namaSkrg = $_SESSION['id_loginS'].'_'.substr((md5($namaAwal.rand())),2,10).'.'.$tipex;
			$src      = $_FILES[0]['tmp_name'];
			$destix   = '../../img/upload/'.basename($namaSkrg);

			if(move_uploaded_file($src, $destix)) $o=array('status'=>'sukses','file'=>$namaSkrg);
			else $o=array('status'=>'gagal');

			$out=json_encode($o);
		}elseif(isset($_GET['import'])){
			$file = $_FILES[0];
			$data 	= new Spreadsheet_Excel_Reader($file['tmp_name']);
			$baris 	= ($data->rowcount($sheet_index=0)-1);
			$kolom	= ($data->colcount($sheet_index=0)-1);
			$sukses = 0;
			$gagal 	= 0;

			$ss='';
			for($i=2; $i<=($baris+1); $i++){
				$barkode    = $data->val($i, 1);
				$nama       = $data->val($i, 2);
				$tempat     = $data->val($i, 3);
				$kondisi    = $data->val($i, 4);
				$sumber     = $data->val($i, 5);
				$harga      = $data->val($i, 6);
				$keterangan = $data->val($i, 7);

				// get katalog id
				$sk = 'SELECT replid idkatalog from sar_katalog where nama ="'.$nama.'"';
コード例 #21
0
          <p style="float: left; "><img src="images/logo1.gif" style="position:absolute; left:340px" height="70px" width="70px" border="1px"></p>
          </div>
          <p><h5>Rashtreeya Sikshana Samithi Trust</h5></p>
          <p><h4><b>R V College of Engineering</b></h4></p>
          <p><h6>Mysore Road, RV Vidyaniketan Post, Bagalore - 560 059</h6></p>
          </center>
        </div>
        <hr>

        <div class="box"><center><!DOCTYPE html>
<?php 
require_once 'excel_reader2.php';
$file = $_POST['file'];
$data = new Spreadsheet_Excel_Reader($file);
$row = $data->rowcount($sheet_index = 0);
$col = $data->colcount($sheet_index = 0);
require_once __DIR__ . '/db_connect.php';
$db = new DB_CONNECT();
$acy = $_POST['acy'];
$sem = $_POST['sem'];
$dept = $_POST['dept'];
$sub = $_POST['sub'];
$course = $_POST['course'];
$query = "SELECT S_Code from syllabus where sem='" . $sem . "' and \n\t\t(Host_Dpt='" . $dept . "' or Host_Dpt='HSS') and acy='" . $acy . "' \n\t\tand S_type='" . $course . "' and Name='" . $sub . "'";
$result = mysql_query($query);
$ccode = '';
while ($res = mysql_fetch_array($result)) {
    $ccode = $res['S_Code'];
}
$query = "INSERT INTO `attends`(`susn`, `status`, `cdte`, `ctme`, `ccode`, `acy`, `sem` ) VALUES ";
$i = 2;
コード例 #22
0
ファイル: xls_io_m.php プロジェクト: phonglanpls/jz-proj-2012
 function toDbFB()
 {
     $data = new Spreadsheet_Excel_Reader("./media/fb.xls");
     $rowNumber = $data->rowcount($sheet_index = 0);
     $colNumber = $data->colcount($sheet_index = 0);
     $valueArray = array();
     $j = 0;
     for ($i = 0; $i <= $rowNumber; $i++) {
         if ($id = $data->val($i, 2, $sheet = 0) and $this->phpvalidator->is_url($data->val($i, 6, $sheet = 0))) {
             $j += 1;
             $valueArray[$j]['ID'][] = $id;
         }
         if ($seriesName = $data->val($i, 3, $sheet = 0) and $this->phpvalidator->is_url($data->val($i, 6, $sheet = 0))) {
             $valueArray[$j]['seriesName'][] = $seriesName;
         }
         if ($seriesThumb = $data->val($i, 4, $sheet = 0) and $this->phpvalidator->is_url($data->val($i, 6, $sheet = 0))) {
             $valueArray[$j]['seriesThumb'][] = $seriesThumb;
         }
         if ($episodeName = $data->val($i, 5, $sheet = 0) and $this->phpvalidator->is_url($data->val($i, 6, $sheet = 0))) {
             $valueArray[$j]['episodeName'][] = $episodeName;
         }
         if ($link = $data->val($i, 6, $sheet = 0) and $this->phpvalidator->is_url($data->val($i, 6, $sheet = 0))) {
             $valueArray[$j]['link'][] = $link;
         }
     }
     //var_dump($valueArray);
     foreach ($valueArray as $key => $array) {
         $seriesName = $array['seriesName'][0];
         $seriesdata = array();
         $seriesdata['id_hentai_category'] = 1;
         $seriesdata['code_series'] = NULL;
         $seriesdata['name'] = $seriesName;
         $seriesdata['image'] = NULL;
         //strtolower( str_replace(array(' ','-','_'), array('-','-','-'), $seriesName) );
         $seriesdata['img_url'] = $array['seriesThumb'][0];
         //$this->getThumbnail($array['link'][0]);
         $seriesdata['add_date'] = mysqlDate();
         $seriesdata['last_update'] = mysqlDate();
         $seriesdata['ip'] = $this->geo_lib->getIpAddress();
         $id_series = $this->mod_io_m->insert_map($seriesdata, TBL_SERIES);
         for ($i = 0; $i < count($array['episodeName']); $i++) {
             $episodeName = $array['episodeName'][$i];
             $link = $array['link'][$i];
             $episodedata = array();
             $episodedata['id_series'] = $id_series;
             $episodedata['code_video'] = strtolower(str_replace(array(' ', '-', '_'), array('', '', ''), $episodeName));
             $episodedata['name'] = $episodeName;
             $episodedata['video_url'] = $link;
             $episodedata['img_url'] = $this->getThumbnail($link);
             $episodedata['description'] = NULL;
             $episodedata['rating'] = 0;
             $episodedata['rate_num'] = 0;
             $episodedata['view_count'] = 0;
             $episodedata['add_date'] = mysqlDate();
             $episodedata['last_update'] = mysqlDate();
             $episodedata['ip'] = $this->geo_lib->getIpAddress();
             $this->mod_io_m->insert_map($episodedata, TBL_VIDEO);
         }
     }
 }
コード例 #23
0
ファイル: ReadFile.php プロジェクト: jessesiu/GigaDBV3
 /**
  * Read Excel file
  * 
  * @param string $file_name
  * @return array
  */
 public static function readXlsFile($file_name)
 {
     $excel = new Spreadsheet_Excel_Reader(self::TEMP_FOLDER . $file_name);
     return array($excel->rowcount(), $excel->colcount());
 }
コード例 #24
0
ファイル: lib_xls.php プロジェクト: netcon-source/dotspotting
function xls_parse_fh($fh, $more = array())
{
    loadpear("Spreadsheet/Excel/Reader");
    fclose($fh);
    $xls = new Spreadsheet_Excel_Reader($more['file']['path'], false);
    $rows = $xls->rowcount();
    $cols = $xls->colcount(0);
    if (!$rows || !$cols) {
        return array('ok' => 0, 'error' => 'Unable to locate any rows or columns with data. Perhaps the spreadsheet is old or has been corrupted?');
    }
    $fields = array();
    for ($i = 1; $i < $cols; $i++) {
        $raw = $xls->val(1, $i);
        $fields[] = strtolower($raw);
    }
    #
    $possible_lat = $GLOBALS['cfg']['import_fields_mightbe_latitude'];
    $possible_lon = $GLOBALS['cfg']['import_fields_mightbe_longitude'];
    $lat_field = 'latitude';
    $lon_field = 'longitude';
    if (!in_array($lat_field, $fields)) {
        foreach ($fields as $f) {
            if (in_array($f, $possible_lat)) {
                $lat_field = $f;
                break;
            }
        }
    }
    if (!in_array($lon_field, $fields)) {
        foreach ($fields as $f) {
            if (in_array($f, $possible_lon)) {
                $lon_field = $f;
                break;
            }
        }
    }
    #
    $data = array();
    $errors = array();
    $record = 0;
    for ($i = 2; $i < $rows; $i++) {
        $record++;
        if ($more['max_records'] && $record > $more['max_records']) {
            break;
        }
        $tmp = array();
        for ($j = 1; $j < $cols; $j++) {
            $label = $fields[$j - 1];
            $value = $xls->val($i, $j);
            if ($label == $lat_field) {
                if (!geo_utils_is_valid_latitude($value)) {
                    $errors[] = array('record' => $record, 'error' => 'invalid latitude', 'column' => 'latitude');
                    continue;
                }
                $label = 'latitude';
            }
            if ($label == $lon_field) {
                if (!geo_utils_is_valid_longitude($value)) {
                    $errors[] = array('record' => $record, 'error' => 'invalid longitude', 'column' => 'longitude');
                    continue;
                }
                $label = 'longitude';
            }
            # TO DO : dates and times (they seem to be always be weird)
            $tmp[$label] = import_scrub($value);
        }
        $data[] = $tmp;
    }
    return array('ok' => 1, 'data' => &$data, 'errors' => &$errors);
}
コード例 #25
0
ファイル: example.php プロジェクト: starvagrant/address-api
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if (!$mysqli->query("DELETE FROM jd_wp")) {
    die("Table delete failed: (" . $mysqli->errno . ") " . $mysqli->error);
}
/* Prepared statement, stage 1: prepare */
if (!($stmt = $mysqli->prepare("INSERT INTO jd_wp (`jrd_1`, `jrd_sheet`, `order`, `st_num`, `street`, `jrd_block`, `jrd_address`, `short_own`, `absentee_owner`, `kiva_pin`, `county_apn_link`, `sub_division`, `block`, `lot`, `owner`, `owner_2`, `owner_address`, `owner_city_zip`, `site_address`, `zip_code`, `council_district`, `trash_day`, `school_distrct`, `census_neigh_borhood`, `park_region`, `pw_maintenance_district`, `zoning`, `land_use`, `blvd_front_footage`, `effective_date`, `assessed_land`, `assessed_improve`, `exempt_land`, `exempt_improve`, `square_feet`, `acres`, `perimeter`, `year_built`, `living_area`, `tax_neighborhood_code`, `parcel_area_sf`, `propert_class_pca_code`, `landuse_type`, `market_value`, `taxabl_evalue`, `assessed_value`, `tax_status`, `legal_description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))) {
    die("Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error);
}
if (!$stmt->bind_param('ssssssssssssssssssssssssssssssssssssssssssssssss', $v[1], $v[2], $v[3], $v[4], $v[5], $v[6], $v[7], $v[8], $v[9], $v[10], $v[11], $v[12], $v[13], $v[14], $v[15], $v[16], $v[17], $v[18], $v[19], $v[20], $v[21], $v[22], $v[23], $v[24], $v[25], $v[26], $v[27], $v[28], $v[29], $v[30], $v[31], $v[32], $v[33], $v[34], $v[35], $v[36], $v[37], $v[38], $v[39], $v[40], $v[41], $v[42], $v[43], $v[44], $v[45], $v[46], $v[47], $v[48])) {
    die("Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error);
}
$data = new Spreadsheet_Excel_Reader("wp.xls");
$num_rows = $data->rowcount($sheet_index = 0);
$num_cols = $data->colcount($sheet_index = 0);
print "{$num_rows},{$num_cols}\n\n";
$types = '';
$vars = '';
for ($r = 2; $r < $num_rows; $r++) {
    print "row={$r} \n";
    for ($i = 1; $i < $num_cols; $i++) {
        $v[$i] = $data->val($r, $i);
        print "\$v[{$i}] = |" . $v[$i] . "|\n";
    }
    $v[48] = substr($v[48], 0, 200);
    $v[28] = substr($v[28], 0, 5);
    if (!$stmt->execute()) {
        die("Execute failed: (" . $stmt->errno . ") " . $stmt->error);
    }
}
コード例 #26
0
<?php

require_once 'scraperwiki/excel_reader2.php';
$url = "http://www.ec.gov.gh/page.php?page=469&section=49&typ=1";
file_put_contents("/tmp/spreadsheet.xls", scraperWiki::scrape($url));
$book = new Spreadsheet_Excel_Reader("/tmp/spreadsheet.xls");
print $book->rowcount() . "\n";
print $book->colcount() . "\n";
require_once 'scraperwiki/excel_reader2.php';
$url = "http://www.ec.gov.gh/page.php?page=469&section=49&typ=1";
file_put_contents("/tmp/spreadsheet.xls", scraperWiki::scrape($url));
$book = new Spreadsheet_Excel_Reader("/tmp/spreadsheet.xls");
print $book->rowcount() . "\n";
print $book->colcount() . "\n";
コード例 #27
0
 /**
  * Import records from Excel file
  *
  * @param      $file
  * @param bool $simulate
  */
 private function importRecords($file, $simulate = false)
 {
     global $ilUser, $lng;
     include_once "./Modules/DataCollection/libs/ExcelReader/excel_reader2.php";
     $warnings = array();
     try {
         $excel = new Spreadsheet_Excel_Reader($file);
     } catch (Exception $e) {
         $warnings[] = $lng->txt("dcl_file_not_readable");
     }
     if (count($warnings)) {
         $this->endImport(0, $warnings);
         return;
     }
     $field_names = array();
     for ($i = 1; $i <= $excel->colcount(); $i++) {
         $field_names[$i] = $excel->val(1, $i);
     }
     $fields = $this->getImportFieldsFromTitles($field_names, $warnings);
     for ($i = 2; $i <= $excel->rowcount(); $i++) {
         $record = new ilDataCollectionRecord();
         $record->setTableId($this->table_obj->getId());
         $record->setOwner($ilUser->getId());
         $date_obj = new ilDateTime(time(), IL_CAL_UNIX);
         $record->setCreateDate($date_obj->get(IL_CAL_DATETIME));
         $record->setTableId($this->table_id);
         if (!$simulate) {
             $record->doCreate();
         }
         foreach ($fields as $col => $field) {
             $value = $excel->val($i, $col);
             $value = utf8_encode($value);
             try {
                 if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_REFERENCE) {
                     $old = $value;
                     $value = $this->getReferenceFromValue($field, $value);
                     if (!$value) {
                         $warnings[] = "(" . $i . ", " . $this->getExcelCharForInteger($col) . ") " . $lng->txt("dcl_no_such_reference") . " " . $old;
                     }
                 } else {
                     if ($field->getDatatypeId() == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
                         $value = array('date' => date('Y-m-d', strtotime($value)), 'time' => '00:00:00');
                     }
                 }
                 $field->checkValidity($value, $record->getId());
                 if (!$simulate) {
                     $record->setRecordFieldValue($field->getId(), $value);
                 }
             } catch (ilDataCollectionInputException $e) {
                 $warnings[] = "(" . $i . ", " . $this->getExcelCharForInteger($col) . ") " . $e;
             }
         }
         if (!$simulate) {
             $record->doUpdate();
         }
         if ($i - 1 > $this->max_imports) {
             $warnings[] = $lng->txt("dcl_max_import") . ($excel->rowcount() - 1) . " > " . $this->max_imports;
             break;
         }
     }
     $this->endImport($i - 2, $warnings);
 }
コード例 #28
0
ファイル: example.php プロジェクト: anasswoow/coba
	}
}
</script>
</head>
<body>

Display formatting information: <input type="checkbox" onclick="toggle(this.checked)">
<br><br>

<table border="1">
<?php 
for ($row = 1; $row <= $xls->rowcount(); $row++) {
    ?>
	<tr>
	<?php 
    for ($col = 1; $col <= $xls->colcount(); $col++) {
        ?>
		<td><?php 
        echo $xls->val($row, $col);
        ?>
&nbsp;
		<div><br>Format=<?php 
        echo $xls->format($row, $col);
        ?>
<br>FormatIndex=<?php 
        echo $xls->formatIndex($row, $col);
        ?>
<br>Raw=<?php 
        echo $xls->raw($row, $col);
        ?>
</div></td>