<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<body>
#<? php
$r1r = implode(",",$_POST['ypname']);
$r2r = implode(",",$_POST['guige'] );
$r3r = implode(",",$_POST['shengcan']);
$r4r = implode(",",$_POST['danwei']);
$r5r = implode(",",$_POST['pihao']);
$r6r = implode(",",$_POST['bz']);
$r7r = implode(",",$_POST['rq']);
$r8r = implode(",",$_POST['djlx']);
#$r9r = implode(",",$_POST['rk']);
$rwr = implode(",",$_POST['ch']);
$data2 = array_merge($r1r,$r2r);
var_dump ($data2);
/**
* 資料匯出
* @param array $title 標題行名稱
* @param array $data 匯出資料
* @param string $fileName檔案名稱
* @param string $savePath 儲存路徑
* @param $type 是否下載 false--儲存 true--下載
* @return string 返回檔案全路徑
* @throws PHPExcel_Exception
* @throws PHPExcel_Reader_Exception
# */
$title = array("商品名稱","規格","廠商","單位","批號","備註","日期","單據類型","入庫數量","出貨物數量");
$type = true;
$data = r1r;
$fileName = 'bflxexc';
#function exportExcel($title=array(), $data=array(), $fileName='', $savePath='./', $isDown=false){
# include('PHPExcel. php');
$obj = new PHPExcel();
//橫向儲存格識別
$cellName = array('A' , 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', ' N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' , 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', ' AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY' , 'AZ');
$obj->getActiveSheet(0)->setTitle('bflx'); //設定sheet名稱
$_row = 1; //設定縱向儲存格識別碼
if($title){
$_cnt = count($title);
$obj->getActiveSheet(0)->mergeCells('A'.$_row.':'.$cellName[$_cnt-1].$_row); //合併儲存格
# $obj->setActiveSheetIndex(0)->setCellValue('A'.$_row, '$r1r'.date('Y-m-d H:i:s')); //設定合併後的儲存格內容
$_row ;
$i = 0;
foreach($title AS $v){ //設定列標題
$obj-> ;setActiveSheetIndex(0)->setCellValue($cellName[$i].$_row, $v);
$i ;
}
# $_row ;
}
//填入資料
if($data){
$i = 0;
foreach($data AS $_v){
$j = 0;
foreach($_v AS $_cell){
$obj->getActiveSheet(0 )->setCellValue($cellName[$j] . ($i $_row), $_cell);
$j ;
}
## $i ; } } //檔名處理 if(!$fileName){ $ fileName = uniqid(time(),true); } $objWrite = PHPExcel_IOFactory::createWriter($obj, 'Excel2007');。 ##
if($isDown){ //網頁下載
header('pragma:public');
header("Content-Disposition:attachment;filename= $fileName.xls");
$objWrite->save('php://output');exit;
## } # $_fileName = iconv("utf-8", "gb2312", $fileName); //轉碼 $_savePath = $savePath.$_fileName.'.xlsx';###### $ objWrite->save($_savePath);###### ####### return $savePath.$fileName.'.xlsx';#######} #######//exportExcel###//exportExcel (array('姓名','年齡'), array(array('a',21),array('b',23)), '檔案', './', true);###### # ?>###### ###### </body>###### <?php####### ?>######//陣列還沒有轉換,但是為什麼沒有提示下載的? ###