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);//
只需要新增這個方法實現**資料格式轉換
$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
)
$list_aray=$cell_values
; }
}
phpexcel匯入excel資料
public function importexcel file phpexcel phpreader load file 載入excel物件 sheet phpexcel getsheet 0 獲取指定的sheet表 rows sheet gethighestrow 行數 cols sheet g...
PHPExcel類匯入Excel用法
if post leadexcel true 匯入excel檔案 function uploadfile file,filetempname echo str die explode 函式把字串分割為陣列。strs explode str sql insert into te 1 2 3 4 5 v...
phpexcel匯入excel處理大資料
header content type text html charset utf 8 設定頁面編碼 require once phpexcel.class.php 引入檔案 require once phpexcel iofactory.php 引入檔案 require once phpexcel...