亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

先下載對(duì)應(yīng)phpExcel 的包就行了https://github.com/PHPOffice/PHPExcel

下載完成 把那個(gè)Classes 這個(gè)文件夾里面的 文件跟文件夾拿出來(lái)就好了。

直接寫到PHPExcel 這個(gè)文件里面的。調(diào)用很簡(jiǎn)單。引入phpExcel 這個(gè)類傳遞對(duì)應(yīng)的excel 文件的路徑就好了

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

header('Content-type: text/html; charset=utf-8'); //設(shè)置頁(yè)面編碼
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);//只需要添加這個(gè)方法實(shí)現(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;// 單元格坐標(biāo)
   $cell_values[] = $currentSheet->getCell($address)->getFormattedValue();
  }
  $list_aray[]=$cell_values;
 }
}

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

相關(guān)文章

最新評(píng)論