엑셀 상품다운시 깨짐
본문
안녕하세요
엑셀로 다운받을시 깨지는데 안깨지게 할수있는 방법이있을까요 ?
아래와같이 이상한 문양이 나옵니다
<?php
include_once('./_common.php');
auth_check($auth[$sub_menu], 'r');
// MS엑셀 XLS 데이터로 다운로드 받음
$sql = " SELECT *
FROM {$g5['g5_shop_item_table']} order by it_maker ASC ";
$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_maker']);
$worksheet->write($i, 2, ' '.$row['it_price']);
$worksheet->write($i, 3, $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;
?>
답변 2
해당은 보통 소스가 에러 나면 나오는 현상인데 엑셀 출력 뺴고 소스상 문제가 없는지 한벉 체크해보셔야 할거 같습니다.
서버 관련 문제 일 수 있습니다.
보통 서버측 에러입니다.
답변을 작성하시기 전에 로그인 해주세요.