답변 2개 / 댓글 4개
채택된 답변
+20 포인트
답변에 대한 댓글 2개
itemlist_excel.php 파일을 다음과 같이 한번해보세요.
Copy
<?php
include_once('./_common.php');
auth_check($auth[$sub_menu], 'r');
// MS엑셀 XLS 데이터로 다운로드 받음
$sql = " SELECT *
FROM {$g5['g5_shop_item_table']} ";
$result = sql_query($sql);
$cnt = @sql_num_rows($result);
if (!$cnt)
alert("출력할 내역이 없습니다.");
/*================================================================================
php_writeexcel http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/
=================================================================================*/
include_once(G5_LIB_PATH.'/Excel/php_writeexcel/class.writeexcel_workbook.inc.php');
include_once(G5_LIB_PATH.'/Excel/php_writeexcel/class.writeexcel_worksheet.inc.php');
$fname = tempnam(G5_DATA_PATH, "tmp-productlist.xls");
$workbook = new writeexcel_workbook($fname);
$worksheet = $workbook->addworksheet();
// Put Excel data
$data = array('상품고유번호', '상품명');
$data = array_map('iconv_euckr', $data);
$col = 0;
foreach($data as $cell) {
$worksheet->write(0, $col++, $cell);
}
$save_it_id = '';
for($i=1; $row=sql_fetch_array($result); $i++)
{
$row = array_map('iconv_euckr', $row);
$worksheet->write($i, 0, ' '.$row['it_id']);
$worksheet->write($i, 1, $row['it_name']); //다운받길 원하시는 걸 아래로 쭉 적으시면 됩니다.
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\"상품리스트-".date("ymd", time()).".xls\"");
header("Content-Disposition: inline; filename=\"상품리스트-".date("ymd", time()).".xls\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
exit;
?>
답변을 작성하려면 로그인이 필요합니다.