欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

phpexcel導入excel處理大數(shù)據(jù)(實例講解)

 更新時間:2017年08月22日 09:23:54   投稿:jingxian  
下面小編就為大家?guī)硪黄猵hpexcel導入excel處理大數(shù)據(jù)(實例講解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

先下載對應phpExcel 的包就行了https://github.com/PHPOffice/PHPExcel

下載完成 把那個Classes 這個文件夾里面的 文件跟文件夾拿出來就好了。

直接寫到PHPExcel 這個文件里面的。調(diào)用很簡單。引入phpExcel 這個類傳遞對應的excel 文件的路徑就好了

現(xiàn)在上傳到指定的目錄,然后加載上傳的excel文件讀取這里讀取是的時候不轉(zhuǎn)換數(shù)組了。注意:是Sheet可以多個讀取,php上傳值要設置大,上傳超時要設置長。

header('Content-type: text/html; charset=utf-8'); //設置頁面編碼
require_once 'phpexcel.class.php'; //引入文件
require_once 'PHPExcel/IOFactory.php'; //引入文件
require_once 'PHPExcel/Reader/Excel2007.php'; //引入文件
$uploadfile = $_FILES['select_file']['tmp_name'];  //獲取上傳文件
$auid = $_SESSION['auid'];
$date = date('Ymd');
$rand = rand(1,9999);
$_month=str_replace('-','',$date);
$file_name = str_pad($auid, 4, 0, STR_PAD_LEFT).$date.str_pad($rand, 4, 0, STR_PAD_LEFT).'.xlsx';
$path_file = '../data/upload/file/'.$file_name; //上傳文件目錄指定
move_uploaded_file($uploadfile, $path_file); //文件上傳

$inputFileType = PHPExcel_IOFactory::identify($path_file);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);//只需要添加這個方法實現(xiàn)表格數(shù)據(jù)格式轉(zhuǎn)換
$objPHPExcel = $objReader->load($path_file);

$sheet_read_arr = array();
$sheet_read_arr["表1"] = array("B","C");
$sheet_read_arr["表2"] = array("B","C");
$sheet_read_arr["表3"] = array("B","C");
$list_aray=array();
foreach ($sheet_read_arr as $key => $val){
 $currentSheet = $objPHPExcel->getSheetByName($key);
 $row_num = $currentSheet->getHighestRow();
 for ($i = 6; $i <= $row_num; $i++){
  $cell_values = array();
  foreach ($val as $cell_val){
   $address = $cell_val . $i;// 單元格坐標
   $cell_values[] = $currentSheet->getCell($address)->getFormattedValue();
  }
  $list_aray[]=$cell_values;
 }
}

以上這篇phpexcel導入excel處理大數(shù)據(jù)(實例講解)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論