/adm/shop_admin/itemlist.php 소스추가
<a href="#" class='btn_excel' style="background:green;color:#fff; padding:5px 10px; border-radius:5px;">엑셀 다운로드</a>
<script>
$('body').on('click', '.btn_excel', function(event) {
event.preventDefault();
var f = $('#fitemlistupdate')[0];
f.action = './itemlist_excel.php';
f.submit();
f.action = '';
return false;
});
</script>
/adm/shop_admin/itemlist_excel.php 파일추가
<?php
include_once('./_common.php');
auth_check($auth[$sub_menu], 'r');
$referer = parse_url ( $_SERVER['HTTP_REFERER'] ) ;
parse_str( $referer['query'], $output);
foreach ($output as $key => $value) {
${$key} = $value;
}
$sql_common = " from {$g5['g5_shop_item_table']} a ,
{$g5['g5_shop_category_table']} b
where (a.ca_id = b.ca_id";
if ($is_admin != 'super')
$sql_common .= " and b.ca_mb_id = '{$member['mb_id']}'";
$sql_common .= ") ";
$sql_common .= $sql_search;
$sql = " SELECT * FROM g5_shop_item";
$result = sql_query($sql);
/* ================================= */
$type = 'csv'; // comma-separated values, text 코마 구분 값 포맷의 파일
/* ================================= */
$file_alias ="itemlist_".date('Ymd').".{$type}";
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
Header('Content-Disposition: attachment; filename=' . $file_alias);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Pragma: no-cache');
Header('Expires: 0');
/* ================================= */
$filedName = array(
"분류",
"상품코드",
"상품명",
"기본설명"
);
$prtPattern = "";
foreach($filedName as $val ) {
$prtPattern .= ',"%s"';
}
$prtPattern = substr($prtPattern, 1)."\r\n";
echo "\xEF\xBB\xBF";
vprintf($prtPattern, $filedName );
$filedValues = array(
preg_replace('/[\"]/', '""', $row['ca_id'])
,preg_replace('/[\"]/', '""', $row['it_id'])
,preg_replace('/[\"]/', '""', $row['it_name'])
,preg_replace('/[\"]/', '""', $row['it_basic'])
);
vprintf($prtPattern, $filedValues );
?>
개발한것 제외하느라 정상작동할진 모르겠네요 필요하신 분 쓰세용
팁자료실에 없어서 만드느라 힘들었네요 ㅠㅠ
<a href="#" class='btn_excel' style="background:green;color:#fff; padding:5px 10px; border-radius:5px;">엑셀 다운로드</a>
<script>
$('body').on('click', '.btn_excel', function(event) {
event.preventDefault();
var f = $('#fitemlistupdate')[0];
f.action = './itemlist_excel.php';
f.submit();
f.action = '';
return false;
});
</script>
/adm/shop_admin/itemlist_excel.php 파일추가
<?php
include_once('./_common.php');
auth_check($auth[$sub_menu], 'r');
$referer = parse_url ( $_SERVER['HTTP_REFERER'] ) ;
parse_str( $referer['query'], $output);
foreach ($output as $key => $value) {
${$key} = $value;
}
$sql_common = " from {$g5['g5_shop_item_table']} a ,
{$g5['g5_shop_category_table']} b
where (a.ca_id = b.ca_id";
if ($is_admin != 'super')
$sql_common .= " and b.ca_mb_id = '{$member['mb_id']}'";
$sql_common .= ") ";
$sql_common .= $sql_search;
$sql = " SELECT * FROM g5_shop_item";
$result = sql_query($sql);
/* ================================= */
$type = 'csv'; // comma-separated values, text 코마 구분 값 포맷의 파일
/* ================================= */
$file_alias ="itemlist_".date('Ymd').".{$type}";
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
Header('Content-Disposition: attachment; filename=' . $file_alias);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Pragma: no-cache');
Header('Expires: 0');
/* ================================= */
$filedName = array(
"분류",
"상품코드",
"상품명",
"기본설명"
);
$prtPattern = "";
foreach($filedName as $val ) {
$prtPattern .= ',"%s"';
}
$prtPattern = substr($prtPattern, 1)."\r\n";
echo "\xEF\xBB\xBF";
vprintf($prtPattern, $filedName );
$filedValues = array(
preg_replace('/[\"]/', '""', $row['ca_id'])
,preg_replace('/[\"]/', '""', $row['it_id'])
,preg_replace('/[\"]/', '""', $row['it_name'])
,preg_replace('/[\"]/', '""', $row['it_basic'])
);
vprintf($prtPattern, $filedValues );
?>
개발한것 제외하느라 정상작동할진 모르겠네요 필요하신 분 쓰세용
팁자료실에 없어서 만드느라 힘들었네요 ㅠㅠ
댓글 15개
게시글 목록
| 번호 | 제목 |
|---|---|
| 2503 | |
| 2501 | |
| 2497 | |
| 2495 | |
| 2491 | |
| 2490 | |
| 2489 | |
| 2486 | |
| 2484 | |
| 2483 | |
| 2481 | |
| 2476 | |
| 2475 | |
| 2474 | |
| 2472 | |
| 2469 | |
| 2467 | |
| 2466 | |
| 2465 | |
| 2464 | |
| 2463 | |
| 2460 | |
| 2459 | |
| 2456 | |
| 2449 | |
| 2446 | |
| 2441 | |
| 2420 | |
| 2419 | |
| 2417 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기