관리자페이지에서 엑셀파일 올리기 정보
관리자페이지에서 엑셀파일 올리기본문
스킨은 basic 이구요
관리자모드(도메인/adm) 특정페이지에서 csv파일이나 txt파일을 업로드 해서
자동으로 데이타베이스에 넣게 하고 싶은데
어떤 방법으로 해야될까요??
초보라 ㅠㅠ 질문이 좀 막연하긴 하지만 도와주세요 부탁드립니다
관리자모드(도메인/adm) 특정페이지에서 csv파일이나 txt파일을 업로드 해서
자동으로 데이타베이스에 넣게 하고 싶은데
어떤 방법으로 해야될까요??
초보라 ㅠㅠ 질문이 좀 막연하긴 하지만 도와주세요 부탁드립니다
댓글 전체

<?
$sub_menu = "400100";
include_once("./_common.php");
$g4[title] = "업직종 일괄 업로드";
include_once ("$g4[admin_path]/admin.head.php");
$xls_file = "./Excel/excel.xls";
$today = date('Ymd');
?>
<?
if (file_exists($xls_file)){
require_once './Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
// 여기 이부분에서 euc-kr 을 넣어 주면 한글을 이용할 수 있다.
$data->setOutputEncoding('utf-8');
$data->read($xls_dir.$xls_file);
//error_reporting(E_ALL ^ E_NOTICE);
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
// re data setting start
$code = $data->sheets[0]['cells'][$i][1];
$name = $data->sheets[0]['cells'][$i][2];
// re data setting end
if($code){
if(!eregi("-", $code)){ // 대매뉴인지 분류
$query = "INSERT INTO g4_sector VALUES('', '{$code}', '{$name}', '업직종', '', 'in');";
sql_query($query);
echo "<font color='red'>\"{$name}\"</font> 덤프완료</br>";
echo $query."<br>";
}else{ //중소분류
$query = "INSERT INTO g4_sector VALUES('', '{$code}', '{$name}', '업직종', '', '');";
sql_query($query);
echo "\"{$name}\" <font color='red'>덤프완료</font></br>";
echo $query."<br>";
}
}
} // for end
}else{
echo "<p><font color='red'><b>XLS 파일이 없습니다.</b></font>";
}
?>
<?
include_once ("$g4[admin_path]/admin.tail.php");
?>
$sub_menu = "400100";
include_once("./_common.php");
$g4[title] = "업직종 일괄 업로드";
include_once ("$g4[admin_path]/admin.head.php");
$xls_file = "./Excel/excel.xls";
$today = date('Ymd');
?>
<?
if (file_exists($xls_file)){
require_once './Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
// 여기 이부분에서 euc-kr 을 넣어 주면 한글을 이용할 수 있다.
$data->setOutputEncoding('utf-8');
$data->read($xls_dir.$xls_file);
//error_reporting(E_ALL ^ E_NOTICE);
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
// re data setting start
$code = $data->sheets[0]['cells'][$i][1];
$name = $data->sheets[0]['cells'][$i][2];
// re data setting end
if($code){
if(!eregi("-", $code)){ // 대매뉴인지 분류
$query = "INSERT INTO g4_sector VALUES('', '{$code}', '{$name}', '업직종', '', 'in');";
sql_query($query);
echo "<font color='red'>\"{$name}\"</font> 덤프완료</br>";
echo $query."<br>";
}else{ //중소분류
$query = "INSERT INTO g4_sector VALUES('', '{$code}', '{$name}', '업직종', '', '');";
sql_query($query);
echo "\"{$name}\" <font color='red'>덤프완료</font></br>";
echo $query."<br>";
}
}
} // for end
}else{
echo "<p><font color='red'><b>XLS 파일이 없습니다.</b></font>";
}
?>
<?
include_once ("$g4[admin_path]/admin.tail.php");
?>

위에 있는 소스는 예제구요.
oleread.inc 라고 검색하면 관련 php 모듈 찾을수 있습니다.
oleread.inc 라고 검색하면 관련 php 모듈 찾을수 있습니다.
답변 감사합니다~ 하다가 모르는거 있으면 쪽지 보내도 될까요;;;