<?php
include_once('./_common.php');
include_once(G5_PATH.'/head.sub.php');
include_once(G5_BBS_PATH.'/admin_head.php');
$g5['title'] = "엑셀 업로드";
?>
<style>
.new_excel{border:3px solid #ccc; padding:0 20px 20px 20px; margin-top:20px;}
.new_excel h1{margin:10px 0;}
.excel_info {margin-bottom:10px; line-height:18px;}
.btn_confirm {margin-top:15px;}
</style>
<div class="new_excel">
<h1><?php echo $g5['title']?></h1>
<div class="excel_info">
<p>
<a href="<?php echo $board_skin_url?>/0_hs_excel_0.xls">신규등록 엑셀파일 샘플 다운로드 Click</a>.
</p>
</div>
<form name="fitemexcelup" id="fitemexcelup" method="post" action="./excel_up2.php" enctype="MULTIPART/FORM-DATA" autocomplete="off">
<input type="hidden" name="ca_name" value="<?php echo $_GET['ct']?>">
<div id="excelfile_upload" style="text-align:center;">
<input type="file" name="excelfile" id="excelfile">
</div>
<div class="btn_confirm01 btn_confirm">
<input type="submit" value="엑셀파일 등록" class="btn_submit">
</div>
</form>
</div>
//excel_up2.php
<?php
include_once('./_common.php');
// 상품이 많을 경우 대비 설정변경
set_time_limit ( 0 );
ini_set('memory_limit', '50M');
if(!$_FILES['excelfile']['tmp_name']) {
alert("등록하실 파일이 없습니다");
}
if($_FILES['excelfile']['tmp_name']) {
$file = $_FILES['excelfile']['tmp_name'];
include_once(G5_LIB_PATH.'/Excel/reader.php');
$data = new Spreadsheet_Excel_Reader();
// Set output Encoding.
$data->setOutputEncoding('UTF-8');
/***
* if you want you can change 'iconv' to mb_convert_encoding:
* $data->setUTFEncoder('mb');
*
**/
/***
* By default rows & cols indeces start with 1
* For change initial index use:
* $data->setRowColOffset(0);
*
**/
/***
* Some function for formatting output.
* $data->setDefaultFormat('%.2f');
* setDefaultFormat - set format for columns with unknown formatting
*
* $data->setColumnFormat(4, '%.3f');
* setColumnFormat - set format for column (apply only to number fields)
*
**/
$data->read($file);
/*
$data->sheets[0]['numRows'] - count rows
$data->sheets[0]['numCols'] - count columns
$data->sheets[0]['cells'][$i][$j] - data from $i-row $j-column
$data->sheets[0]['cellsInfo'][$i][$j] - extended info about cell
$data->sheets[0]['cellsInfo'][$i][$j]['type'] = "date" | "number" | "unknown"
if 'type' == "unknown" - use 'raw' value, because cell contain value with format '0.00';
$data->sheets[0]['cellsInfo'][$i][$j]['raw'] = value if cell without format
$data->sheets[0]['cellsInfo'][$i][$j]['colspan']
$data->sheets[0]['cellsInfo'][$i][$j]['rowspan']
*/
error_reporting(E_ALL ^ E_NOTICE);
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) { //$i == 몇번째 라인부터 등록할건지
$total_count++;
$mb_id = $member['mb_id'];
$ca_name = $_POST['ca_name']; //발급번호
$wr_no = addslashes($data->sheets[0]['cells'][$i][1]); //분류
$wr_bf = addslashes($data->sheets[0]['cells'][$i][2]); //품목 BF
$wr_sf = addslashes($data->sheets[0]['cells'][$i][3]); //품목 SF
$wr_mc = addslashes($data->sheets[0]['cells'][$i][4]); //품목 MC
$wr_gb = addslashes($data->sheets[0]['cells'][$i][5]); //품목 GB
$wr_level = addslashes($data->sheets[0]['cells'][$i][6]); //등급
$wr_1 = addslashes($data->sheets[0]['cells'][$i][7]); //열관류율
$wr_2 = addslashes($data->sheets[0]['cells'][$i][8]); //기밀성
$wr_3 = addslashes($data->sheets[0]['cells'][$i][9]); //유리사항 내부
$wr_4 = addslashes($data->sheets[0]['cells'][$i][10]); //유리사항 외부
$wr_5 = addslashes($data->sheets[0]['cells'][$i][11]); //비고
$sql = " insert into wr_down
set wr_no = '$wr_no',
ca_name = '$ca_name',
wr_bf = '$wr_bf',
wr_sf = '$wr_sf',
wr_mc = '$wr_mc',
wr_gb = '$wr_gb',
wr_level = '$wr_level',
wr_1 = '$wr_1',
wr_2 = '$wr_2',
wr_3 = '$wr_3',
wr_4 = '$wr_4',
wr_5 = '$wr_5',
mb_id = '$mb_id',
wr_datetime = '".G5_TIME_YMDHIS."'";
sql_query($sql);
$wr_id = sql_insert_id();
}//for end
alert("업로드 되었습니다","/bbs/admin.php?mode=wr_down&type=list&ct=$ca_name");
}
?>